]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
id: handle systems without getgroups support
authorEric Blake <ebb9@byu.net>
Fri, 4 Dec 2009 15:06:55 +0000 (08:06 -0700)
committerEric Blake <ebb9@byu.net>
Sat, 5 Dec 2009 02:18:06 +0000 (19:18 -0700)
If getgroups failed with ENOSYS, mgetgroups would unnecessarily
fail, and that provoked id into freeing an uninitialized pointer.
Meanwhile, we were not using xalloc_die properly.  Both issues
are better solved in gnulib, by introducing xgetgroups; this
patch uses the new interface.

Regression introduced by commit 6a31fd8d7.

* gnulib: Update, for mgetgroups improvments.
* src/id.c (print_full_info): Adjust caller to die on allocation
failure, and no longer worry about ENOSYS.
* src/group-list.c (print_group_list): Likewise.
* src/setuidgid.c (main): Likewise.
* NEWS: Mention the fix.
* THANKS: Update.
Reported by Scott Harrison.

NEWS
THANKS
gnulib
src/group-list.c
src/id.c
src/setuidgid.c

diff --git a/NEWS b/NEWS
index 9f7bf2e5f5a03e9b6faad6f3f93aa582693dcd8d..19cca5bdb9d3786b33e57dda33d4eaaebe70898a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  id no longer crashes on systems without supplementary group support.
+  [bug introduced in coreutils-8.1]
+
   rm once again handles zero-length arguments properly.
   The rewrite to make rm use fts introduced a regression whereby
   a command like "rm a '' b" would fail to remove "a" and "b", due to
diff --git a/THANKS b/THANKS
index 52d41705a4353893de26d7cfbaf58901969a1009..3b03587d65f36cb481feae1181311d8a64ac87e0 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -529,6 +529,7 @@ Samuli Karkkainen                   Samuli.Karkkainen@hut.fi
 Sander van Malssen                  svm@kozmix.ow.nl
 Santiago Vila Doncel                sanvila@unex.es
 Savochkin Andrey Vladimirovich      saw@msu.ru
+Scott Harrison                      scott.gnu.2009@scottrix.co.uk
 Scott Lurndal                       slurn@griffin.engr.sgi.com
 Sébastien Maret                     smaret@umich.edu
 Sergei Steshenko                    sergstesh@yahoo.com
diff --git a/gnulib b/gnulib
index cdfe647f8d29540cdfe90cef0fa568c5d2fd4481..3e035a5d686888e5eba0b622dac459b65cdd99d3 160000 (submodule)
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit cdfe647f8d29540cdfe90cef0fa568c5d2fd4481
+Subproject commit 3e035a5d686888e5eba0b622dac459b65cdd99d3
index 1fadd0c579a98b198b7fc9c371af329ed397198d..a4b1f6dc6aa22509cba5bcf151138576718d6ec6 100644 (file)
@@ -58,9 +58,9 @@ print_group_list (const char *username,
     gid_t *groups;
     int i;
 
-    int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
+    int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
                                &groups);
-    if (n_groups < 0 && errno != ENOSYS)
+    if (n_groups < 0)
       {
         if (username)
           {
index 9a00f5ce4cfe7ef59a6b6706d532c84005fa1782..96d8e965eb13c9faa4381be187fb53183f6b5840 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -296,9 +296,9 @@ print_full_info (const char *username)
     gid_t *groups;
     int i;
 
-    int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
+    int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
                                &groups);
-    if (n_groups < 0 && errno != ENOSYS)
+    if (n_groups < 0)
       {
         if (username)
           {
index 0adac215c171b01240d3c38e2560f73bee7be20c..2710bc9de2470cdaabb3f63272cf04c3e675f958 100644 (file)
@@ -179,7 +179,7 @@ main (int argc, char **argv)
 #if HAVE_SETGROUPS
     if (n_gids == 0)
       {
-        int n = mgetgroups (pwd->pw_name, pwd->pw_gid, &gids);
+        int n = xgetgroups (pwd->pw_name, pwd->pw_gid, &gids);
         if (n <= 0)
           error (EXIT_FAILURE, errno, _("failed to get groups for user %s"),
                  quote (pwd->pw_name));