** Bug fixes
+ cp --no-preserve=mode now no longer preserves the original file's
+ permissions but correctly sets mode specified by 0666 & ~umask
+
du no longer emits a "disk-corrupted"-style diagnostic when it detects
a directory cycle that is due to a bind-mounted directory. Instead,
it detects this precise type of cycle, diagnoses it as such and
ls: add --format=FORMAT option that controls how each line is printed.
-cp --no-preserve=X should not attempt to preserve attribute X
- reported by Andreas Schwab
-
copy.c: Address the FIXME-maybe comment in copy_internal.
And once that's done, add an exclusion so that 'cp --link'
no longer incurs the overhead of saving src. dev/ino and dest. filename
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 ();
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)
bool preserve_ownership;
bool preserve_mode;
bool preserve_timestamps;
+ bool explicit_no_preserve_mode;
/* Enabled for mv, and for cp by the --preserve=links option.
If true, attempt to preserve in the destination files any
x->preserve_links = false;
x->preserve_mode = false;
x->preserve_timestamps = false;
+ x->explicit_no_preserve_mode = false;
x->preserve_security_context = false;
x->require_preserve_context = false;
x->preserve_xattr = false;
{
case PRESERVE_MODE:
x->preserve_mode = on_off;
+ x->explicit_no_preserve_mode = !on_off;
break;
case PRESERVE_TIMESTAMPS:
x->preserve_timestamps = on_off;
x->preserve_ownership = on_off;
x->preserve_links = on_off;
+ x->explicit_no_preserve_mode = !on_off;
if (selinux_enabled)
x->preserve_security_context = on_off;
x->preserve_xattr = on_off;
x->preserve_links = false;
x->preserve_mode = false;
x->preserve_timestamps = false;
+ x->explicit_no_preserve_mode = false;
x->reduce_diagnostics=false;
x->data_copy_required = true;
x->require_preserve = false;
x->preserve_links = true;
x->preserve_mode = true;
x->preserve_timestamps = true;
+ x->explicit_no_preserve_mode= false;
x->preserve_security_context = selinux_enabled;
x->reduce_diagnostics = false;
x->data_copy_required = true;
umask 077
cp -a --no-preserve=mode a b
mode=$(ls -l b|cut -b-10)
-test "$mode" = "-rwx------" || fail=1
+test "$mode" = "-rw-------" || fail=1
umask 022
# --------------------------------------
--- /dev/null
+#!/bin/sh
+# ensure that cp's --no-preserve=mode works correctly
+
+# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ cp
+
+rm -f a b c
+umask 0022
+touch a
+touch b
+chmod 600 b
+
+#regular file test
+cp --no-preserve=mode b c
+mode_a=$(ls -l a | gawk '{print $1}')
+mode_c=$(ls -l c | gawk '{print $1}')
+test "$mode_a" = "$mode_c" || fail=1
+
+rm -rf d1 d2 d3
+mkdir d1 d2
+chmod 705 d2
+
+#directory test
+cp --no-preserve=mode -r d2 d3
+mode_d1=$(ls -l d1 | gawk '{print $1}')
+mode_d3=$(ls -l d3 | gawk '{print $1}')
+test "$mode_d1" = "$mode_d3" || fail=1
+
+rm -f a b c
+touch a
+chmod 600 a
+
+#contradicting options test
+cp --no-preserve=mode --preserve=all a b
+mode_a=$(ls -l a | gawk '{print $1}')
+mode_b=$(ls -l b | gawk '{print $1}')
+test "$mode_a" = "$mode_b" || fail=1
+
+Exit $fail
tests/cp/perm.sh \
tests/cp/preserve-2.sh \
tests/cp/preserve-link.sh \
+ tests/cp/preserve-mode.sh \
tests/cp/preserve-slink-time.sh \
tests/cp/proc-short-read.sh \
tests/cp/proc-zero-len.sh \