diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-05-19 18:21:57 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-05-21 11:18:27 +0100 |
commit | 7a63d6395ac117b753a18468a9b3f5ed95d176d4 (patch) | |
tree | c01b1115f71bd4a4b98b1dc6f9383d4228507e5f /tests | |
parent | 0c4729516baa2fbefb0af66c38f434b1f7519078 (diff) | |
download | coreutils-7a63d6395ac117b753a18468a9b3f5ed95d176d4.tar.xz |
tests: use chroot --user rather than internal setuidgid tool
* init.cfg (require_root_): Adjust to use chroot, and make
`require_built_ chroot` implicit when chroot used in the test.
* po/POTFILES.in: Remove reference to setuidgid tool.
* src/.gitignore: Likewise.
* src/local.mk: Likewise.
* src/setuidgid.c: Remove.
* tests/cp/preserve-gid.sh: s/setuidgid/chroot --user/.
* tests/cp/special-bits.sh: Likewise.
* tests/id/setgid.sh: Likewise.
* tests/misc/truncate-owned-by-other.sh
* tests/mv/sticky-to-xpart.sh: Likewise.
* tests/rm/fail-2eperm.sh: Likewise.
* tests/rm/no-give-up.sh: Likewise.
* tests/touch/now-owned-by-other.sh: Likewise.
* tests/misc/chroot-fail.sh: Skip if chroot not built.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/cp/preserve-gid.sh | 5 | ||||
-rwxr-xr-x | tests/cp/special-bits.sh | 2 | ||||
-rwxr-xr-x | tests/id/setgid.sh | 3 | ||||
-rwxr-xr-x | tests/misc/chroot-fail.sh | 1 | ||||
-rwxr-xr-x | tests/misc/truncate-owned-by-other.sh | 3 | ||||
-rwxr-xr-x | tests/mv/sticky-to-xpart.sh | 4 | ||||
-rwxr-xr-x | tests/rm/fail-2eperm.sh | 4 | ||||
-rwxr-xr-x | tests/rm/no-give-up.sh | 3 | ||||
-rwxr-xr-x | tests/touch/now-owned-by-other.sh | 3 |
9 files changed, 17 insertions, 11 deletions
diff --git a/tests/cp/preserve-gid.sh b/tests/cp/preserve-gid.sh index 77dcdb657..f141ac141 100755 --- a/tests/cp/preserve-gid.sh +++ b/tests/cp/preserve-gid.sh @@ -117,8 +117,9 @@ t1() { u=$1; shift g=$1; shift t0 "$f" "$u" "$g" \ - setuidgid -g "$nameless_gid1,$nameless_gid2" \ - "$nameless_uid" env PATH="$tmp_path" "$@" + chroot --user=+$nameless_uid:+$nameless_gid1 \ + --groups="+$nameless_gid1,+$nameless_gid2" \ + / env PATH="$tmp_path" "$@" } t1 a0 "$nameless_uid" "$nameless_gid1" cp diff --git a/tests/cp/special-bits.sh b/tests/cp/special-bits.sh index 60d26a936..a55eea21f 100755 --- a/tests/cp/special-bits.sh +++ b/tests/cp/special-bits.sh @@ -42,7 +42,7 @@ set _ $(ls -l b); shift; p1=$1 set _ $(ls -l b2); shift; p2=$1 test $p1 = $p2 || fail=1 -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" cp -p c c2 || fail=1 +chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" cp -p c c2 || fail=1 set _ $(ls -l c); shift; p1=$1 set _ $(ls -l c2); shift; p2=$1 test $p1 = $p2 && fail=1 diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh index 9da35385e..aa43ea37f 100755 --- a/tests/id/setgid.sh +++ b/tests/id/setgid.sh @@ -27,7 +27,8 @@ gp1=$(expr $g + 1) echo $gp1 > exp || framework_failure_ -setuidgid -g $gp1 $NON_ROOT_USERNAME env PATH="$PATH" id -G > out || fail=1 +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 diff --git a/tests/misc/chroot-fail.sh b/tests/misc/chroot-fail.sh index b171ec40c..a84826fd7 100755 --- a/tests/misc/chroot-fail.sh +++ b/tests/misc/chroot-fail.sh @@ -20,6 +20,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ chroot +require_built_ chroot # These tests verify exact status of internal failure; since none of # them actually run a command, we don't need root privileges diff --git a/tests/misc/truncate-owned-by-other.sh b/tests/misc/truncate-owned-by-other.sh index 9f269ed4e..e93b7f136 100755 --- a/tests/misc/truncate-owned-by-other.sh +++ b/tests/misc/truncate-owned-by-other.sh @@ -31,6 +31,7 @@ chmod g+w root-owned # Ensure that the current directory is searchable by $NON_ROOT_USERNAME. chmod g+x . -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" truncate -s0 root-owned || fail=1 +chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ + truncate -s0 root-owned || fail=1 Exit $fail diff --git a/tests/mv/sticky-to-xpart.sh b/tests/mv/sticky-to-xpart.sh index ea5948eee..e0c99e946 100755 --- a/tests/mv/sticky-to-xpart.sh +++ b/tests/mv/sticky-to-xpart.sh @@ -42,7 +42,7 @@ chmod go+x . || framework_failure_ # Ensure that $NON_ROOT_USERNAME can access the required version of mv. version=$( - setuidgid $NON_ROOT_USERNAME env PATH="$PATH" mv --version | + chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" mv --version | sed -n '1s/.* //p' ) case $version in @@ -50,7 +50,7 @@ case $version in *) skip_ "cannot access just-built mv as user $NON_ROOT_USERNAME";; esac -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" \ +chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ mv t/root-owned "$other_partition_tmpdir" 2> out-t && fail=1 # On some systems, we get 'Not owner'. Convert it. diff --git a/tests/rm/fail-2eperm.sh b/tests/rm/fail-2eperm.sh index e040d00dc..6e8ce9ba3 100755 --- a/tests/rm/fail-2eperm.sh +++ b/tests/rm/fail-2eperm.sh @@ -32,14 +32,14 @@ touch a/b || framework_failure_ # Try to ensure that $NON_ROOT_USERNAME can access # the required version of rm. rm_version=$( - setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm --version | + chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" rm --version | sed -n '1s/.* //p' ) case $rm_version in $PACKAGE_VERSION) ;; *) skip_ "cannot access just-built rm as user $NON_ROOT_USERNAME";; esac -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf a 2> out-t && fail=1 +chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" rm -rf a 2> out-t && fail=1 # On some systems, we get 'Not owner'. Convert it. # On other systems (HPUX), we get 'Permission denied'. Convert it, too. diff --git a/tests/rm/no-give-up.sh b/tests/rm/no-give-up.sh index 874285959..41070c9de 100755 --- a/tests/rm/no-give-up.sh +++ b/tests/rm/no-give-up.sh @@ -30,7 +30,8 @@ chmod go=x . || framework_failure_ # This must fail, since '.' is not writable by $NON_ROOT_USERNAME. -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" rm -rf d 2>/dev/null && fail=1 +chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ + rm -rf d 2>/dev/null && fail=1 # d must remain. test -d d || fail=1 diff --git a/tests/touch/now-owned-by-other.sh b/tests/touch/now-owned-by-other.sh index 3b5c36896..f5eeda604 100755 --- a/tests/touch/now-owned-by-other.sh +++ b/tests/touch/now-owned-by-other.sh @@ -30,6 +30,7 @@ chmod g+w root-owned # Ensure that the current directory is searchable by $NON_ROOT_USERNAME. chmod g+x . -setuidgid $NON_ROOT_USERNAME env PATH="$PATH" touch -d now root-owned || fail=1 +chroot --user=$NON_ROOT_USERNAME / env PATH="$PATH" \ + touch -d now root-owned || fail=1 Exit $fail |