Skip Menu |

This queue is for tickets about the Archive-Tar CPAN distribution.

Report information
The Basics
Id: 4437
Status: resolved
Priority: 0/
Queue: Archive-Tar

People
Owner: Nobody in particular
Requestors: slaven [...] rezic.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: (no value)



Subject: Missing leading directories in created archive
An archive created by Archive::Tar does not create entries for leading directories. Those archives are handled alright by recent tar programs, but have problems with older BSD tar programs. Here's an example: env PERL5LIB=$HOME/lib/perl perl -MArchive::Tar -e 'Archive::Tar->create_archive("/tmp/test.tar", 0, glob("/house/eserte12/test/*"))' The created archive looks like this: tar tfv /tmp/test.tar tar: Blocksize = 5 records -rw-r--r-- eserte12/nis 0 Nov 20 05:13 2003 a -rw-r--r-- eserte12/nis 0 Nov 20 05:13 2003 b -rw-r--r-- eserte12/nis 0 Nov 20 05:13 2003 c On other systems it would be "house/eserte12/test/a" etc. When extracting such an archive with an old BSD tar, the leading directories will *not* be created, and you get everything in a flat directory. I saw this behavior on NetBSD 1.6 and FreeBSD 4.6, but not on FreeBSD 4.8 and RedHat Linux 8.0. Regards, Slaven
From: "Jos I. Boumans" <kane [...] dwim.org>
Subject: Re: [cpan #4437] Missing leading directories in created archive
Date: Mon, 24 Nov 2003 18:54:22 +0100
To: bug-Archive-Tar [...] rt.cpan.org
RT-Send-Cc:
On 20-nov-03, at 13:00, Guest via RT wrote: Show quoted text
> An archive created by Archive::Tar does not create entries for > leading directories. Those archives are handled alright by recent > tar programs, but have problems with older BSD tar programs.
Although probably true, this is wholly and totally to blame on the older BSD tar programs, as they simply do not follow the tar spec. Instead, they choose to ignore the 'prefix' field in the tar header, or more accurately, are so old they are not aware this field exists... From: http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html "The name and the prefix fields shall produce the pathname of the file. A new pathname shall be formed, if prefix is not an empty string (its first character is not NUL), by concatenating prefix (up to the first NUL character), a slash character, and name; otherwise, name is used alone. In either case, name is terminated at the first NUL character. If prefix begins with a NUL character, it shall be ignored. In this manner, pathnames of at most 256 characters can be supported. If a pathname does not fit in the space provided, pax shall notify the user of the error, and shall not store any part of the file-header or data-on the medium." it's amended with: "The total size of the name and prefix fields have been set to meet the minimum requirements for {PATH_MAX}. If a pathname will fit within the name field, it is recommended that the pathname be stored there without the use of the prefix field. Although the name field is known to be too small to contain {PATH_MAX} characters, the value was not changed in this version of the archive file format to retain backwards-compatibility, and instead the prefix was introduced. Also, because of the earlier version of the format, there is no way to remove the restriction on the linkname field being limited in size to just that of the name field." The solution Archive::Tar implements is a 'rather safe than sorry' solution, which tries to split out dirs from names to avoid having to deal with how paths are exactly built up. Anything going over the 255 byte length that the headers allows for, is put in an extended header (the ././@LongLink entries -- which postdates even the 'prefix' addition). Allowing to be totally compatible with 'older' tars, it would mean that Archive::Tar could not deal with any files longer than a 100 characters (since that's the number of bytes in the header allocated for the 'name' field), which is an even more undesirable solution i think. Below the sig is a program that demonstrates what i mean... Sadly, the only course of action that can be taken here is to upgrade to versions of tar/gtar that adhere to the current format spec. -- Jos Boumans "You know you are never more indignant in life than when you're shopping at a store you feel is beneath you and one of the other customers mistakes you for one of the employees of that store." - Dennis Miller CPANPLUS http://cpanplus.sf.net [kane@coke ~...tmp/leading-dir-bug]$ cat x.pl use Archive::Tar; use Data::Dumper; use strict; my $file = shift; my $glob = shift; Archive::Tar->create_archive($file,0,glob($glob)) or die Archive::Tar->error; my $tar = Archive::Tar->new($file); print Dumper $_ for $tar->get_files; [kane@coke ~...tmp/leading-dir-bug]$ perlc x.pl test.tar "/Users/kane/p4/other/archive-tar-new/tmp/leading-dir-bug/foo/*" $VAR1 = bless( { 'mode' => 33188, 'linkname' => '', 'gid' => 502, 'magic' => 'ustar', 'data' => '', 'name' => 'Users/kane/p4/other/archive-tar-new/tmp/leading-dir-bug/foo/a', 'mtime' => 1069695358, 'size' => 0, 'uid' => 502, 'version' => '00', 'raw' => 'a100644000766000766 0 7760440576 23236 0ustar00kanekane000000000000Users/kane/p4/other/archive-tar-new/tmp/ leading-dir-bug/foo', 'type' => '0', 'uname' => 'kane', 'devmajor' => 0, 'devminor' => 0, 'prefix' => 'Users/kane/p4/other/archive-tar-new/tmp/leading-dir-bug/foo', 'chksum' => 9886, 'gname' => 'kane' }, 'Archive::Tar::File' ); $VAR1 = bless( { 'mode' => 33188, 'linkname' => '', 'gid' => 502, 'magic' => 'ustar', 'data' => '', 'name' => 'Users/kane/p4/other/archive-tar-new/tmp/leading-dir-bug/foo/b', 'mtime' => 1069695358, 'size' => 0, 'uid' => 502, 'version' => '00', 'raw' => 'b100644000766000766 0 7760440576 23237 0ustar00kanekane000000000000Users/kane/p4/other/archive-tar-new/tmp/ leading-dir-bug/foo', 'type' => '0', 'uname' => 'kane', 'devmajor' => 0, 'devminor' => 0, 'prefix' => 'Users/kane/p4/other/archive-tar-new/tmp/leading-dir-bug/foo', 'chksum' => 9887, 'gname' => 'kane' }, 'Archive::Tar::File' ); $VAR1 = bless( { 'mode' => 33188, 'linkname' => '', 'gid' => 502, 'magic' => 'ustar', 'data' => '', 'name' => 'Users/kane/p4/other/archive-tar-new/tmp/leading-dir-bug/foo/c', 'mtime' => 1069695358, 'size' => 0, 'uid' => 502, 'version' => '00', 'raw' => 'c100644000766000766 0 7760440576 23240 0ustar00kanekane000000000000Users/kane/p4/other/archive-tar-new/tmp/ leading-dir-bug/foo', 'type' => '0', 'uname' => 'kane', 'devmajor' => 0, 'devminor' => 0, 'prefix' => 'Users/kane/p4/other/archive-tar-new/tmp/leading-dir-bug/foo', 'chksum' => 9888, 'gname' => 'kane' }, 'Archive::Tar::File' );