[issue3394] zipfile.writestr doesn't set external attributes, so files are extracted mode 000 on Unix

Christopher Brannon report at bugs.python.org
Fri Jul 18 08:15:59 CEST 2008


Christopher Brannon <cmbrannon at cox.net> added the comment:

Here is a patch containing code and a unit test.  I set external_attr
to 0600, for the following reason.
When I extract with Infozip, my umask is ignored when setting permissions of
extracted entries.  They have the permissions assigned to them when archived.
tar does respect umask, but it's not pertinent.
The following shell script demonstrates Infozip's behavior:

=====begin=====
#!/bin/sh
mkdir ziptest_dir
echo hello > ziptest_dir/foo.txt
chmod 666 ziptest_dir/foo.txt
zip -r ziptest_file.zip ziptest_dir/
rm -rf ziptest_dir
umask 077
unzip ziptest_file.zip
=====end=====

Setting permissions to 0600 seems like the safest course.

I'm not sure if this patch should be accompanied by some documentation,
since the zipfile docs don't say much about external_attr or permissions.

PS.  My earlier comments about timestamps were incorrect and spurious!

----------
keywords: +patch
Added file: http://bugs.python.org/file10933/writestr_usable_permissions.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3394>
_______________________________________
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: writestr_usable_permissions.diff
URL: <http://mail.python.org/pipermail/python-bugs-list/attachments/20080718/16c898f4/attachment.txt>


More information about the Python-bugs-list mailing list