From acb422bdd1b325285bb46883f02d8fc6402efd14 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Thu, 26 Jun 2014 12:41:01 +0100 Subject: tests: use predetermined NON_ROOT_GID * HACKING: GID is more useful in tests than group name, so rename input param from NON_ROOT_GROUP to NON_ROOT_GID to make it obvious that only a group ID is now acceptable, thus allowing GID lookups to be avoided throughout the tests. * init.cfg (require_root_): Likewise. * tests/misc/truncate-owned-by-other.sh: Avoid looking up the GID. * tests/touch/now-owned-by-other.sh: Likewise. * tests/misc/chroot-credentials.sh: Likewise. Also fix an instance of comparison against NON_ROOT_GROUP which would have given a false failure if a non numeric value was passed in. * tests/id/setgid.sh: Use previously looked up gid as a more accurate base for the subsequent adjustment, and move the uid lookup within chroot, rather than having the overhead of a separate `id` invocation. --- tests/id/setgid.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'tests/id') diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh index 0664c47a2..6d9d74f43 100755 --- a/tests/id/setgid.sh +++ b/tests/id/setgid.sh @@ -20,21 +20,20 @@ print_ver_ id require_root_ -u=$(id -u $NON_ROOT_USERNAME) || framework_failure_ -g=$u - -# Construct a different group number. -gp1=$(expr $g + 1) +# Construct a different group number +gp1=$(expr $NON_ROOT_GID + 1) echo $gp1 > exp || framework_failure_ -# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g -chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \ +# With coreutils-8.16 and earlier, id -G would print both: +# $gp1 $NON_ROOT_GID +chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \ id -G > out || fail=1 -compare exp out || { cat out; fail=1; } +compare exp out || fail=1 -# With coreutils-8.22 and earlier, id would erroneously print groups=$g -chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \ +# With coreutils-8.22 and earlier, id would erroneously print +# groups=$NON_ROOT_GID +chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \ id > out || fail=1 grep -F "groups=$gp1" out || { cat out; fail=1; } -- cgit v1.2.3-70-g09d2