This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: getgroups


	
Hello!

I have patched the `getgroups' function so that supplementary groups
are taken into account. They are eg. shown by `id(1)' now.

Furthermore in limits.h and sys/params.h the defines for NGROUPS
and NGROUPS_MAX are changed according to M$.

Take care,
Corinna


ChangeLog:
==========

Sun Dec 26 22:39:00 1999  Corinna Vinschen  <corinna@vinschen.de>

	* grp.cc (getgroups): Returns supplementary groups now.
	* include/limits.h: Defines NGROUP_MAX as 16 now.
	* ../newlib/libc/sys/cygwin/sys/param.h: Ditto.
Index: grp.cc
===================================================================
RCS file: /src/cvsroot/winsup-991223/grp.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 grp.cc
--- grp.cc	1999/12/26 15:03:14	1.1.1.1
+++ grp.cc	1999/12/26 21:02:30
@@ -236,10 +236,39 @@ extern "C"
 int
 getgroups (int gidsetsize, gid_t *grouplist)
 {
+#if 0
   if (gidsetsize <= 0)
       return 0;
   grouplist[0] = myself->gid;
   return 1;
+#else
+  if (!group_in_memory_p)
+    read_etc_group();
+
+  int cnt = 0;
+
+  for (int i = 0; i < curr_lines; ++i)
+    if (myself->gid == group_buf[i].gr_gid)
+      {
+        if (cnt < gidsetsize)
+          grouplist[cnt] = group_buf[i].gr_gid;
+        ++cnt;
+        if (gidsetsize && cnt >= gidsetsize)
+          goto out;
+      }
+    else if (group_buf[i].gr_mem)
+      for (int gi = 0; group_buf[i].gr_mem[gi]; ++gi)
+        if (! strcasecmp (myself->username, group_buf[i].gr_mem[gi]))
+          {
+            if (cnt < gidsetsize)
+              grouplist[cnt] = group_buf[i].gr_gid;
+            ++cnt;
+            if (gidsetsize && cnt >= gidsetsize)
+              goto out;
+          }
+out:
+  return cnt;
+#endif
 }
 
 extern "C"
Index: include/limits.h
===================================================================
RCS file: /src/cvsroot/winsup-991223/include/limits.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 limits.h
--- include/limits.h	1999/12/26 15:03:20	1.1.1.1
+++ include/limits.h	1999/12/26 21:19:46
@@ -104,9 +104,9 @@
 /* Maximum length of a path */
 #define PATH_MAX (260 - 1 /*NUL*/)
 
-/* Max num groups for a user, only current GID available under Windows */
+/* Max num groups for a user, value taken from NT documentation */
 /* Must match <sys/param.h> NGROUPS */
-#define NGROUPS_MAX 1
+#define NGROUPS_MAX 16
 
 /* WaitForMultipleObjects can't handle waiting for more than 64 objects.
    This limits how many children we can fork/spawn off. */
--- ../newlib/libc/sys/cygwin/sys/param.h.orig	Sun Dec 26 22:22:00 1999
+++ ../newlib/libc/sys/cygwin/sys/param.h	Sun Dec 26 22:21:16 1999
@@ -11,7 +11,7 @@
 #define NOFILE		8192
 
 /* Max number of groups; must keep in sync with NGROUPS_MAX in limits.h */
-#define NGROUPS		1
+#define NGROUPS		16
 
 /* Ticks/second for system calls such as times() */
 /* FIXME: is this the appropriate value? */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]