From c42d31bc781550121dca4d836470b11fbed3e0ed Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 18 Jul 2003 09:12:23 +0000 Subject: Use $srcdir/../priv-check, create a temporary directory, and remove Perl-coded `you may not run as root' test. --- tests/rm/fail-eperm | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'tests/rm/fail-eperm') diff --git a/tests/rm/fail-eperm b/tests/rm/fail-eperm index 2e4d64cb3..6e6feb641 100755 --- a/tests/rm/fail-eperm +++ b/tests/rm/fail-eperm @@ -3,6 +3,27 @@ # Ensure that rm gives the expected diagnostic when failing to remove a file # owned by some other user in a directory with the sticky bit set. +if test "$VERBOSE" = yes; then + set -x + rm --version +fi + +PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + : ${PERL=perl} : ${srcdir=.} @@ -28,13 +49,6 @@ $verbose # Ensure that the diagnostics are in English. $ENV{LC_ALL} = 'C'; -# Ensure that the effective UID is not 0. -if ($> == 0) - { - warn "$ME: you may not run this test as root; skipping it.\n"; - exit 77; - } - my @dir_list = qw(/tmp /var/tmp /usr/tmp); # Find a directory with the sticky bit set. -- cgit v1.2.3-54-g00ecf