]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
*** empty log message ***
authorJim Meyering <jim@meyering.net>
Sat, 15 Sep 2001 17:07:54 +0000 (17:07 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 15 Sep 2001 17:07:54 +0000 (17:07 +0000)
old/fileutils/ChangeLog
tests/touch/fail-diag [new file with mode: 0755]

index f210c74d2a4e89019d0e5eab649708ba122124ba..a1aa0eb9e2ef6222162232f86936f60bff0e6e4c 100644 (file)
@@ -1,5 +1,11 @@
 2001-09-15  Jim Meyering  <meyering@lucent.com>
 
+       * src/touch.c (EISDIR): Define to 0, if not already defined.
+       (touch): Give a better diagnostic for e.g., `touch /' by non-root.
+       Based on a patch from Michael Stone.
+       Reported by Jeff Sheinberg as Debian bug #101677.
+       * tests/touch/fail-diag: New test, for the above fix.
+
        * src/copy.c (copy_internal) [move_mode]: Support the new
        --reply=... option.
        (UNWRITABLE): Define (factored out of copy_internal).
diff --git a/tests/touch/fail-diag b/tests/touch/fail-diag
new file mode 100755 (executable)
index 0000000..f1fd037
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+# make sure touch gives reasonable diagnostics
+
+if test "$VERBOSE" = yes; then
+  set -x
+  touch --version
+fi
+
+. $srcdir/../envvar-check
+. $srcdir/../lang-default
+PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+
+pwd=`pwd`
+tmp=fail-diag.$$
+trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
+trap '(exit $?); exit' 1 2 13 15
+
+framework_failure=0
+mkdir $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+
+if test $framework_failure = 1; then
+  echo 'failure in testing framework' 1>&2
+  (exit 1); exit
+fi
+
+fail=0
+
+# Before fileutils-4.1, we'd get the following misleading
+# diagnostic instead of `Permission denied'.
+# touch: creating `/': Is a directory
+touch / > out 2>&1 && fail=1
+
+touch /no/such-dir >> out 2>&1 && fail=1
+
+cat > exp <<\EOF
+touch: setting times of `/': Permission denied
+touch: creating `/no/such-dir': No such file or directory
+EOF
+
+cmp out exp || fail=1
+test $fail = 1 && diff out exp 2> /dev/null
+
+(exit $fail); exit