Repository navigation
Keep an existing file's mode when a local transaction commits - #2326
Merged
Merged
Conversation
Member
|
Isn't it expected that a newly written file's mode would not depend on whatever file was there before? |
Contributor
Author
|
For a fresh path, sure, and that case still gets the umask default. The thing is, a normal So whether a file stays private depends on whether it was written inside a transaction, and that bites most for configs and credentials. This is the same kind of parity |
Contributor
Author
|
gentle ping |
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.
LocalFileOpener.commitfinishes every write made insidefs.transaction(or withautocommit=False) by moving atempfile.mkstemp()file over the target and then chmod-ing it to0o666 & ~umask. The move replaces the inode, so whatever mode the file had before is gone: a config or credentials file kept at0o600comes out of the transaction as0o644, readable by every other user on the host, while a plainopen(path, "wb")truncates in place and keeps0o600.Read the existing file's permission bits before the move and put them back afterwards; the umask default now only applies when there was no file, which is what
test_same_permissions_with_and_without_transactionchecks for new files. Added a regression test intest_local.pythat fails without the change; pre-commit and the full suite pass locally.