Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly support permissions and symlinks in Zip files (500USD Bounty) #356

Open
lihaoyi opened this issue Feb 14, 2025 · 2 comments
Open
Labels

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Feb 14, 2025


From the maintainer Li Haoyi: I'm putting a 500USD bounty on this issue, payable by bank transfer on a merged PR fixing this.

See https://github.com/orgs/com-lihaoyi/discussions/6 for other bounties and the terms and conditions that bounties operate under


@kiendang hit some issues using os.zip in Mill (com-lihaoyi/mill#4503), some of which are permissions related. It seems that since 2019 the JDK's zip file APIs should be able to support permissions (https://bugs.java.com/bugdatabase/view_bug?bug_id=8213031), so we should make sure OS-Lib takes advantage to preserve permissions when zipping and unzipping files and folders

@kiendang
Copy link
Contributor

kiendang commented Feb 20, 2025

Turned out the problem was all permission related. It worked after executable perm was given to files inside bin and libexec.

Anw can see 2 problems with os.unzip: It does not perserve file permissions and symlinks. After being unzipped from cosmocc.zip (https://cosmo.zip/pub/cosmocc/) with either os.unzip or os.unzip.stream, the files are stripped of permissions (files in bin no longer have executable permission) and all the original symlinks are replaced with copies of the destination files.

@lihaoyi lihaoyi changed the title Properly support permissions in Zip files Properly support permissions and symlinks in Zip files Feb 20, 2025
@lihaoyi lihaoyi changed the title Properly support permissions and symlinks in Zip files Properly support permissions and symlinks in Zip files (500USD Bounty) Feb 20, 2025
@lihaoyi lihaoyi added the bounty label Feb 20, 2025
@sideeffffect
Copy link

https://unix.stackexchange.com/a/509337

Info-Zip 3.0 SUPPORTS preserving files/dirs UNIX permissions and UID/GID ownership data. zip stores it by default but you need to use unzip in an special way to restore them:

  • unzip must be used with the -X flag.
  • unzip must run as root to set the files/dirs UID/GID. If you run it as a normal user then the UID will be always the one of the current user and the GID will be restored ONLY IF the current user belongs to that group.

Note: you can also use unzip with the -K flag to also restore SUID/SGID/Sticky bits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants