cpio 2.9 drops directory permissions and ownership
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cpio (Ubuntu) |
Fix Released
|
Low
|
Daniel T Chen |
Bug Description
Binary package hint: cpio
Using cpio 2.9 (in hardy) and the traditional "find . -depth" (e.g., as in the cpio tutorial), directory permissions and ownerships are not set properly when the directory in question is non-empty.
Example: Given the current directory has:
.:
total 0
drwxrws--T 2 daemon backup 72 2008-04-10 00:38 d
./d:
total 0
-rw-r--r-- 1 daemon backup 0 2008-04-10 00:38 hello
Now execute these as root:
mkdir ../tgt
find . -depth | cpio -pmd ../tgt
ls -lR ../tgt
../tgt:
total 0
drwxr-xr-x 2 root root 72 2008-04-10 00:38 d
../tgt/d:
total 0
-rw-r--r-- 1 daemon backup 0 2008-04-10 00:38 hello
The permissions and ownership of directory d are lost. This has not been the case for a decade (e.g., try it with the cpio versions distributed in gutsy, feisty, edgy, dapper, ...).
Similar behaviour if you go through "cpio -o | (cd ../tgt; cpio -idm)". In fact you can verify that the directory flags are stored into the archive file alright; the problem is during extraction.
If you change "find . -depth" to "find .", omitting "-depth", the problem goes away, which is my current workaround. But the original behaviour has been relied upon for decades. It certainly caught me off-guard when I used hardy's cpio (and the traditional find formula) to clone a whole system and then found out the clone broke.
I have also reported it to the gnu cpio mailing list.
The message I sent to the gnu cpio mailing list, and replies:
http:// lists.gnu. org/archive/ html/bug- cpio/2008- 04/msg00000. html