diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-05-02 22:54:32 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-05-06 10:26:50 +0100 |
commit | 0b04ff22edcd7b75f0929f5bede7d814d100e2f1 (patch) | |
tree | 387fabd741a3ac3bbb096ce6375c3bbc8dfcaa0c /tests/cp | |
parent | a03a51c44c78d25e9fab2ffb9bb0a46f22969f4e (diff) | |
download | coreutils-0b04ff22edcd7b75f0929f5bede7d814d100e2f1.tar.xz |
mv,cp: preserve symlink xattrs when copying across file systems
* src/copy.c (copy_internal): Include the copy_attr() call for symlinks.
This should not dereference symlinks, since llistxattr() is used
in attr_copy_file() in libattr, and so should copy all but the filtered
extended attributes. Note we don't just move the copy_attr() call
before the set_owner() call, as that would break capabilities
for non symlinks.
* tests/cp/cp-mv-enotsup-xattr.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes http://bugs.gnu.org/16131
Diffstat (limited to 'tests/cp')
-rwxr-xr-x | tests/cp/cp-mv-enotsup-xattr.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/cp/cp-mv-enotsup-xattr.sh b/tests/cp/cp-mv-enotsup-xattr.sh index f8cdd4551..11809892a 100755 --- a/tests/cp/cp-mv-enotsup-xattr.sh +++ b/tests/cp/cp-mv-enotsup-xattr.sh @@ -106,4 +106,24 @@ mv xattr/a noxattr/ 2>err || fail=1 test -s noxattr/a || fail=1 # destination file must not be empty test -s err && fail=1 # there must be no stderr output +# This should pass and copy xattrs of the symlink +# since the xattrs used here are not in the 'user.' namespace. +# Up to and including coreutils-8.22 xattrs of symlinks +# were not copied across file systems. +ln -s 'foo' xattr/symlink || framework_failure_ +# Note 'user.' namespace is only supported on regular files/dirs +# so use the 'trusted.' namespace here +txattr='trusted.overlay.whiteout' +if setfattr -hn "$txattr" -v y xattr/symlink; then + # Note only root can read the 'trusted.' namespace + if getfattr -h -m- -d xattr/symlink | grep -F "$txattr"; then + mv xattr/symlink noxattr/ || fail=1 + getfattr -h -m- -d noxattr/symlink | grep -F "$txattr" || fail=1 + else + echo "failed to get '$txattr' xattr. skipping symlink check" >&2 + fi +else + echo "failed to set '$txattr' xattr. skipping symlink check" >&2 +fi + Exit $fail |