redhotpenguin / perl-Archive-Zip

Archive::Zip as seen at https://metacpan.org/pod/Archive::Zip
Other
15 stars 44 forks source link

extractTree does not work like unzip command line tool for writeless folder permissions #98

Open mrdvt92 opened 1 year ago

mrdvt92 commented 1 year ago

Given a zip file like this where the folder does not have any write permissions inside the zip archive.

$ find writeless/ -ls
464069    0 dr-xr-xr-x   2 - - 40 Nov 30 14:39 writeless/
464070    4 -rw-rw-r--   1 - - 6 Nov 30 14:39 writeless/hello.txt
464071    4 -rw-rw-r--   1 - - 6 Nov 30 14:39 writeless/world.txt

The extractTree method fails to extract the files like unzip command line tool

$ perl /usr/share/doc/perl-Archive-Zip-1.68/examples/unzipAll.pl writeless.zip
IO error: Can't open file .../temp/writeless/hello.txt for write : Permission denied
 at /usr/share/perl5/vendor_perl/Archive/Zip/Member.pm line 566.
        Archive::Zip::Member::extractToFileNamed('Archive::Zip::ZipFileMember=HASH(0x22275b8)', '...') called at /usr/share/perl5/vendor_perl/Archive/Zip/Archive.pm line 1237
        Archive::Zip::Archive::extractTree('Archive::Zip::Archive=HASH(0x1c30a68)') called at /usr/share/doc/perl-Archive-Zip-1.68/examples/unzipAll.pl line 29

To create the test archive.

$ mkdir writeless
$ echo hello > writeless/hello.txt
$ echo world > writeless/world.txt
$ chmod a-w writeless/
$ zip -r writeless.zip writeless/

This is also been reported against https://github.com/jib/archive-extract/issues/12 but I'm not sure if both need to be fixed or just one.