diff options
author | Darren Tucker <dtucker@zip.com.au> | 2008-07-04 13:51:12 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2008-07-04 13:51:12 +1000 |
commit | b03fd02aede5cb796aea417a7a68e42e7f998d62 (patch) | |
tree | 8975ee0b3277378bc72e6a34aa3ad274c435d321 /groupaccess.c | |
parent | f5cafb0c850a3b6cc7db27fa79afbd4fb185f8f2 (diff) |
- djm@cvs.openbsd.org 2008/07/04 03:44:59
[servconf.c groupaccess.h groupaccess.c]
support negation of groups in "Match group" block (bz#1315); ok dtucker@
Diffstat (limited to 'groupaccess.c')
-rw-r--r-- | groupaccess.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/groupaccess.c b/groupaccess.c index e73f62b22..2381aeb15 100644 --- a/groupaccess.c +++ b/groupaccess.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: groupaccess.c,v 1.12 2006/08/03 03:34:42 deraadt Exp $ */ | 1 | /* $OpenBSD: groupaccess.c,v 1.13 2008/07/04 03:44:59 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Kevin Steves. All rights reserved. | 3 | * Copyright (c) 2001 Kevin Steves. All rights reserved. |
4 | * | 4 | * |
@@ -31,6 +31,7 @@ | |||
31 | #include <grp.h> | 31 | #include <grp.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <stdarg.h> | 33 | #include <stdarg.h> |
34 | #include <string.h> | ||
34 | 35 | ||
35 | #include "xmalloc.h" | 36 | #include "xmalloc.h" |
36 | #include "groupaccess.h" | 37 | #include "groupaccess.h" |
@@ -88,6 +89,30 @@ ga_match(char * const *groups, int n) | |||
88 | } | 89 | } |
89 | 90 | ||
90 | /* | 91 | /* |
92 | * Return 1 if one of user's groups matches group_pattern list. | ||
93 | * Return 0 on negated or no match. | ||
94 | */ | ||
95 | int | ||
96 | ga_match_pattern_list(const char *group_pattern) | ||
97 | { | ||
98 | int i, found = 0; | ||
99 | size_t len = strlen(group_pattern); | ||
100 | |||
101 | for (i = 0; i < ngroups; i++) { | ||
102 | switch (match_pattern_list(groups_byname[i], | ||
103 | group_pattern, len, 0)) { | ||
104 | case -1: | ||
105 | return 0; /* Negated match wins */ | ||
106 | case 0: | ||
107 | continue; | ||
108 | case 1: | ||
109 | found = 1; | ||
110 | } | ||
111 | } | ||
112 | return found; | ||
113 | } | ||
114 | |||
115 | /* | ||
91 | * Free memory allocated for group access list. | 116 | * Free memory allocated for group access list. |
92 | */ | 117 | */ |
93 | void | 118 | void |