bug-gnu-utils
[Top][All Lists]
Advanced

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

Soft links bug (feature?)


From: Ted Grzesik
Subject: Soft links bug (feature?)
Date: Thu, 15 May 2003 11:47:06 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02

Problem:  GNU tar overwrites soft links when extracting to an existing directory structure.


Here is a simple example:
mkdir -p a/b/c
touch a/b/c/xyz.txt
mkdir d
ln -s ../a/b d/e

This gives the following structure:
address@hidden test]$ find a d | xargs ls -ld
drwxrwxr-x    3 tedg     tedg         4096 May 15 11:32 a
drwxrwxr-x    3 tedg     tedg         4096 May 15 11:32 a/b
drwxrwxr-x    2 tedg     tedg         4096 May 15 11:32 a/b/c
-rw-rw-r--    1 tedg     tedg            0 May 15 11:32 a/b/c/xyz.txt
drwxrwxr-x    2 tedg     tedg         4096 May 15 11:33 d
lrwxrwxrwx    1 tedg     tedg            6 May 15 11:33 d/e -> ../a/b

Now we create a tarball of the d tree
tar chf foo.bar d

The tarball looks like this:
address@hidden test]$ tar tf foo.tar
d/
d/e/
d/e/c/
d/e/c/xyz.txt

Now extract the tarball back into the directory:
address@hidden test]$ tar xvf foo.tar
drwxrwxr-x tedg/tedg         0 2003-05-15 11:33:53 d/
drwxrwxr-x tedg/tedg         0 2003-05-15 11:32:46 d/e/
drwxrwxr-x tedg/tedg         0 2003-05-15 11:32:54 d/e/c/
-rw-rw-r-- tedg/tedg         0 2003-05-15 11:32:54 d/e/c/xyz.txt

Looking at the directory structure, we see that the 'e' softlink was deleted and a directory 'e' was created:
address@hidden test]$ find a d | xargs ls -ld
drwxrwxr-x    3 tedg     tedg         4096 May 15 11:32 a
drwxrwxr-x    3 tedg     tedg         4096 May 15 11:32 a/b
drwxrwxr-x    2 tedg     tedg         4096 May 15 11:32 a/b/c
-rw-rw-r--    1 tedg     tedg            0 May 15 11:32 a/b/c/xyz.txt
drwxrwxr-x    3 tedg     tedg         4096 May 15 11:57 d
drwxrwxr-x    3 tedg     tedg         4096 May 15 11:32 d/e
drwxrwxr-x    2 tedg     tedg         4096 May 15 11:32 d/e/c
-rw-rw-r--    1 tedg     tedg            0 May 15 11:32 d/e/c/xyz.txt


The -h option on extraction does not solve this problem. It would appear that some extra option is needed or -h on extract needs to support the ability to preserve soft links. The reason we uncovered this problem is that we migrated our webserver from Solaris to Linux. Our update scripts make extensive use of tar in a heavily soft-linked directory hierarchy. On Solaris, soft links are not destroyed.  We are faced with a situation on Linux with no obvious workaround, other than to change our directory structure or the way we package our files.

Thanks,
Ted Grzesik


-- 
Ted Grzesik
address@hidden                                   http://roostme.com
"The things you own end up owning you."
                  -- Tyler Durden (Brad Pitt) in the movie "Fight Club"

reply via email to

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