severity 42158 grave
retitle 42158 pax: hard linked files from cpio archives "restored" with zero
size (can cause data loss)
thanks
Hi there--
Feels weird touching on an 8-year-old bug, but i've stumbled into a
simple use case for #42158 which i found while reviewing #466771. I'm
upgrading the severity to grave due to the fact that this can cause
data loss if pax is used to recover from backups and the backups are
overwritten or discarded.
Here's the use case:
[0 [EMAIL PROTECTED] cdtemp.h29208]$ rm -rf paxtest && mkdir paxtest
[0 [EMAIL PROTECTED] cdtemp.h29208]$ echo -n x > paxtest/file0
[0 [EMAIL PROTECTED] cdtemp.h29208]$ ln paxtest/file0 paxtest/file1
[0 [EMAIL PROTECTED] cdtemp.h29208]$ rm -rf z && mkdir z
[0 [EMAIL PROTECTED] cdtemp.h29208]$ find paxtest | cpio -H newc --create | (cd
z && pax -r)
1 block
[0 [EMAIL PROTECTED] cdtemp.h29208]$ ls -la paxtest z/paxtest
paxtest:
total 8
drwxr-xr-x 2 dkg dkg 80 2008-03-25 17:35 .
drwxr-xr-x 7 dkg dkg 200 2008-03-25 17:36 ..
-rw-r--r-- 2 dkg dkg 1 2008-03-25 17:35 file0
-rw-r--r-- 2 dkg dkg 1 2008-03-25 17:35 file1
z/paxtest:
total 0
drwxr-xr-x 2 dkg dkg 80 2008-03-25 17:35 .
drwxr-xr-x 3 dkg dkg 60 2008-03-25 17:36 ..
-rw-r--r-- 2 dkg dkg 0 2008-03-25 17:35 file0
-rw-r--r-- 2 dkg dkg 0 2008-03-25 17:35 file1
[0 [EMAIL PROTECTED] cdtemp.h29208]$
Note that the file becomes zero bytes in length, even though the
symlinks are retained.
Examining the headers generated by cpio shows that the files are being
stored as regular files linked together (same inode number). But the
first file lists zero bytes, while the second file lists 1 byte in
length:
[0 [EMAIL PROTECTED] cdtemp.h29208]$ find paxtest | cpio -H newc --create |
strings
1 block
0707010017AA8D000041ED000003E8000003E80000000247E9703600000000000000000000001200000000000000000000000800000000paxtest
0707010017AAA0000081A4000003E8000003E80000000247E9702500000000000000000000001200000000000000000000000E00000000paxtest/file1
0707010017AAA0000081A4000003E8000003E80000000247E9702500000001000000000000001200000000000000000000000E00000000paxtest/file0
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!
[0 [EMAIL PROTECTED] cdtemp.h29208]$
According to the "New ASCII Format" section of cpio(5), the newc
format (magic number 070701) is allowed to do this with hardlinks:
In this format, hardlinked files are handled by setting the
filesize to zero for each entry except the last one that appears in
the archive.
fwiw, here's the versions of cpio and pax i was using to make this
test:
[0 [EMAIL PROTECTED] cdtemp.h29208]$ dpkg -l pax cpio
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-======-=========-==========================================================
ii cpio 2.9-11 GNU cpio -- a program to manage archives of files
ii pax 1:1.5-16 Portable Archive Interchange
[0 [EMAIL PROTECTED] cdtemp.h29208]$
Thanks for maintaining pax in debian.
Regards,
--dkg
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]