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.
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
wrappers: allow snaps to install icon theme icons #6767
wrappers: allow snaps to install icon theme icons #6767
Changes from 12 commits
af2ed6d
90bbfa7
e4f2a1e
330ddf4
d0a962b
829d2c2
773f7c9
44b715d
4379d61
9d22252
4328fcf
eef96c1
a001514
6918530
d22b27a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This is not related to icons but I think it would be neat if our parallel installed desktop files had a way to name the instance automatically.
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.
What if
line
has no=
? Then this will panic.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 calling code reads as:
So there will always be an equals sign. I followed the pattern of
rewriteExecLine
here.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.
This is something for a follow-up, CC @mvo5 but I'd like to refactor it so that the caller splits and passes key, value arguments so that the code is both correct and obviously correct.
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.
I think it's pretty hard to guess the correct value just from the word
canonical
, how about we just tell what we mean?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 main problem here is that
filepath.Clean(icon)
may not be something that we will accept. For example, the canonical version of ${SNAP}/foo/../icon.pngis acceptable, but the canonical version of
${SNAP}/../icon.png` is not. We know the value is wrong, but we don't necessarily know what the right value is.I've changed it to
icon path %q is not canonicalized
, which might be easier to search for (e.g. this is the terminology used in the realpath(3) man page).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.
This means that the desktop file can specify
Icon=/path/to/anything
. This seems overly broad; why wouldn't we limit this in some manner?I just checked and it is snapcraft that is doing the munging of the Icon file, not snapd. Eg, I used
Icon=/etc/passwd
, installed the snap and then found it was passed all the way through to /var/lib/snapd/desktop/applications/*.desktop after install. I'll add a review-tools test to make sure it is compliant with this PR, but it seems snapd could do more here. I suspect before the variable expansion if it starts with '/' or if the normalized path is different from the specified path, then failing would be sufficient.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.
I've added some additional checks to
RewriteIconLine
that should cover this:${SNAP}/
filepath.Clean(icon) == icon
The second part catches escapes like
${SNAP}/../other/icon.png
. It won't cover the case of symlinks within the snap that point outside. Presumably that's something the review tools already check for?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.
And just so there's no confusion: errors in this function are logged and cause the
Icon=
line to be omitted from the sanitised desktop file. The change @jdstrand requested will not prevent the install or upgrade of a snap.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.
Thanks! I've adjusted the review-tools to be inline with this PR and so if '/' is in the filename. As such, if the Icon contains '/', it must start with ${SNAP}/ (and end with .png and .svg and the path is the same as the normalized path, but that isn't relevant for what I'm describing), so the existing review-tools check for external symlinks would catch this.
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.
silly question, what happens if the app refers to the icons from code, or is that not expected? or would it in that case use them from the snap, and not the system?
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.
There are (currently) no interfaces that grant a snap access to
/var/lib/snapd/desktop/icons
, so the naming should be irrelevant to the snap. As with the exported desktop files, this is for the benefit of the host system.From within the snap sandbox, the app can access un-munged versions of its own icons in
${SNAP}/meta/gui/icons
.