summaryrefslogtreecommitdiff
path: root/tests/id
diff options
context:
space:
mode:
authorPetr Stodůlka <pstodulk@redhat.com>2014-06-25 18:26:23 +0100
committerPádraig Brady <P@draigBrady.com>2014-06-26 12:07:10 +0100
commit408461c0e7e5ddc6bfd0fddb2c79d35a02238ee0 (patch)
tree217c189cbf8ef3bc5b0279e78a7e2cdfed4c3afe /tests/id
parentd71c12f1e4e165c7da59989b49ded2805b7977cc (diff)
downloadcoreutils-408461c0e7e5ddc6bfd0fddb2c79d35a02238ee0.tar.gz
id: output the effective group for the process
* src/id.c (print_full_info): When no user is specified, output the effective group for the _process_, rather than the default group from the system database, which may be different. * tests/id/setgid.sh: Add a case for `id` as well as `id -G`. * NEWS: Mention the bug fix. Fixes http://bugs.gnu.org/7320 Reported at http://bugzilla.redhat.com/1016163
Diffstat (limited to 'tests/id')
-rwxr-xr-xtests/id/setgid.sh16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh
index aa43ea37f..0664c47a2 100755
--- a/tests/id/setgid.sh
+++ b/tests/id/setgid.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Verify that id -G prints the right group when run set-GID.
+# Verify that id [-G] prints the right group when run set-GID.
# Copyright (C) 2012-2014 Free Software Foundation, Inc.
@@ -20,16 +20,22 @@
print_ver_ id
require_root_
-g=$(id -u $NON_ROOT_USERNAME) || framework_failure_
+u=$(id -u $NON_ROOT_USERNAME) || framework_failure_
+g=$u
# Construct a different group number.
gp1=$(expr $g + 1)
echo $gp1 > exp || framework_failure_
-chroot --user=$NON_ROOT_USERNAME:$gp1 --groups='' / env PATH="$PATH" \
- id -G > out || fail=1
-compare exp out || fail=1
# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g
+chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \
+ id -G > out || fail=1
+compare exp out || { cat out; fail=1; }
+
+# With coreutils-8.22 and earlier, id would erroneously print groups=$g
+chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \
+ id > out || fail=1
+grep -F "groups=$gp1" out || { cat out; fail=1; }
Exit $fail