Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 491546 - app-arch/tar-1.26-r1 - tar called with --xattrs ignores -C
Summary: app-arch/tar-1.26-r1 - tar called with --xattrs ignores -C
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-17 22:24 UTC by Alex Efros
Modified: 2014-08-12 12:11 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Efros 2013-11-17 22:24:16 UTC
Looks like when tar trying to restore xattrs it use path to file relative to current directory, ignoring -C option.

Setup test environment:

~ $ mkdir -p tar-xattr-bug/{src,dst}
~ $ cd tar-xattr-bug/
~/tar-xattr-bug $ touch src/test
~/tar-xattr-bug $ setfattr -n user.key -v val src/test
~/tar-xattr-bug $ getfattr -d src/test 
# file: src/test
user.key="val"

Try to copy from src/ to dst/ with xattrs:

~/tar-xattr-bug $ cd src/
~/tar-xattr-bug/src $ tar --xattrs -cf - ./ | tar -C ../dst/ -xvpf -
./
./test
tar: ./test: Cannot open: File exists
tar: Exiting with failure status due to previous errors
~/tar-xattr-bug/src $ ls -al ../dst/
total 8
drwxr-xr-x 2 powerman powerman 4096 Nov 18 00:07 .
drwxr-xr-x 4 powerman powerman 4096 Nov 18 00:12 ..
~/tar-xattr-bug/src $

Looks like unpacked file ../dst/test was removed by tar because of some internal error.

Try again, using another current directory:

~/tar-xattr-bug/src $ cd ..
~/tar-xattr-bug $ find -type f
./src/test
~/tar-xattr-bug $ tar -C src/ --xattrs -cf - ./ | tar -C dst/ -xvpf -
./
./test
~/tar-xattr-bug $ find -type f
./test
./dst/test
./src/test
~/tar-xattr-bug $ getfattr -d dst/test 
~/tar-xattr-bug $ getfattr -d test 
# file: test
user.key="val"

Now tar created two files - one in dst/ and second in current directory, and xattrs was applied only to second file.

And again, with subdirectory:

~/tar-xattr-bug $ mkdir src/subdir
~/tar-xattr-bug $ mv src/test src/subdir/
~/tar-xattr-bug $ rm test dst/test 
~/tar-xattr-bug $ getfattr -d src/subdir/test 
# file: src/subdir/test
user.key="val"

~/tar-xattr-bug $ find -type f
./src/subdir/test
~/tar-xattr-bug $ tar -C src/ --xattrs -cf - ./ | tar -C dst/ -xvpf -
./
./subdir/
./subdir/test
tar: ./subdir/test: Cannot setxattr: No such file or directory
tar: ./subdir/test: Cannot open: No such file or directory
tar: Exiting with failure status due to previous errors
~/tar-xattr-bug $ find -type f
./src/subdir/test
~/tar-xattr-bug $ find -type d
.
./dst
./dst/subdir
./src
./src/subdir

So, looks like tar again removed dst/subdir/test after it failed to set xattrs on non-existing subdir/test in current directory.
Comment 1 Arfrever Frehtes Taifersar Arahesis 2013-12-27 18:16:22 UTC
This bug is fixed in tar >=1.27.