[Bug]: archive extraction strips special permission bits

Open Beginner friendly
#818 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
swift

Research direction

Start in ArchiveReader.setFileAttributes and inspect the ArchiveReaderTests case named preserveSpecialPermissionBits. Run swift test --disable-automatic-resolution -Xswiftc -warnings-as-errors --filter preserveSpecialPermissionBits. Done means extraction preserves the full 0o7777 POSIX permission field, including sticky and set-ID bits, while excluding unrelated file-type bits.

Written by the indexing model from the issue text.

Description

I have done the following

  • I have searched the existing issues
  • I reproduced the issue against apple/containerization main at 50f77222964ed3d01dcb53f803ea2d511656a9dc

Steps to reproduce

  1. Add an ArchiveReaderTests case that writes a directory entry with mode 01777.

  2. Extract the archive with ArchiveReader.

  3. Read the extracted directory's .posixPermissions.

  4. 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 agree to follow this project's Code of Conduct
Dominant language
Swift
Stars
8.9k
Forks
360
Avg merge
1d 18h
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apple/containerization

All issues in apple/containerization

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.