coreutils/coreutils-getgrouplist.patch

70 lines
1.8 KiB
Diff
Raw Normal View History

--- coreutils-6.7/lib/getugroups.c.getgrouplist 2006-09-14 10:53:58.000000000 +0100
+++ coreutils-6.7/lib/getugroups.c 2007-01-09 17:33:09.000000000 +0000
@@ -21,6 +21,9 @@
#include <config.h>
+/* 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>
@@ -102,3 +105,4 @@
return count;
}
+#endif /* have getgrouplist */
--- coreutils-6.7/src/id.c.getgrouplist 2006-10-22 17:54:15.000000000 +0100
+++ coreutils-6.7/src/id.c 2007-01-09 17:33:09.000000000 +0000
@@ -253,7 +253,14 @@
if (!username)
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
+ }
if (max_n_groups < 0)
ng = -1;
@@ -263,7 +270,22 @@
if (!username)
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)
--- coreutils-6.7/m4/jm-macros.m4.getgrouplist 2006-12-06 11:04:22.000000000 +0000
+++ coreutils-6.7/m4/jm-macros.m4 2007-01-09 17:33:47.000000000 +0000
@@ -64,6 +64,7 @@
fchown \
fchmod \
ftruncate \
+ getgrouplist \
iswspace \
mkfifo \
mbrlen \