]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Don't open-code test for UID != 0.
authorJim Meyering <jim@meyering.net>
Sat, 19 Jul 2003 11:47:17 +0000 (11:47 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 19 Jul 2003 11:47:17 +0000 (11:47 +0000)
Use priv-check's require-non-root instead.
Update to use newer framework.

tests/shred/remove

index 70ded037d871e18f8b4d161118b92a6da2f7b88b..5f250811363748eb67b1d93d27bdff6caac765ac 100755 (executable)
@@ -6,18 +6,21 @@ if test "$VERBOSE" = yes; then
   shred --version
 fi
 
+PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+
 pwd=`pwd`
-tmp=t-shred.$$
-trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
-trap 'exit $?' 1 2 13 15
+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
 
 # The length of the basename is what matters.
 # In this case, shred would try to rename the file 256^10 times
 # before terminating.
-file=$tmp/0123456789
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
+file=0123456789
 touch $file || framework_failure=1
 chmod u-w $file || framework_failure=1
 
@@ -26,13 +29,6 @@ if test $framework_failure = 1; then
   exit 1
 fi
 
-(echo foo >> $file) >/dev/null 2>&1 && {
-  echo '********************************************'
-  echo "$0: NOTICE: This test case cannot be run as root."
-  echo '********************************************'
-  exit 77
-}
-
 fail=0
 
 # This would take so long that it appears to infloop
@@ -40,7 +36,4 @@ fail=0
 # When the command completes, expect it to fail.
 shred -u $file > /dev/null 2>&1 && fail=1
 
-chmod u+w $tmp
-rm -rf $tmp
-
 exit $fail