Repository navigation
Conversation
The `exploded_zip` extractor gives an entry its mode from the archive when the mode has the owner's execute bit. That is true of nearly every directory, so a directory got its mode as soon as its own entry was extracted. If the mode has no write bit, the files in the directory, which come later in the archive, could not be created, and the action failed with `PermissionError`. `zip -r` and `ditto -c -k` store such a mode for a directory that is `r-xr-xr-x` on disk, and `unzip` extracts the result. Directories now get their mode after everything is extracted, the deepest first.
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D134892160. (Because this pull request was imported automatically, there will not be any future comments.) |
Contributor
|
This pull request has been merged in 1481e28. |
meta-codesync Bot
pushed a commit
to meta/buck2-prelude
that referenced
this pull request
Nov 28, 2026
Summary: `remote_file(type = "exploded_zip")` extracts with `prelude/zip_file/tools/unzip.py`. The script gives an entry its mode from the archive when the mode has the owner's execute bit. That is true of nearly every directory, so a directory gets its mode as soon as its own entry is extracted. If the mode has no write bit, the files in the directory, which come later in the archive, cannot be created, and the action fails with `PermissionError`. This PR records the modes of directories and applies them after everything is extracted, the deepest first. ## Affected version origin/main 2099e8f075. ## Reproduction ``` mkdir -p src/ro && echo x > src/ro/f && chmod 555 src/ro (cd src && zip -qry ../a.zip .) python3 prelude/zip_file/tools/unzip.py --src a.zip --dst out ``` `ditto -c -k src a.zip` on macOS writes the same directory mode. ## Expected `out/ro/f` is extracted and `out/ro` is `r-xr-xr-x`, as with `unzip a.zip -d out`. ## Actual ``` PermissionError: [Errno 13] Permission denied: 'out/ro/f' ``` X-link: meta/buck2#1672 Reviewed By: dtolnay Differential Revision: D134892160 fbshipit-source-id: f6981fd340bd018b3b751ef77f83b567580252ec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
remote_file(type = "exploded_zip")extracts withprelude/zip_file/tools/unzip.py. The script gives an entry its mode from the archive when the mode has the owner's execute bit. That is true of nearly every directory, so a directory gets its mode as soon as its own entry is extracted. If the mode has no write bit, the files in the directory, which come later in the archive, cannot be created, and the action fails withPermissionError.This PR records the modes of directories and applies them after everything is extracted, the deepest first.
Affected version
origin/main 2099e8f.
Reproduction
ditto -c -k src a.zipon macOS writes the same directory mode.Expected
out/ro/fis extracted andout/roisr-xr-xr-x, as withunzip a.zip -d out.Actual
Test plan
prelude/zip_file/tools/tests/test_unzip.py: the newtest_a_file_in_a_read_only_directory_is_extractedfails with thePermissionErrorwithout the change and passes with it. The other four tests pass.zip -ry(Info-ZIP 3.0) and byditto -c -k(macOS): the file is extracted and the directory isr-xr-xr-x.remote_filetarget.