diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-04-06 12:35:52 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-04-06 12:35:52 +0000 |
commit | b62b8d7c8086626f09f699e278d604ac0c8fe9a3 (patch) | |
tree | 84ea779b02926b6a1f9a7c2248201d11c326716a /winsup/cygwin/grp.cc | |
parent | dafef5e249a5ddd5e9a935b802e5e61e4cc8aaa9 (diff) | |
download | cygnal-b62b8d7c8086626f09f699e278d604ac0c8fe9a3.tar.gz cygnal-b62b8d7c8086626f09f699e278d604ac0c8fe9a3.tar.bz2 cygnal-b62b8d7c8086626f09f699e278d604ac0c8fe9a3.zip |
* security.h (cygsidlist::addfromgr): Avoid duplicate entries.
* grp.cc (initgrousp): Add syscall_printf.
(setgroups): Add syscall_printf and make sure sids are added only once.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r-- | winsup/cygwin/grp.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index e79383999..ae3c27ad2 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -448,15 +448,16 @@ getgroups (int gidsetsize, __gid16_t *grouplist) } extern "C" int -initgroups32 (const char *, __gid32_t) +initgroups32 (const char *name, __gid32_t gid) { if (wincap.has_security ()) cygheap->user.groups.clear_supp (); + syscall_printf ( "0 = initgroups (%s, %u)", name, gid); return 0; } extern "C" int -initgroups (const char * name, __gid16_t gid) +initgroups (const char *name, __gid16_t gid) { return initgroups32 (name, gid16togid32(gid)); } @@ -465,6 +466,7 @@ initgroups (const char * name, __gid16_t gid) extern "C" int setgroups32 (int ngroups, const __gid32_t *grouplist) { + syscall_printf ("setgroups32 (%d)", ngroups); if (ngroups < 0 || (ngroups > 0 && !grouplist)) { set_errno (EINVAL); @@ -482,18 +484,13 @@ setgroups32 (int ngroups, const __gid32_t *grouplist) for (int gidx = 0; gidx < ngroups; ++gidx) { - for (int gidy = 0; gidy < gidx; gidy++) - if (grouplist[gidy] == grouplist[gidx]) - goto found; /* Duplicate */ - if ((gr = internal_getgrgid (grouplist[gidx])) && - gsids.addfromgr (gr)) - goto found; + if ((gr = internal_getgrgid (grouplist[gidx])) + && gsids.addfromgr (gr)) + continue; debug_printf ("No sid found for gid %d", grouplist[gidx]); gsids.free_sids (); set_errno (EINVAL); return -1; - found: - continue; } cygheap->user.groups.update_supp (gsids); return 0; |