Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Extraction of TGZ file fails when symlinks in the TGZ are present

$
0
0

 First off, I just wanted to say that I've had a great experience using sharpzip in my c# app.

For the most part, all is working well except once in a while I will get a failure when extracting a tar.gz with the error that "Access to the path <PATH.....> denied".  I finally figured out that the tar.gz files it was failing on are ones that have symbolic links in them.

Unfortunately, I don't have control over the generation of the tar.gz files to exclude these, so I am trying to find a way around this on my end doing the extraction.

I don't need these symlinks on extraction so I essentially just want to skip even trying to extract any symlinks in a tar.gz file.

Is there a way to do this or an option in sharpzip to handle symlinks in tar.gz files?  I have not had much luck working around this so any advice or suggestions would be welcomed.

I use something similiar to the extract from a Tar with full control example at https://github.com/icsharpcode/SharpZipLib/wiki/GZip-and-Tar-Samples#wiki-anchorTar, but I have also tried just the "Simple Full extract from a TGZ) as well to be sure I was not doing something wrong in my code.  Both ways fail when symlinks are present in the tar.gz file.


Running c# app (.net 4.0) on a Windows 7 system.

Example contents of a tar.gz file that causes issue below.  If I remove the 4 symlinks manually from the file, extraction works perfectly.

[system1] → tar ztfv network-scripts.tar.gz
drwxr-xr-x root/root         0 2013-03-17 10:55:19 network-scripts/
-rwxr-xr-x root/root      3325 2009-07-04 03:10:48 network-scripts/ifup-wireless
lrwxrwxrwx root/root         0 2012-01-23 18:25:48 network-scripts/ifdown-isdn -> ifdown-ippp
-rw-r--r-- root/root       119 2012-01-23 18:20:33 network-scripts/ifcfg-eth2
-rwxr-xr-x root/root      5433 2009-07-04 03:10:48 network-scripts/init.ipv6-global
-rwxr-xr-x root/root      1707 2009-07-04 03:10:48 network-scripts/ifup-routes
-rwxr-xr-x root/root       859 2009-07-04 03:10:48 network-scripts/ifup-bnep
-rwxr-xr-x root/root       827 2009-07-04 03:10:48 network-scripts/ifdown-ippp
-rw-r--r-- root/root     39833 2009-07-04 03:10:48 network-scripts/network-functions-ipv6
-rw-r--r-- root/root       184 2012-01-23 18:59:16 network-scripts/ifcfg-eth5
-rwxr-xr-x root/root      1154 2009-07-04 03:10:48 network-scripts/net.hotplug
-rwxr-xr-x root/root      2369 2009-07-04 03:10:48 network-scripts/ifup-post
-rwxr-xr-x root/root      4473 2009-07-04 03:10:48 network-scripts/ifdown-ipv6
-rwxr-xr-x root/root       625 2009-07-04 03:10:48 network-scripts/ifdown-bnep
-rw-r--r-- root/root       178 2012-01-23 18:59:21 network-scripts/ifcfg-bond1
-rwxr-xr-x root/root       637 2009-07-04 03:10:48 network-scripts/ifdown-routes
lrwxrwxrwx root/root         0 2012-01-23 18:25:48 network-scripts/ifup-isdn -> ifup-ippp
-rwxr-xr-x root/root      4573 2009-07-04 03:10:48 network-scripts/ifdown-eth
-rwxr-xr-x root/root       954 2009-07-04 03:10:48 network-scripts/ifup-plusb
-rwxr-xr-x root/root      2078 2009-07-04 03:10:48 network-scripts/ifup-tunnel
-rwxr-xr-x root/root       823 2009-07-04 03:10:48 network-scripts/ifup-ipx
lrwxrwxrwx root/root         0 2012-01-23 18:25:48 network-scripts/ifup -> ../../../sbin/ifup
-rwxr-xr-x root/root       727 2009-07-04 03:10:48 network-scripts/ifup-plip
-rwxr-xr-x root/root      1074 2009-07-04 03:10:48 network-scripts/ifdown-tunnel
-rwxr-xr-x root/root     10798 2009-07-04 03:10:48 network-scripts/ifup-eth
-rwxr-xr-x root/root      1481 2009-07-04 03:10:48 network-scripts/ifdown-post
-rwxr-xr-x root/root      8088 2009-07-04 03:10:48 network-scripts/ifup-ipsec
-rwxr-xr-x root/root      1675 2009-07-04 03:10:48 network-scripts/ifup-sl
-rw-r--r-- root/root       254 2009-07-04 03:10:48 network-scripts/ifcfg-lo
-rwxr-xr-x root/root     10853 2009-07-04 03:10:48 network-scripts/ifup-ipv6
-rwxr-xr-x root/root       913 2009-07-04 03:10:48 network-scripts/ifdown-sl
-rw-r--r-- root/root       119 2012-01-23 18:20:33 network-scripts/ifcfg-eth0
-rw-r--r-- root/root     10474 2009-07-04 03:10:48 network-scripts/network-functions
-rwxr-xr-x root/root      1593 2009-07-04 03:10:48 network-scripts/ifdown-sit
-rwxr-xr-x root/root      3662 2009-07-04 03:10:48 network-scripts/ifup-sit
-rwxr-xr-x root/root     13427 2009-07-04 03:10:48 network-scripts/ifup-aliases
-rwxr-xr-x root/root     12033 2009-07-04 03:10:48 network-scripts/ifup-ippp
-rw-r--r-- root/root       184 2012-01-23 18:59:16 network-scripts/ifcfg-eth4
-rwxr-xr-x root/root      4298 2009-07-04 03:10:48 network-scripts/ifup-ppp
-rw-r--r-- root/root       119 2012-01-23 18:20:33 network-scripts/ifcfg-eth1
-rwxr-xr-x root/root      1084 2009-07-04 03:10:48 network-scripts/ifdown-ppp
-rwxr-xr-x root/root      2159 2009-07-04 03:10:48 network-scripts/ifdown-ipsec
-rw-r--r-- root/root       119 2012-01-23 18:20:33 network-scripts/ifcfg-eth3
lrwxrwxrwx root/root         0 2012-01-23 18:25:48 network-scripts/ifdown -> ../../../sbin/ifdown


Viewing all articles
Browse latest Browse all 1764

Trending Articles