jgm/zip-archive

Permissions are not preserved when unpacking (Linux)

Closed this issue · 2 comments

I downloaded a zip from a server. Modes (in particular, executable bits) are not preserved by zip-archive, but they are by unzip.

I believe that the condition here is incorrect: https://github.com/jgm/zip-archive/blob/master/src/Codec/Archive/Zip.hs#L321

I modified it to read:

when (modes /= 0) $ setFileMode path modes

and decompressed again and permissions are preserved.

I created a zip file with the zip tool with just one executable file inside with the contents:

#!/bin/bash
echo "Hello world!"

The same thing happens: executable bit not preserved by zip-archive as is; everything ok if I apply that change.

For info: I'm on a Linux machine. I have 'Zip 3.0 (July 5th 2008), by Info-ZIP' installed.

jgm commented

Interesting. I was able to reproduce this.

A zip file created with Zip 3.0 on linux, when unzipped with zip-archive (either on linux on on macos), loses the executable permission on files inside.

Oddly, a zip file created with Zip 3.0 on macosx does not have this problem.

jgm commented

We were assuming that the "version made by" field would have 00 for its second component, which isn't always the case. We fix this now with a bitmask.

Thanks for the report!