From bd75118c16d8bca235b61dbb99326c043278a791 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Thu, 18 Aug 2016 13:54:48 +0100 Subject: 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 --- src/cp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cp.c b/src/cp.c index 3b5b6cb72..13dc1ea09 100644 --- a/src/cp.c +++ b/src/cp.c @@ -476,7 +476,8 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, (src_mode & ~S_IRWXUGO) != 0. However, common practice is to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir decide what to do with S_ISUID | S_ISGID | S_ISVTX. */ - mkdir_mode = src_mode & CHMOD_MODE_BITS & ~omitted_permissions; + mkdir_mode = x->explicit_no_preserve_mode ? S_IRWXUGO : src_mode; + mkdir_mode &= CHMOD_MODE_BITS & ~omitted_permissions; if (mkdir (dir, mkdir_mode) != 0) { error (0, errno, _("cannot make directory %s"), -- cgit v1.2.3-70-g09d2