mrkkrp / zip

Efficient library for manipulating zip archives
Other
81 stars 27 forks source link

Incorrect permissions on unix platforms #74

Closed qnikst closed 3 years ago

qnikst commented 3 years ago

After commit https://github.com/mrkkrp/zip/commit/72970d9e475c82a78cbda40cb2eb9882849036db permissions when unpack using unzip tool got broken. The reason is that we have fixed OS version and unzip interprets extra attributes as file permissions and by default we write 0 there. For unzip it means 0o000 so no permissions.

I've investigated what zip does in that case, it keeps permissions of the existing file

$ unzip -Zl 1.zip
Archive:  1.zip
Zip file size: 7658 bytes, number of entries: 2
-rwxr-xr-x  3.0 unx      771 tx      338 defN 21-Jan-13 18:50 bench.sh
-rw-------  3.0 unx     7012 bx     7012 stor 21-Jan-13 18:58 foo.zip

For newly created files it uses 0600

# echo 'foo bar' | zip > file.zip
  adding: - (stored 0%)
root@gitlab-registry:~# printf "@ -\n@=filename.txt\n" | zipnote -w file.zip
root@gitlab-registry:~# unzip -Zl file.zip
Archive:  file.zip
Zip file size: 150 bytes, number of entries: 1
prw-------  3.0 unx        8 t-        8 stor 21-Jan-14 17:30 filename.txt
1 file, 8 bytes uncompressed, 8 bytes compressed:  0.0%
mrkkrp commented 3 years ago

Fixed by fc1027caa6792701b240626ce47175ca56ff079f.