From 0b3fe5c767eeec05d4a1486bd5da33f69f2b0cac Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Oct 05 2004 15:45:31 +0000 Subject: - getgrouplist() patch from Ulrich Drepper. --- diff --git a/coreutils-getgrouplist.patch b/coreutils-getgrouplist.patch new file mode 100644 index 0000000..35ad04a --- /dev/null +++ b/coreutils-getgrouplist.patch @@ -0,0 +1,68 @@ +--- coreutils-5.2.1/m4/jm-macros.m4.getgrouplist 2003-12-20 17:57:18.000000000 +0000 ++++ coreutils-5.2.1/m4/jm-macros.m4 2004-10-05 12:43:14.975401711 +0100 +@@ -83,6 +83,7 @@ + endpwent \ + fdatasync \ + ftruncate \ ++ getgrouplist \ + gethrtime \ + hasmntopt \ + isascii \ +--- coreutils-5.2.1/lib/getugroups.c.getgrouplist 2003-09-10 07:23:09.000000000 +0100 ++++ coreutils-5.2.1/lib/getugroups.c 2004-10-05 12:43:14.980400761 +0100 +@@ -21,6 +21,9 @@ + # include + #endif + ++/* We do not need this code if getgrouplist(3) is available. */ ++#ifndef HAVE_GETGROUPLIST ++ + #include + #include /* grp.h on alpha OSF1 V2.0 uses "FILE *". */ + #include +@@ -95,3 +98,4 @@ + + return count; + } ++#endif /* have getgrouplist */ +--- coreutils-5.2.1/src/id.c.getgrouplist 2004-10-05 12:26:40.222539037 +0100 ++++ coreutils-5.2.1/src/id.c 2004-10-05 12:43:14.986399620 +0100 +@@ -316,14 +316,36 @@ + if (username == 0) + max_n_groups = getgroups (0, NULL); + else +- max_n_groups = getugroups (0, NULL, username, gid); ++ { ++#ifdef HAVE_GETGROUPLIST ++ max_n_groups = 0; ++ getgrouplist (username, gid, NULL, &max_n_groups); ++#else ++ max_n_groups = getugroups (0, NULL, username, gid); ++#endif ++ } + + /* Add 1 just in case max_n_groups is zero. */ + g = xmalloc (max_n_groups * sizeof (GETGROUPS_T) + 1); + if (username == 0) + ng = getgroups (max_n_groups, g); + else +- ng = getugroups (max_n_groups, g, username, gid); ++ { ++#ifdef HAVE_GETGROUPLIST ++ int e; ++ ng = max_n_groups; ++ while ((e = getgrouplist (username, gid, g, &ng)) == -1 ++ && ng > max_n_groups) ++ { ++ max_n_groups = ng; ++ g = xrealloc (g, max_n_groups * sizeof (GETGROUPS_T)); ++ } ++ if (e == -1) ++ ng = -1; ++#else ++ ng = getugroups (max_n_groups, g, username, gid); ++#endif ++ } + + if (ng < 0) + { diff --git a/coreutils.spec b/coreutils.spec index d1a2c12..baac5df 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -4,7 +4,7 @@ Summary: The GNU core utilities: a set of tools commonly used in shell scripts Name: coreutils Version: 5.2.1 -Release: 30 +Release: 31 License: GPL Group: System Environment/Base Url: ftp://alpha.gnu.org/gnu/coreutils/ @@ -45,6 +45,7 @@ Patch904: coreutils-5.0-allow_old_options.patch Patch905: coreutils-jday.patch Patch906: coreutils-fchown.patch Patch907: coreutils-5.2.1-runuser.patch +Patch908: coreutils-getgrouplist.patch # From upstream Patch920: coreutils-dateseconds.patch @@ -104,6 +105,7 @@ the old GNU fileutils, sh-utils, and textutils packages. %patch905 -p1 -b .jday %patch906 -p1 -b .fchown %patch907 -p1 -b .runuser +%patch908 -p1 -b .getgrouplist # From upstream %patch920 -p1 -b .dateseconds @@ -246,7 +248,8 @@ fi /sbin/runuser %changelog -* Tue Oct 5 2004 Tim Waugh +* Tue Oct 5 2004 Tim Waugh 5.2.1-31 +- getgrouplist() patch from Ulrich Drepper. - The selinux patch should be applied last. * Mon Oct 4 2004 Dan Walsh 5.2.1-30