I have done the following
Steps to reproduce
-
Add an ArchiveReaderTests case that writes a directory entry with mode 01777.
-
Extract the archive with ArchiveReader.
-
Read the extracted directory's .posixPermissions.
-
Run:
swift test --disable-automatic-resolution -Xswiftc -warnings-as-errors --filter preserveSpecialPermissionBits
On current main, the regression fails with:
Expectation failed: ((perms & permMask) -> 511) == (0o1777 -> 1023)
Special permission bits should be preserved
The cause is ArchiveReader.setFileAttributes, which applies entry.permissions & 0o777. That mask strips the sticky, set-user-ID, and set-group-ID bits.
Current behavior
Archive extraction preserves only ordinary owner/group/other read, write, and execute permissions. A 01777 directory is extracted as 0777; set-user-ID and set-group-ID bits are also discarded.
This is a regression in main after #816 changed the extraction mask from the full mode to 0o777.
Expected behavior
Archive extraction should preserve the full POSIX permission field (0o7777) while continuing to exclude unrelated file-type bits.
Environment
- OS: macOS 26.5.1 (25F80)
- Xcode: 26.6 (17F113)
- Swift: Apple Swift 6.3.3
- Containerization source:
apple/containerization main at 50f77222964ed3d01dcb53f803ea2d511656a9dc
Relevant log output
Test preserveSpecialPermissionBits() recorded an issue at ArchiveReaderTests.swift
Expectation failed: ((perms & permMask) -> 511) == (0o1777 -> 1023)
Special permission bits should be preserved
Test run with 1 test in 1 suite failed with 1 issue.
Code of Conduct
I have done the following
apple/containerizationmainat50f77222964ed3d01dcb53f803ea2d511656a9dcSteps to reproduce
Add an
ArchiveReaderTestscase that writes a directory entry with mode01777.Extract the archive with
ArchiveReader.Read the extracted directory's
.posixPermissions.Run:
swift test --disable-automatic-resolution -Xswiftc -warnings-as-errors --filter preserveSpecialPermissionBitsOn current
main, the regression fails with:The cause is
ArchiveReader.setFileAttributes, which appliesentry.permissions & 0o777. That mask strips the sticky, set-user-ID, and set-group-ID bits.Current behavior
Archive extraction preserves only ordinary owner/group/other read, write, and execute permissions. A
01777directory is extracted as0777; set-user-ID and set-group-ID bits are also discarded.This is a regression in
mainafter #816 changed the extraction mask from the full mode to0o777.Expected behavior
Archive extraction should preserve the full POSIX permission field (
0o7777) while continuing to exclude unrelated file-type bits.Environment
apple/containerizationmainat50f77222964ed3d01dcb53f803ea2d511656a9dcRelevant log output
Code of Conduct