summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--old/fileutils/ChangeLog6
-rwxr-xr-xtests/touch/fail-diag44
2 files changed, 50 insertions, 0 deletions
diff --git a/old/fileutils/ChangeLog b/old/fileutils/ChangeLog
index f210c74d2..a1aa0eb9e 100644
--- a/old/fileutils/ChangeLog
+++ b/old/fileutils/ChangeLog
@@ -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
index 000000000..f1fd037b6
--- /dev/null
+++ b/tests/touch/fail-diag
@@ -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