Repository navigation
fix: create sync downloads with the usual file permissions - #810
Merged
Merged
Conversation
An opener passed to open() is called without a mode, so os.open defaulted to 0o777 and downloaded files became executable. Pass 0o666 so the umask yields the same mode as before.
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.
Context
Since #807, a sync download on POSIX creates its temporary file through a directory descriptor with
open(name, 'xb+', opener=functools.partial(os.open, dir_fd=directory_fd)).open()calls an opener without a mode, soos.opendefaults to0o777. The file gets the execute bits (0o777 & ~umask), andos.replacekeeps them, so every downloaded file ends up executable (0o755under umask022, where 2.13.5 produced0o644).Root cause
The opener omitted the file mode. Plain
open()uses0o666; a custom opener has to pass it explicitly.Changes
b2sdk/_internal/sync/action.py: passmode=0o666in the opener, so the umask yields the same permissions as before.test/unit/sync/test_regression_sync_actions.py: addtest_download_file_mode_follows_umask, parametrized over the descriptor-pinned path and the pathname fallback, asserting0o644under umask022.changelog.d/809.fixed.md.Verification
0o755instead of0o644) and green after. Removing the mode argument fails only the pinned case; the pathname fallback was already correct.ruffformat and check pass onb2sdkandtest.Closes #809