-
Notifications
You must be signed in to change notification settings - Fork 70
fix: preserve existing mimeapps.list entries when installing web url handler #1286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
crowecawcaw
wants to merge
7
commits into
aws-deadline:mainline
Choose a base branch
from
crowecawcaw:review-fix/web-url-mimeapps
base: mainline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
23a2af0
fix: preserve existing mimeapps.list entries when installing web url …
crowecawcaw 0dc7a86
fix: surface malformed mimeapps.list as DeadlineOperationError
crowecawcaw 76f627f
Merge branch 'mainline' into review-fix/web-url-mimeapps
crowecawcaw dbade12
fix: tolerate duplicate keys/sections in existing mimeapps.list
crowecawcaw 9d18308
Merge remote-tracking branch 'crowecawcaw/review-fix/web-url-mimeapps…
crowecawcaw 58febaa
fix: make mimeapps.list rewrite atomic
crowecawcaw 08ec80f
fix: preserve mimeapps.list permissions in atomic rewrite
crowecawcaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The atomic-write here does not preserve the destination file's permissions.
tempfile.mkstemp()creates the temp file with mode0600(owner read/write only), andos.replace()keeps that mode on the finalmimeapps.list.For the
all_userscase (/usr/share/applications/mimeapps.list, written as root) this is a functional regression: the system-wide file needs to be world-readable so every user's desktop environment can resolve associations, but after this change it becomes root-only (0600) — and it silently drops the permissions on a pre-existing file that was previously e.g.0644.Consider
stat-ing the existing file first (if present) and applying its mode to the temp file beforeos.replace(), or applying a sane default honoring umask (e.g.0644) when the file is new.mkstemp's hardcoded0600is rarely what you want for a shared config file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 08ec80f: the existing file's mode is stat()ed before the rewrite and applied to the temp file via os.chmod() before os.replace(); a newly created mimeapps.list defaults to 0644. Covered by test_linux_install_preserves_mimeapps_permissions and test_linux_install_creates_mimeapps_with_default_permissions.