Core: grant user write permissions when copying user_path templates - #6386
Open
ZariTen wants to merge 1 commit into
Open
Core: grant user write permissions when copying user_path templates#6386ZariTen wants to merge 1 commit into
ZariTen wants to merge 1 commit into
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.
What is this fixing or adding?
When Archipelago is run from a read-only install path (such as the Nix store
/nix/store), Python'sshutil.copytree()preserves the source folder's read-only (0555) mode viacopystat().As a result, bootstrapped user directories copied into
XDG_DATA_HOME/home_path()(like~/.local/share/Archipelago/Players,data/sprites, anddata/lua) inherit read-only permissions (dr-xr-xr-x), causingPermissionErrorwhen users attempt to create, edit, or save player.yamlfiles.This PR adds a helper function
_make_writable()insideUtils.user_path()that appliesstat.S_IWUSR(u+w) to newly copied directories and files, guaranteeing that the user retains write permissions regardless of source mount permissions.How was this tested?
nix-shellenvironment by creating a dummy read-only (0555) template directory and mockingos.accesswrite permission checks.Utils.user_path("Players")successfully copies the directory and applies user write permissions, resulting in standarddrwxr-xr-x(0755) access.If this makes graphical changes, please attach screenshots.
N/A