summaryrefslogtreecommitdiff
path: root/groupaccess.c
diff options
context:
space:
mode:
Diffstat (limited to 'groupaccess.c')
-rw-r--r--groupaccess.c27
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 */
95int
96ga_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 */
93void 118void