Skip to content

[Bug]: archive extraction strips special permission bits #818

Description

@stephenlclarke

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions