Preserve POSIX ACLs when replacing archives - #561
Open
srkyn wants to merge 1 commit into
Open
Conversation
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.
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:
<sys/xattr.h>at configure time;0600until its access policy has been applied;system.posix_acl_accessfrom the open source descriptor when available, with a named-source fallback for directzip_source_begin_write()use;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.testpasses on Linux and fails against the unpatched library.fsetxattr()failure leaves the original archive and ACL unchanged and removes the temporary file.clang-format --dry-run --Werrorandgit diff --checkpass.