Blame SOURCES/coreutils-8.22-id-groups.patch

fc4c3c
diff -urNp coreutils-8.4-orig/src/id.c coreutils-8.4/src/id.c
fc4c3c
--- coreutils-8.4-orig/src/id.c	2014-06-26 08:47:28.435047859 +0200
fc4c3c
+++ coreutils-8.4/src/id.c	2014-06-26 08:55:28.352788022 +0200
fc4c3c
@@ -296,8 +296,12 @@ print_full_info (const char *username)
fc4c3c
     gid_t *groups;
fc4c3c
     int i;
fc4c3c
 
fc4c3c
-    int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : -1),
fc4c3c
-                               &groups);
fc4c3c
+    gid_t primary_group;
fc4c3c
+    if (username)
fc4c3c
+      primary_group = pwd ? pwd->pw_gid : -1;
fc4c3c
+    else
fc4c3c
+      primary_group = egid;
fc4c3c
+    int n_groups = xgetgroups (username, primary_group, &groups);
fc4c3c
     if (n_groups < 0)
fc4c3c
       {
fc4c3c
         if (username)
fc4c3c
fc4c3c
diff -urNp coreutils-8.22-orig/tests/id/setgid.sh coreutils-8.22/tests/id/setgid.sh
fc4c3c
--- coreutils-8.22-orig/tests/id/setgid.sh	2014-06-26 08:47:28.750053213 +0200
fc4c3c
+++ coreutils-8.22/tests/id/setgid.sh	2014-06-26 08:51:02.536624404 +0200
fc4c3c
@@ -1,5 +1,5 @@
fc4c3c
 #!/bin/sh
fc4c3c
-# Verify that id -G prints the right group when run set-GID.
fc4c3c
+# Verify that id [-G] prints the right group when run set-GID.
fc4c3c
 
fc4c3c
 # Copyright (C) 2012-2013 Free Software Foundation, Inc.
fc4c3c
 
fc4c3c
@@ -35,4 +35,9 @@ setuidgid -g $gp1 $NON_ROOT_USERNAME env
fc4c3c
 compare exp out || fail=1
fc4c3c
 # With coreutils-8.16 and earlier, id -G would print both: $gp1 $g
fc4c3c
 
fc4c3c
+# With coreutils-8.22 and earlier, id would erroneously print groups=$g
fc4c3c
+chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \
fc4c3c
+  id > out || fail=1
fc4c3c
+grep -F "groups=$gp1" out || fail=1
fc4c3c
+
fc4c3c
 Exit $fail