diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 1994-11-05 20:48:06 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 1994-11-05 20:48:06 +0000 |
commit | 5b515dcb3871efadfea4ccf487ca2def5aa68d87 (patch) | |
tree | 0281f0143783852dd44da7c9291cb703871a16e2 /bin | |
parent | 20662469d56b27ce7a59acbc9f7ef907cd16aaf2 (diff) | |
download | src-5b515dcb3871efadfea4ccf487ca2def5aa68d87.tar.gz src-5b515dcb3871efadfea4ccf487ca2def5aa68d87.zip |
Fix group permissions check for group list size > 1
Pointed by Bruce
Notes
Notes:
svn path=/head/; revision=4171
Diffstat (limited to 'bin')
-rw-r--r-- | bin/test/test.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/bin/test/test.c b/bin/test/test.c index a7785ac4ad6b..3b3f4d0b16ad 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 <sys/types.h> #include <sys/stat.h> +#include <sys/param.h> #include <ctype.h> #include <err.h> @@ -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 */ |