- getgrouplist() patch from Ulrich Drepper.

This commit is contained in:
Tim Waugh 2004-10-05 15:45:31 +00:00
parent 1ba26cacf9
commit 0b3fe5c767
2 changed files with 73 additions and 2 deletions

View File

@ -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 <config.h>
#endif
+/* We do not need this code if getgrouplist(3) is available. */
+#ifndef HAVE_GETGROUPLIST
+
#include <sys/types.h>
#include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */
#include <grp.h>
@@ -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)
{

View File

@ -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 <twaugh@redhat.com>
* Tue Oct 5 2004 Tim Waugh <twaugh@redhat.com> 5.2.1-31
- getgrouplist() patch from Ulrich Drepper.
- The selinux patch should be applied last.
* Mon Oct 4 2004 Dan Walsh <dwalsh@redhat.com> 5.2.1-30