Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Message-ID: <38668BC8.7F077F90@vinschen.de> Date: Sun, 26 Dec 1999 22:42:32 +0100 From: Corinna Vinschen X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: de,en MIME-Version: 1.0 To: Chris Faylor CC: cygdev Subject: Patch: getgroups Content-Type: multipart/mixed; boundary="------------36CDAE2E822F6A7C70B0D3DF" This is a multi-part message in MIME format. --------------36CDAE2E822F6A7C70B0D3DF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 * grp.cc (getgroups): Returns supplementary groups now. * include/limits.h: Defines NGROUP_MAX as 16 now. * ../newlib/libc/sys/cygwin/sys/param.h: Ditto. --------------36CDAE2E822F6A7C70B0D3DF Content-Type: text/plain; charset=us-ascii; name="getgroups-patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="getgroups-patch" 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 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? */ --------------36CDAE2E822F6A7C70B0D3DF--