Skip to content

Preserve POSIX ACLs when replacing archives - #561

Open
srkyn wants to merge 1 commit into
nih-at:mainfrom
srkyn:codex/preserve-posix-acl
Open

Preserve POSIX ACLs when replacing archives#561
srkyn wants to merge 1 commit into
nih-at:mainfrom
srkyn:codex/preserve-posix-acl

Conversation

@srkyn

@srkyn srkyn commented Aug 15, 2026

Copy link
Copy Markdown

On Linux, rewriting an existing archive creates a sibling temporary file, restores the original mode bits, and then renames the temporary file over the archive. This loses an extended POSIX access ACL because the ACL belongs to the replaced inode.

Mode bits are not always an equivalent fallback for an extended ACL. The group-class bits represent the ACL mask, so dropping the ACL can give the archive's owning group permissions that previously applied only to a named user or group.

This change:

  • detects <sys/xattr.h> at configure time;
  • creates an existing file's replacement as 0600 until its access policy has been applied;
  • copies system.posix_acl_access from the open source descriptor when available, with a named-source fallback for direct zip_source_begin_write() use;
  • restores the original projected mode and fails before rename if either ACL copying or mode restoration fails; and
  • leaves platforms without the Linux xattr interface on their existing path.

The regression creates an archive with a named-user ACL whose owning-group entry is empty while its mask is read/write. It verifies byte-for-byte ACL preservation through both an ordinary archive update and a direct named-source replacement.

Validation:

  • acl-preserve.test passes on Linux and fails against the unpatched library.
  • The complete regression suite has the same two AES-backend failures as the baseline build; the new test passes.
  • A forced fsetxattr() failure leaves the original archive and ACL unchanged and removes the temporary file.
  • A fresh Clang ASan/UBSan build passes the expanded ACL regression.
  • clang-format --dry-run --Werror and git diff --check pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant