Re: tar fun
On Fri, Jun 17, 2005 at 11:32:49AM +0200, nodata wrote:
> I have a gzipped tar archive in /tmp/test/
>
> $ tar ztvf file.tgz | head -1
> dr-xr-xr-x root/sys 0 2004-04-19 15:15:15 ./
>
> I'm not running as root. I run an extract:
>
> $ tar zxvf file.tgz
> ./
> somedir/
> tar: somedir: Cannot mkdir: Permission denied
> somedir/somedir/
> tar: somedir/somedir: Cannot mkdir: No such file or directory
>
> The permissions on /tmp/test/ are being changed by the tar file, meaning I
> can't extract the files.
Are you sure you initially have write permission in /tmp/test?
I don't seem to be able to able to reproduce your problem. With the
following test tarball
$ tar ztvf test.tgz
dr-xr-xr-x root/sys 0 2005-06-18 12:25:55 ./
dr-xr-xr-x root/sys 0 2005-06-18 12:30:34 ./somedir/
dr-xr-xr-x root/sys 0 2005-06-18 12:20:25 ./somedir/somedir/
-rw-r--r-- root/sys 0 2005-06-18 12:30:34 ./somedir/somefile
I don't have any problems unpacking it in a directory /tmp/test owned
by me, with initial permissions 0755:
$ tar zxvf test.tgz
./
./somedir/
./somedir/somedir/
./somedir/somefile
What do you get running "strace -e trace=file tar xzvf test.tgz"?
Which version of tar, which kernel, what active umask, initial
permissions/ownership of /tmp/test?
The relevant section of my trace looks as follows
(...)
mkdir(".", 0755) = -1 EEXIST (File exists)
unlink(".") = -1 EISDIR (Is a directory)
mkdir("./somedir", 0755) = 0
mkdir("./somedir/somedir", 0755) = 0
utime("./somedir/somedir", [2005/06/18-13:15:58, 2005/06/18-12:20:25]) = 0
stat64("./somedir/somedir", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
chmod("./somedir/somedir", 040555) = 0
open("./somedir/somefile", O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0644) = 5
utime("./somedir/somefile", [2005/06/18-13:15:58, 2005/06/18-12:30:34]) = 0
utime("./somedir", [2005/06/18-13:15:58, 2005/06/18-12:30:34]) = 0
stat64("./somedir", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
chmod("./somedir", 040555) = 0
which is exactly how things need to be done -- i.e. the permissions
of the directories are set _after_ all actions inside the respective
directory have been completed.
(I do get a similar problem (not exactly yours, though) with a umask of
0222. In that case, tar will fail on trying to create ./somedir/somedir,
because ./somedir will have been created 0555. But that's what you
would expect...)
Almut
Reply to:
- References:
- tar fun
- From: "nodata" <debian@nodata.co.uk>