summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-06-26 12:41:01 +0100
committerPádraig Brady <P@draigBrady.com>2014-06-26 15:30:41 +0100
commitacb422bdd1b325285bb46883f02d8fc6402efd14 (patch)
tree1f77b51c48cff7532a9227fa3517c5c26eee30be /tests/misc
parente7c7802964cbf0f77a5883808e28eab56e36907b (diff)
downloadcoreutils-acb422bdd1b325285bb46883f02d8fc6402efd14.tar.xz
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.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/chroot-credentials.sh8
-rwxr-xr-xtests/misc/truncate-owned-by-other.sh4
2 files changed, 5 insertions, 7 deletions
diff --git a/tests/misc/chroot-credentials.sh b/tests/misc/chroot-credentials.sh
index d50704ccc..b06e8b7f0 100755
--- a/tests/misc/chroot-credentials.sh
+++ b/tests/misc/chroot-credentials.sh
@@ -29,7 +29,7 @@ root=$(id -nu 0) || skip_ "Couldn't look up root username"
# verify numeric IDs looked up similarly to names
NON_ROOT_UID=$(id -u $NON_ROOT_USERNAME)
-NON_ROOT_GID=$(id -g $NON_ROOT_USERNAME)
+NON_ROOT_GROUP=$NON_ROOT_GID # Used where we want name lookups to occur
# "uid:" is supported (unlike chown etc.) since we treat it like "uid"
chroot --userspec=$NON_ROOT_UID: / true || fail=1
@@ -64,7 +64,7 @@ id_G_after_chroot=$(
chroot --userspec=$NON_ROOT_USERNAME:$NON_ROOT_GROUP \
--groups=$NON_ROOT_GROUP / id -G
)
-test "$id_G_after_chroot" = $NON_ROOT_GROUP || fail=1
+test "$id_G_after_chroot" = $NON_ROOT_GID || fail=1
# Verify that when specifying only the user name we get all their groups
test "$(chroot --userspec=$NON_ROOT_USERNAME / id -G)" = \
@@ -77,7 +77,7 @@ test "$(chroot --userspec=$NON_ROOT_USERNAME: / id -G)" = \
# Verify that when specifying only the user and clearing supplemental groups
# that we only get the primary group
test "$(chroot --userspec=$NON_ROOT_USERNAME --groups='' / id -G)" = \
- "$(id -g $NON_ROOT_USERNAME)" || fail=1
+ $NON_ROOT_GID || fail=1
# Verify that when specifying only the UID we get all their groups
test "$(chroot --userspec=$NON_ROOT_UID / id -G)" = \
@@ -88,7 +88,7 @@ test "$(chroot --userspec=$NON_ROOT_UID / id -G)" = \
# results in no lookups in the name database which could be useful depending
# on your chroot setup.
test "$(chroot --userspec=+$NON_ROOT_UID:+$NON_ROOT_GID --groups='' / id -G)" =\
- "$(id -g $NON_ROOT_USERNAME)" || fail=1
+ $NON_ROOT_GID || fail=1
# Verify that when specifying only a group we get the current user ID
test "$(chroot --userspec=:$NON_ROOT_GROUP / id -u)" = "$(id -u)" \
diff --git a/tests/misc/truncate-owned-by-other.sh b/tests/misc/truncate-owned-by-other.sh
index e93b7f136..e70badb6b 100755
--- a/tests/misc/truncate-owned-by-other.sh
+++ b/tests/misc/truncate-owned-by-other.sh
@@ -21,11 +21,9 @@ print_ver_ truncate
require_root_
-group_num=$(id -g $NON_ROOT_USERNAME)
-
# Create a file owned by root, and writable by $NON_ROOT_USERNAME.
echo > root-owned || framework_failure_
-chgrp +$group_num . root-owned || framework_failure_
+chgrp +$NON_ROOT_GID . root-owned || framework_failure_
chmod g+w root-owned
# Ensure that the current directory is searchable by $NON_ROOT_USERNAME.