Repository navigation
Conversation
Create new POSIX destinations with owner-only permissions before copying data. A denied source attribute listing still raises, and the new file cannot be left group- or world-readable because of the creation umask.
zaniebot
force-pushed
the
fix/shutil-listxattr-permissions
branch
from
October 24, 2026 01:04
e211141 to
58b1acb
Compare
shutil.copy2() continue when listing extended attributes is deniedshutil.copy2()
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 POSIX,
shutil.copy2()can leave a copy of a0700file readable by other users. With a0022umask, the destination typically starts at0644and stays that way ifos.listxattr()raises beforeshutil.copystat()applies the source mode. RunSecure encountered this denial whensetuptoolscopied package metadata duringpip install .(see AndEnd-Collective/RunSecure#12). Other users can also read the destination while the contents are being copied (see python#59305 (comment)).Create new destinations with the source’s owner permission bits plus owner write. This gives
shutil.copystat()a chance to set extended attributes before it applies a read-only source mode. If listing the source attributes is denied,shutil.copy2()still raisesPermissionError(see python#61278 (comment)).