bug-cpio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-cpio] directory permissions and ownership lost in 2.9


From: Albert Y. C. Lai
Subject: [Bug-cpio] directory permissions and ownership lost in 2.9
Date: Thu, 10 Apr 2008 01:18:28 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080227 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

Using cpio 2.9 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.

I have tried both cpio 2.9 distributed by Ubuntu 8.04 beta and the tarball from http://www.gnu.org/software/cpio/ .


Example 1: 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


Example 2: Given the current directory has:

.:
total 0
drwxr-xr-x 2 trebla trebla 72 2008-04-10 00:39 d

./d:
total 0
-rw-r--r-- 1 trebla trebla 0 2008-04-10 00:39 hello

Now execute these as user trebla:

umask 077
mkdir ../tgt
find . -depth | cpio -pmd ../tgt
ls -lR ../tgt

../tgt:
total 0
drwx------ 2 trebla trebla 72 2008-04-10 00:40 d

../tgt/d:
total 0
-rw-r--r-- 1 trebla trebla 0 2008-04-10 00:39 hello


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.

While umask and other process defaults are honoured when directories are not explicitly listed, which is great, when they are explicitly listed with flags (except in a delayed order) the flags are still ignored, which is not great IMO. Yes, I can omit "-depth" and be done, but the original behaviour has been relied upon for decades. It certainly caught me off-guard when I used cpio 2.9 (and the tradition find formula) to clone a whole system and then found out the clone broke.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]