Repository navigation
Keep spaces in XDG user dir paths in the sandbox script - #3084
Merged
Merged
Conversation
The loop that looks up the XDG user dirs for "--sandbox" runs eval XDG_DIR="$(xdg-user-dir $DIR)", so the path is parsed again as shell code. If a dir has a space in its name, the word after the space is run as a command and XDG_DIR keeps whatever it held before: - With the pt_BR default Desktop, "Área de trabalho" (Russian "Рабочий стол" and Greek have a space too), it prints "de: not found" and DESKTOP falls back to ~/Desktop, which doesn't exist. Allowing the app to access the Desktop gives it --add-file ~/Desktop:rw instead of the real folder. - A dir later in the loop gets the previous dir's path. With XDG_PICTURES_DIR="$HOME/My Pictures", PICTURES becomes ~/Music, so the prompts ask about ~/Music twice and allowing Pictures gives the app read-write access to ~/Music. The same loop is in the launcher script that replaces the AppImage, so the error is printed every time the sandboxed app starts. The second line, eval $DIR="$XDG_DIR", would split the path the same way once the first one is fixed. xdg-user-dir already prints the full path, so a plain command substitution is enough, and eval "$DIR=\$XDG_DIR" (as 7d957c4 did for _read) assigns the value without parsing it again. Both work in POSIX sh.
Owner
|
@Samueru-sama please review this. NOTE, changes to --sandbox are coming in the dev branch of this repository. See #3070 |
Contributor
|
lgtm |
Contributor
Author
|
Thanks for the review! The dev branch still has the same two lines (modules/install.am lines 931 and 1074), and this fix applies there cleanly. Happy to open the same change against dev if that's easier with #3070. |
Owner
No problem, I will keep dev in sync with main as always. Thanks. |
Owner
done #3085 |
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.
The XDG user dir loop used by
--sandboxrunseval XDG_DIR="$(xdg-user-dir $DIR)", so the path is parsed again as shell code. When a dir's name has a space, the word after the space runs as a command andXDG_DIRkeeps its previous value. The same loop is copied into the launcher script that replaces the AppImage.de: command not foundand asksAllow APP access to "~/Desktop"?.--add-file ~/Desktop:rw, a folder that doesn't exist, so the app never sees the real Desktop.eval: de: not foundevery time the app starts.XDG_PICTURES_DIR="$HOME/My Pictures":PICTURESbecomes~/Music, and the prompts ask about~/Musictwice.~/Music.xdg-user-diralready prints the full path, so a plain command substitution is enough. The second line useseval "$DIR=\$XDG_DIR", as #3076 did for_read. Both loops get the same change, 4 lines in total, and both lines are POSIX sh. Thedevbranch has the same lines, and this applies there too.How I tested it: I extracted AM's sandbox functions and ran them in an Ubuntu 24.04 container (bash 5.2, dash as
/bin/sh). I used auser-dirs.dirswith the pt_BR names, and another withXDG_PICTURES_DIR="$HOME/My Pictures", plus a stand-insasthat prints the--add-file/--rm-filearguments the generated launcher passes. Before the change the launcher passes~/Desktop:rwand~/Music:rw. After it, the launcher passes"~/Área de trabalho":rwand"~/My Pictures":rw, and thenot founderrors are gone. Dirs without spaces give the same arguments as before.bash -nis clean, and shellcheck reports nothing new oninstall.amor the generated script. I did not runregress/test-am-sandbox.shagainst a real aisap/sas install.