]> sourceware.org Git - newlib-cygwin.git/commitdiff
* security.h (cygsidlist::addfromgr): Avoid duplicate entries.
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 6 Apr 2005 12:35:52 +0000 (12:35 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 6 Apr 2005 12:35:52 +0000 (12:35 +0000)
* grp.cc (initgrousp): Add syscall_printf.
(setgroups): Add syscall_printf and make sure sids are added only once.

winsup/cygwin/ChangeLog
winsup/cygwin/grp.cc
winsup/cygwin/security.h

index f21b91869d38a64770aac174806aa7bca0b608b0..bc1069a08d7d79e764c3f387b4aa4852cb929ad6 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-06  Pierre Humblet <pierre.humblet@ieee.org>
+
+       * 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.
+
 2005-04-06  Christopher Faylor  <cgf@timesys.com>
 
        * net.cc (cygwin_getservbyname): Return (possibly NULL) return value of
index e79383999c741ce5c78c69375d6097d17061aaa6..ae3c27ad21bfa6a98caaadbef54e0643dcd0436f 100644 (file)
@@ -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;
index 0ee8e7134f47b8c6ffc4418ba9654d6fcf4eeded..1c95d30b32e19731fd590dafbbf12ccf5824eee5 100644 (file)
@@ -148,7 +148,8 @@ public:
   BOOL add (const char *sidstr)
     { cygsid nsi (sidstr); return add (nsi); }
   BOOL addfromgr (struct __group32 *gr) /* Only with alloc */
-    { return sids[count++].getfromgr (gr); }
+    { return sids[count].getfromgr (gr)
+            && (contains (sids[count]) || ++count); }
 
   BOOL operator+= (cygsid &si) { return add (si); }
   BOOL operator+= (const char *sidstr) { return add (sidstr); }
This page took 0.037887 seconds and 5 git commands to generate.