From 7418e4c6c2888da86f9dc88166c3ffa6333dd9a6 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 5 Nov 1994 20:48:06 +0000 Subject: Fix group permissions check for group list size > 1 Pointed by Bruce --- bin/test/test.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'bin/test') diff --git a/bin/test/test.c b/bin/test/test.c index a7785ac..3b3f4d0 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: test.c,v 1.7 1994/11/05 17:31:23 ache Exp $ + * $Id: test.c,v 1.8 1994/11/05 20:24:49 ache Exp $ */ #ifndef lint @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)test.c 8.3 (Berkeley) 4/2/94"; #include #include +#include #include #include @@ -359,8 +360,17 @@ exist: i = S_IXOTH; permission: if (fs->stat.st_uid == geteuid()) i <<= 6; - else if (fs->stat.st_gid == getegid()) - i <<= 3; + else { + gid_t grlist[NGROUPS]; + int ngroups, j; + + ngroups = getgroups(NGROUPS, grlist); + for (j = 0; j < ngroups; j++) + if (fs->stat.st_gid == grlist[j]) { + i <<= 3; + goto filebit; + } + } } else i = S_IXOTH|S_IXGRP|S_IXUSR; goto filebit; /* true if (stat.st_mode & i) != 0 */ -- cgit v1.1