summaryrefslogtreecommitdiff
path: root/src/copy.c
diff options
context:
space:
mode:
authorOndrej Oprala <ooprala@redhat.com>2012-08-07 16:56:52 +0200
committerJim Meyering <meyering@redhat.com>2012-09-28 12:21:02 +0200
commit24ebca61a3a0f10d6cd2800b188b3c034d1c4755 (patch)
treedfb6ffe8a3e1447432b9310a93f2785d787bcfb8 /src/copy.c
parent64be8b40f457f6480f9e79777d98afce40469786 (diff)
downloadcoreutils-24ebca61a3a0f10d6cd2800b188b3c034d1c4755.tar.xz
cp: fix the --no-preserve=mode option
The --no-preserve=mode option did not do what its name implies: it would mistakenly preserve permission mode bits. * NEWS: Mention the fix. * TODO: Remove an entry. * src/copy.c (copy_reg): Add a condition to properly handle the --no-preserve=mode option for files (copy_internal): Add a condition to properly handle the --no-preserve=mode option for directories. * src/copy.h (struct cp_options): Add a new boolean. * src/cp.c (cp_option_init,decode_preserve_arg): Set the new boolean value according to specified options. * src/install.c (struct cp_options): Initialize the new boolean. * src/mv.c (struct cp_options): Initialize the new boolean. * tests/cp/preserve-mode.sh: Add a new test. * tests/cp/link-preserve.sh (-a --no-preserve=mode): Adjust the expected perms: now, --no-preserve=mode overrides the --preserve=mode that is inherent in -a, as it should. * tests/local.mk: Add the new test to the list.
Diffstat (limited to 'src/copy.c')
-rw-r--r--src/copy.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/copy.c b/src/copy.c
index 2558fea14..16aed036d 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1151,6 +1151,11 @@ preserve_metadata:
if (set_acl (dst_name, dest_desc, x->mode) != 0)
return_val = false;
}
+ else if (x->explicit_no_preserve_mode)
+ {
+ set_acl (dst_name, dest_desc, 0666 & ~cached_umask ());
+ return_val = false;
+ }
else if (omitted_permissions)
{
omitted_permissions &= ~ cached_umask ();
@@ -2570,6 +2575,11 @@ copy_internal (char const *src_name, char const *dst_name,
if (set_acl (dst_name, -1, x->mode) != 0)
return false;
}
+ else if (x->explicit_no_preserve_mode)
+ {
+ if (set_acl (dst_name, -1, 0777 & ~cached_umask ()) != 0)
+ return false;
+ }
else
{
if (omitted_permissions)