I really started wondering, and I can't reproduce the behavior you claim to have seen in: BusyBox tar
, star
, libarchive-bsdtar
.
(earlier post)
The question becomes, which tar were you using? The GNU tar in 8.5/8.7 was NEARLY identical, and both of them cause the same error you saw. What wouldn't cause it would be some other tar being used via Debian alternatives /
dpkg-divert
, or happened to be elsewhere on your path.
These are the GNU tar versions shipped with each release, as noted by the ISO listings on the Debian FTP:
debian-8.5.0-amd64-CD-1.list.gz:tar_1.27.1-2+b1_amd64.deb
debian-8.7.0-amd64-CD-1.list.gz:tar_1.27.1-2+deb8u1_amd64.deb
They are extremely similar, containing exactly one more patch for CVE-2016-6321. You can see how Debian treated it here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=842339
The patch deals with handling of /../
path entries in the tarball, and does not affect the handling of arguments.
If we get both debs (In my case I pulled them from the netinst iso), and extract the tar binaries, we can test the behavior:
$ for i in tar_1.27.1-2+b1_amd64 tar_1.27.1-2+deb8u1_amd64 ; do \
ls -la ${i}.deb && \
deb2targz ${i}.deb && \
mkdir -p $i && \
tar -xf ${i}.tar.xz -C $i && \
find $i -name tar -type f -perm /111 -ls \
; done ;
# First Debian package
-r--r--r-- 1 root root 675968 Mar 24 21:31 tar_1.27.1-2+b1_amd64.deb
# Convert it to a tarball for extracting
deb2targz: converting 'tar_1.27.1-2+b1_amd64.deb' ...
deb2targz: skipping section 'debian-binary'
deb2targz: skipping section 'control.tar.gz'
deb2targz: wrote 'tar_1.27.1-2+b1_amd64.tar.xz'
# Tar binary in the first debian package:
108669076 352 -rwxr-xr-x 1 root root 358072 Nov 8 2014 tar_1.27.1-2+b1_amd64/bin/tar
# Second debian package
-r--r--r-- 1 root root 676278 Mar 24 21:32 tar_1.27.1-2+deb8u1_amd64.deb
# Convert it to a tarball for extracting
deb2targz: converting 'tar_1.27.1-2+deb8u1_amd64.deb' ...
deb2targz: skipping section 'debian-binary'
deb2targz: skipping section 'control.tar.gz'
deb2targz: wrote 'tar_1.27.1-2+deb8u1_amd64.tar.xz'
# Tar binary in the first debian package:
543129777 352 -rwxr-xr-x 1 root root 358072 Oct 31 14:37 tar_1.27.1-2+deb8u1_amd64/bin/tar
Now we have both versions extracted, and we can compare them with a variant of your test command:
# Variables to make it clear which one we are using:
$ tar1=./tar_1.27.1-2+b1_amd64/bin/tar
$ tar2=./tar_1.27.1-2+deb8u1_amd64/bin/tar
# First
$ $tar1 --keep-directory-symlink czf /tmp/foo.tar.gz /tmp/foo
./tar_1.27.1-2+b1_amd64/bin/tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
Try './tar_1.27.1-2+b1_amd64/bin/tar --help' or
'./tar_1.27.1-2+b1_amd64/bin/tar --usage' for more information.
# Second
$ $tar2 --keep-directory-symlink czf /tmp/foo.tar.gz /tmp/foo
./tar_1.27.1-2+deb8u1_amd64/bin/tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
Try './tar_1.27.1-2+deb8u1_amd64/bin/tar --help' or
'./tar_1.27.1-2+deb8u1_amd64/bin/tar --usage' for more information.
As for the discussion of other tar implementations, see my answer to a question difference between tar implementions: https://unix.stackexchange.com/a/104172/54009
tar czf
is incorrect, even though most Linuxes would allow it. – SYN Feb 27 '17 at 18:12-czf
systematically if it is so like you say then. - - Please, make your comment an answer so I can accept it. – Léo Léopold Hertz 준영 Feb 27 '17 at 18:14tar czf
. Version shows:tar (GNU tar) 1.27.1
– SYN Feb 27 '17 at 18:18--keep-directory-symlink
? - - I cannot do it in Debian 8.7. – Léo Léopold Hertz 준영 Feb 27 '17 at 18:24czf filename
. Otherwise, you're right, tar fails. – SYN Feb 27 '17 at 18:26