diff -r ea677e26dbeb Doc/library/zipfile.rst --- a/Doc/library/zipfile.rst Mon Apr 14 12:24:37 2014 -0400 +++ b/Doc/library/zipfile.rst Mon Apr 14 18:03:42 2014 -0400 @@ -224,6 +224,11 @@ characters (``:``, ``<``, ``>``, ``|``, ``"``, ``?``, and ``*``) replaced by underscore (``_``). + .. note:: + + File permissions are not passed to the extracted file. The extracted + file will use the users umask instead of the source files permissions. + .. method:: ZipFile.extractall([path[, members[, pwd]]]) @@ -239,6 +244,11 @@ that have absolute filenames starting with ``"/"`` or filenames with two dots ``".."``. + .. note: + + File permissions are not passed to the extracted file. The extracted + file will use the users umask instead of the source files permissions. + .. versionchanged:: 2.7.4 The zipfile module attempts to prevent that. See :meth:`extract` note. @@ -326,6 +336,15 @@ member of the given :class:`ZipInfo` instance. By default, the :class:`ZipInfo` constructor sets this member to :const:`ZIP_STORED`. + .. note:: + + To set the permissions of the compressed file the ZipInfo.external_attr + attribute will need to be set before calling ZipFile.writestr. + + example: + + ZipInfo.external_attr = 0777 << 16L # give full access to included file + .. versionchanged:: 2.7 The *compress_type* argument. diff -r ea677e26dbeb Lib/zipfile.py --- a/Lib/zipfile.py Mon Apr 14 12:24:37 2014 -0400 +++ b/Lib/zipfile.py Mon Apr 14 18:03:42 2014 -0400 @@ -1018,6 +1018,8 @@ using its full name. Its file information is extracted as accurately as possible. `member' may be a filename or a ZipInfo object. You can specify a different directory using `path'. + + Ignores target files permissions, uses user umask. """ if not isinstance(member, ZipInfo): member = self.getinfo(member) @@ -1032,6 +1034,8 @@ directory. `path' specifies a different directory to extract to. `members' is optional and must be a subset of the list returned by namelist(). + + Ignores target files permissions, uses user umask. """ if members is None: members = self.namelist() @@ -1042,6 +1046,8 @@ def _extract_member(self, member, targetpath, pwd): """Extract the ZipInfo object 'member' to a physical file on the path targetpath. + + Ignores target files permissions, uses user umask. """ # build the destination pathname, replacing # forward slashes to platform specific separators. @@ -1200,7 +1206,12 @@ def writestr(self, zinfo_or_arcname, bytes, compress_type=None): """Write a file into the archive. The contents is the string 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or - the name of the file in the archive.""" + the name of the file in the archive. + + The compressed file permissions default to 0600 unless + ZipInfo.external_attr is set before Zipfile.writestr is + called. + """ if not isinstance(zinfo_or_arcname, ZipInfo): zinfo = ZipInfo(filename=zinfo_or_arcname, date_time=time.localtime(time.time())[:6])