fix(archive): preserve special permission bits - #820
Open
stephenlclarke wants to merge 1 commit into
Open
Conversation
Archive extraction masked modes to ordinary rwx bits, stripping sticky, set-user-ID, and set-group-ID permissions. Preserve the full POSIX permission mask and add a sticky-directory regression.
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
Preserve sticky, set-user-ID, and set-group-ID permission bits when extracting archive entries.
Motivation and Context
During testing of my
container-composeplugin, I found and fixed the following issue: archive extraction masked entry permissions with0o777, which discarded all special POSIX permission bits.This regressed in #816. A directory archived with mode
01777was extracted as0777; set-user-ID and set-group-ID bits were affected by the same mask.Fixes #818.
Reproduction
Write a directory archive entry with mode
01777.Extract it with
ArchiveReader.Inspect the extracted directory's POSIX permissions.
Run:
swift test --disable-automatic-resolution -Xswiftc -warnings-as-errors --filter preserveSpecialPermissionBitsOn stock
mainat50f77222964ed3d01dcb53f803ea2d511656a9dc, the regression failed with:Changes
entry.permissions & 0o7777instead ofentry.permissions & 0o777.Validation
Validated on macOS 26.5.1 (25F80), Xcode 26.6 (17F113), and Swift 6.3.3.
0777instead of01777make fmt: passedmake check: passedswift test --enable-code-coverage --disable-automatic-resolution -Xswiftc -warnings-as-errors: 574 tests in 80 suites passedgit diff --check: passed6e32963617b3ed8f4b63432dbcf834f94807342bis cryptographically signed and verifiedCompatibility and Risk
The change preserves the complete POSIX permission field while still excluding file-type bits. It does not change archive formats or public APIs. The behavioural change is limited to restoring permissions that are already present in the archive entry.
Related
fchownordering issue that can clear set-ID bits after this mask is corrected.Release Note Highlight
Archive extraction now preserves sticky, set-user-ID, and set-group-ID permission bits.