summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-08-18 13:54:48 +0100
committerPádraig Brady <P@draigBrady.com>2016-08-18 13:54:48 +0100
commitbd75118c16d8bca235b61dbb99326c043278a791 (patch)
tree42926fb4f780e2d6816928741317ec349a4f1764 /tests
parent3e71b0657760825d4c3a356df67a59fc6bc57ec6 (diff)
downloadcoreutils-bd75118c16d8bca235b61dbb99326c043278a791.tar.xz
cp: with --parents --no-preserve=mode don't copy dir perms
* src/cp.c (make_dir_parents_private): Use default permissions for created directories when --no-preserve=mode is specified. * tests/cp/cp-parents.sh: Add a test case. * NEWS: Mention the fix. Fixes http://bugs.gnu.org/24251
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cp/cp-parents.sh27
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/cp/cp-parents.sh b/tests/cp/cp-parents.sh
index b0be883dc..3819e3d6c 100755
--- a/tests/cp/cp-parents.sh
+++ b/tests/cp/cp-parents.sh
@@ -1,6 +1,4 @@
#!/bin/sh
-# cp -R --parents dir-specified-with-trailing-slash/ other-dir
-# would get a failed assertion.
# Copyright (C) 2000-2016 Free Software Foundation, Inc.
@@ -25,14 +23,15 @@ working_umask_or_skip_
# Run the setgid check from the just-created directory.
skip_if_setgid_
-mkdir foo bar || framework_failure_
-mkdir -p a/b/c d e g || framework_failure_
-ln -s d/a sym || framework_failure_
-touch f || framework_failure_
-
+{
+ mkdir foo bar
+ mkdir -p a/b/c d e g
+ ln -s d/a sym
+ touch f
+} || framework_failure_
# With 4.0.37 and earlier (back to when?), this would fail
-# with the failed assertion from dirname.c.
+# with the failed assertion from dirname.c due to the trailing slash.
cp -R --parents foo/ bar || fail=1
# Exercise the make_path and re_protect code in cp.c.
@@ -55,4 +54,16 @@ p=$(ls -ld g/sym|cut -b-10); case $p in drwx-w--w-);; *) fail=1;; esac
p=$(ls -ld e/d/a/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
p=$(ls -ld g/sym/b/c|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
+# Before 8.25 cp --parents --no-preserve=mode would copy
+# the mode bits from the source directories
+{
+ mkdir -p np/b &&
+ chmod 0700 np &&
+ touch np/b/file &&
+ chmod 775 np/b/file &&
+ mkdir np_dest
+} || framework_failure_
+cp --parents --no-preserve=mode np/b/file np_dest/ || fail=1
+p=$(ls -ld np_dest/np|cut -b-10); case $p in drwxr-xr-x);; *) fail=1;; esac
+
Exit $fail