X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/01d35895bd00d71a21c3429c7012197150d621a4..4866258754324a73893b037557802c92515e2bc6:/groupaccess.c diff --git a/groupaccess.c b/groupaccess.c index 2a85cb37..2381aeb1 100644 --- a/groupaccess.c +++ b/groupaccess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: groupaccess.c,v 1.8 2006/03/25 13:17:01 djm Exp $ */ +/* $OpenBSD: groupaccess.c,v 1.13 2008/07/04 03:44:59 djm Exp $ */ /* * Copyright (c) 2001 Kevin Steves. All rights reserved. * @@ -25,8 +25,16 @@ #include "includes.h" -#include "groupaccess.h" +#include +#include + +#include +#include +#include +#include + #include "xmalloc.h" +#include "groupaccess.h" #include "match.h" #include "log.h" @@ -80,6 +88,30 @@ ga_match(char * const *groups, int n) return 0; } +/* + * Return 1 if one of user's groups matches group_pattern list. + * Return 0 on negated or no match. + */ +int +ga_match_pattern_list(const char *group_pattern) +{ + int i, found = 0; + size_t len = strlen(group_pattern); + + for (i = 0; i < ngroups; i++) { + switch (match_pattern_list(groups_byname[i], + group_pattern, len, 0)) { + case -1: + return 0; /* Negated match wins */ + case 0: + continue; + case 1: + found = 1; + } + } + return found; +} + /* * Free memory allocated for group access list. */