FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=13322&edit=1

ID: 13322
Updated by: daniel.oconnor@gmail.com
Reported By: pascal dot vogels at philips dot com
Summary: Extracting of archive containing symlinks fails
-Status: Assigned
+Status: Feedback
Type: Bug
Package: Archive_Tar
Operating System: Windows
Package Version: 1.3.2
PHP Version: 5.2.0
Assigned To: mrook
Roadmap Versions:
New Comment:

-Status: Assigned
+Status: Feedback
Can you do this as a proper patch against svn by any chance?


Previous Comments:
------------------------------------------------------------------------

[2010-04-25 22:30:25] mrook

-Roadmap Versions: 1.3.7
+Roadmap Versions: 1.3.8


------------------------------------------------------------------------

[2010-03-09 10:25:29] mrook

-Roadmap Versions: 1.3.6
+Roadmap Versions: 1.3.7


------------------------------------------------------------------------

[2010-03-09 09:27:37] mrook

-Roadmap Versions: 1.3.4, 1.3.6
+Roadmap Versions: 1.3.6


------------------------------------------------------------------------

[2009-08-11 20:34:08] mrook

-Summary: Extracting of archive containing zero-size
file fails
+Summary: Extracting of archive containing symlinks
fails
-Assigned To:
+Assigned To: mrook


------------------------------------------------------------------------

[2009-01-22 09:43:19] nath

I have come across this problem too.
I'm running IIS7 on Windows Vista with PHP 5.2.5

Although Vista does support symlinks (a.k.a Junctioning) it's
not an easy thing to try and get working and I'm guessing
would result in some problems when trying to TAR things up
again. Instead I've written a little workaround (well more of a
hack actually) to have symlinks on Windows extract. I believe
this is how WinRAR handles the situation.

This code simply looks for the linked file in the archive and
extracts that instead under the name of the link. If the symlink
was originally to something outside of the TAR then it'd be
broken anyway if you're extracting onto Windows and so in
this case it writes a little comment in a file under the name of
the link. This does mean that the two files (original and
symlinked one) are now separate entities and as such it should
be noted that modifying one will not modify the other.

Simply replace line 1533 of Tar.php with the following:
(Because of line wrapping in this comment post, I will number
each new line. You will have to manually remove the false line
breaks.)

1533: if (defined('OS_WINDOWS') && OS_WINDOWS) {
1534: if (($v_dest_file = @fopen($v_header['filename'],
"wb")) == 0) {
1535: $this->_error('Error while opening
{'.$v_header['filename'].'} in write binary mode');
1536: return false;
1537: } else {
1538: $temp = new Archive_Tar($this->_tarname, $this-
_compress_type);
1539: $v_link_file =
substr(substr($v_header['filename'],0,strrpos($v_header['filena
me'],"/")+1),strlen($p_path)+1).$v_header['link'];
1540: $v_content = $temp->extractInString($v_link_file);
1541: unset($temp);
1542: if(!is_null($v_content)) {
1543: fwrite($v_dest_file, $v_content);
1544: } else {
1545: // Symbolic Link is broken or links to something
outside of tar file. For Windows we'll create it as a text file
with a note in it.
1546: fwrite($v_dest_file, "This file represents a UNIX
symbolic link to ".$v_header['link']."\r\nThe linked file was not
found in the archive.");
1547: }
1548: }
1549: @fclose($v_dest_file);
1550: } else if (!@symlink($v_header['link'],
$v_header['filename'])) {

If you think this is worthwhile hopefully the authors may add it
to an official release.

Nath.

P.S. As an improvement it might be worthwhile doing a check
for the existence of the original file and copying it to a file
with the link name before we go hunting through the archive
again. In case we already extracted the linked file.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=13322

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 25, '12 at 1:52p
activeJan 25, '12 at 1:52p
posts1
users1
websitepear.php.net

1 user in discussion

Daniel Oconnor: 1 post

People

Translate

site design / logo © 2022 Grokbase