Menu

#113 zip extraction loss execute bit in applications

open
nobody
None
5
2011-03-27
2011-03-27
aONe
No

When extracting a zip with p7zip under Mac OS X, if this zip contain some binary (with execute permission) it will loss that permission so the application wont open if you don't fix it with chmod +x to the binary file.

More info here:

http://trac.kekaosx.com/ticket/13#comment:1

Thanks for the great port ;)

Discussion

  • Igor Pavlov

    Igor Pavlov - 2011-03-28

    I'll add
    kpidPosixAttrib
    to ZIP handler in next version.

    Does pzip calls GetProperty with kpidPosixAttrib?

     
  • aONe

    aONe - 2011-03-28

    Sounds great! I don't know if p7zip uses GetProperty, hope myspace get in touch about this.

    Thanks for your great job Igor.

     
  • Anonymous

    Anonymous - 2011-04-08

    I recently encountered this issue with RAR files, but zip files seemed to work fine ( the executable bit was retained ). However, I think I know what's causing the issue.

    For zip files
    ----------------

    In ZipItem.cpp :
    When the extract callback requests for attributes, the ZipHandler calls this method:
    UInt32 CItem::GetWinAttributes() const

    Now, this method does checks the archive's "made by" field, and if it's unix (value=3), it converts it. In this case, the executable bit is properly set ( verified. )
    However, if this value for an archive wasn't 3, the proper permissions wouldn't be set. Now, if you take a look at the zip file specs ( http://www.pkware.com/documents/casestudies/APPNOTE.TXT ),
    you'll see that OS X has its own value ( "19 - OS/X (Darwin)"). The solution therefore would be to just add the other possible cases to the switch.
    (Note that under snow leopard, archivers created using the native BOMArchiveHelper appear to use the unix value. So, I'm curious which archivers actually use the osx values...)

    If you find a zip file where the executable permission isn't retain, it'd be helpful if you could quickly check the "made by" field using this python script :

    from zipfile import ZipFile
    print ZipFile('foo.zip','r').infolist()[0].create_system

    For rar files
    ----------------

    In RarItem.cpp
    GetWinAttributes simply returns 0 for unix.

    So, the mode is completely lost for rar files.

     
  • aONe

    aONe - 2012-04-16

    I've tried what ether eon said. But in the file I'm testing with the MadeByVersion.HostOS returns 0, so uses kFAT.

    Here the file I'm talking about:

    http://www.blackra1n.com/blackra1n.zip

     

Log in to post a comment.

MongoDB Logo MongoDB