2 # Make sure that touch gives reasonable diagnostics when applied
3 # to an unwritable directory owned by some other user.
5 if test "$VERBOSE" = yes; then
10 . $srcdir/../envvar-check
11 . $srcdir/../lang-default
12 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
16 echo Skipping because you have write access to /.
20 if $test -O / || $test -G /; then
21 echo Skipping because you own /.
26 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
27 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
28 trap '(exit $?); exit $?' 1 2 13 15
31 mkdir -p $tmp || framework_failure=1
32 cd $tmp || framework_failure=1
34 if test $framework_failure = 1; then
35 echo "$0: failure in testing framework" 1>&2
41 # Before fileutils-4.1, we'd get the following misleading
42 # diagnostic instead of `...: Permission denied'.
43 # touch: creating `/': Is a directory
44 touch / > out 2>&1 && fail=1
46 # On SunOS4, EPERM is `Not owner'.
47 # On some *BSD systems it's `Operation not permitted'.
48 for msg in 'Not owner' 'Operation not permitted' 'Permission denied'; do
50 touch: setting times of \`/': $msg
53 cmp out exp > /dev/null 2>&1 && { match=1; break; }
55 test "$match" = 1 || fail=1
57 test $fail = 1 && diff out exp 2> /dev/null
59 (exit $fail); exit $fail