[Patches] [ python-Patches-1412872 ] zipfile: use correct system type on unixy systems

SourceForge.net noreply at sourceforge.net
Wed Feb 1 12:00:44 CET 2006


Patches item #1412872, was opened at 2006-01-23 14:48
Message generated for change (Comment added) made by pete_forman
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1412872&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Ronald Oussoren (ronaldoussoren)
Assigned to: Nobody/Anonymous (nobody)
Summary: zipfile: use correct system type on unixy systems

Initial Comment:
This patch updates the contructor of zipfile.ZipInfo to initialize the 
create_system attribute to 3 instead of 0 on systems that are not 
Windows.

Without this patch the unzip command won't honour the file mode that is 
stored in the zip file.

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

Comment By: Pete Forman (pete_forman)
Date: 2006-02-01 11:00

Message:
Logged In: YES 
user_id=315964

I would contend that UNIX file permissions are not
compatible with MS-DOS though it is possible that PKZIP
2.04g might read them and convert them to an approximation.
I would hope that an unzipping program would ignore any file
type code that it did not know how to interpret.  The ZIP
spec explicitly says the the external file attributes are
set to zero in the case where input is from standard input.
I infer from that that an unzipper should at least be able
to extract the bytes of a file.

Rather than argue over fine points of interpretation I think
that we should take the pragmatic view that a ZIP archive is
most likely to be unzipped on the same type of file system
that it was created on.

The file system code is indeed more complicated.  Setting
one type for the archive is limiting.  It ought to be set
for each member.  And yes, it should be file system rather
than OS.

unzip does honor the file mode.  External file attributes
must be interpreted according to 'version made by'.  It does
have options such as '-X restore UID/GID info' but those
control how much metadata is unpacked, not override
incorrect fields.


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

Comment By: Martin v. Löwis (loewis)
Date: 2006-01-31 20:36

Message:
Logged In: YES 
user_id=21627

I think it is more complicated than that. In version 6.2.2,
a value of 19 is assigned to OS/X. There might also be cases
when 10 (Windows NTFS) is the right answer; it appears they
look at the file system rather than the operating system.

HOWEVER, it also says that the value should be 0 if the
external file attributes are compatible with DOS and pkzip
2.04g.

Perhaps it is a bug in unzip that it doesn't honor the file
mode?

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

Comment By: Pete Forman (pete_forman)
Date: 2006-01-26 16:49

Message:
Logged In: YES 
user_id=315964

The merged patch looks good.

One extra comment that I'd made was that if os.name is 
'java' then a further query of 
java.lang.System.getProperty("os.name") might be in order.  
The string returned from that is 'Linux', 'Windows XP' and 
'SunOS' on the platforms I can test.  A quick search turned 
up this page: http://lopica.sourceforge.net/os.html

On that basis I'd propose a rule that if the Java os.name 
starts with 'Windows' or 'OS/2' then use 0; if it starts 
with 'Mac OS' then 7; else 3.  Perhaps someone with 'Mac OS 
X' could pronounce whether it ought to be 3 (UNIX) or 7 
(Macintosh).  Comments from Jython experts welcome as well.

The spec for the ZIP file format is at PKWARE.
http://www.pkware.com/business_and_developers/developer/
popups/appnote.txt

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

Comment By: Ronald Oussoren (ronaldoussoren)
Date: 2006-01-26 10:34

Message:
Logged In: YES 
user_id=580910

I've updated the patch based on a simular patch by Pete Forman (UID: 
pete_forman). This version contains a lookup-table of create_systems based on 
the os.name and also supports some other non-windows systems.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1412872&group_id=5470


More information about the Patches mailing list