[GH-ISSUE #3874] What's are currently the best ways to configure apps to run sandboxed with firejail? (Modified .desktop files can change after updates) #2436

Closed
opened 2026-05-05 09:06:42 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @mYnDstrEAm on GitHub (Jan 6, 2021).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3874

I used to modify applications' start commands by changing .desktop files in /usr/share/applications or sometimes copying it there for a separate version that uses firejail in Debian/KDE. This can also be done by right clicking application icons->Application->changing the Command. I'm sure many users configure apps to use firejail in like this or in similar ways - for example it's also recommended in the InstallGentooWiki

The problem with that is that after package updates the Commands can be overwritten - so theoretically one would need to check every package's .desktop entry in that folder for a change to Exec in the .desktop file after it's been updated if it's firejailed.

What would be more reliable ways to configure apps to always be sandboxed with firejail?

I don't want to run firecfg to sandbox all applications with firejail.

Would moving all .desktop files from /usr/share/applications/ to ~/.local/share/applications and modifying the commands there be a good way? Edit: a complication with this would be that software could still call the binaries in /usr/bin directly (for example web-ext run tries opening a new firefox instance.) Edit 2: related discussion at #3191

Originally created by @mYnDstrEAm on GitHub (Jan 6, 2021). Original GitHub issue: https://github.com/netblue30/firejail/issues/3874 I used to modify applications' start commands by changing .desktop files in /usr/share/applications or sometimes copying it there for a separate version that uses firejail in Debian/KDE. This can also be done by right clicking application icons->Application->changing the Command. I'm sure many users configure apps to use firejail in like this or in similar ways - for example it's also recommended [in the InstallGentooWiki](https://wiki.installgentoo.com/index.php/Firejail#Usage) The problem with that is that after package updates the Commands can be overwritten - so theoretically one would need to check every package's .desktop entry in that folder for a change to Exec in the .desktop file after it's been updated if it's firejailed. What would be more reliable ways to configure apps to always be sandboxed with firejail? I don't want to run firecfg to sandbox all applications with firejail. Would moving all .desktop files from /usr/share/applications/ to ~/.local/share/applications and modifying the commands there be a good way? Edit: a complication with this would be that software could still call the binaries in /usr/bin directly (for example `web-ext run` tries opening a new firefox instance.) Edit 2: related discussion at #3191
gitea-mirror 2026-05-05 09:06:42 -06:00
Author
Owner

@chiraag-nataraj commented on GitHub (Jan 6, 2021):

You can run sudo ln -s /usr/bin/<x> /usr/local/bin/firejail to ensure that the program is always started with firejail (it's basically the manual version of firecfg and you can select the programs that are sandboxed by default).

<!-- gh-comment-id:755785503 --> @chiraag-nataraj commented on GitHub (Jan 6, 2021): You can run `sudo ln -s /usr/bin/<x> /usr/local/bin/firejail` to ensure that the program is always started with firejail (it's basically the manual version of `firecfg` and you can select the programs that are sandboxed by default).
Author
Owner

@kris7t commented on GitHub (Jan 7, 2021):

@chiraag-nataraj Be on the lookout that some .desktop files refer to the binary with its full path, i.e., merely linking the binary in /usr/local/bin won't to the trick. However, If you also copy the .desktop file from /usr/share/applications to /usr/local/share/applications or $HOME/.local/share/applications and modify it appropriately (to invoke the symlinked binary from /usr/local/bin), then the application will run sandboxed both when started from the command line and when started from the application launcher.

<!-- gh-comment-id:755815788 --> @kris7t commented on GitHub (Jan 7, 2021): @chiraag-nataraj Be on the lookout that some .desktop files refer to the binary with its full path, i.e., merely linking the binary in `/usr/local/bin` won't to the trick. However, If you also copy the .desktop file from `/usr/share/applications` to `/usr/local/share/applications` or `$HOME/.local/share/applications` and modify it appropriately (to invoke the symlinked binary from `/usr/local/bin`), then the application will run sandboxed both when started from the command line and when started from the application launcher.
Author
Owner

@chiraag-nataraj commented on GitHub (Jan 7, 2021):

@kris7t You're right. My setup is so drastically divorced from more 'mainstream' setups that I completely forgot that some .desktop files refer to the full path 😜 I mostly run things from the $PATH, so everything's generally quite consistent as long as everything sees the same $PATH variable 😂

<!-- gh-comment-id:755852090 --> @chiraag-nataraj commented on GitHub (Jan 7, 2021): @kris7t You're right. My setup is so drastically divorced from more 'mainstream' setups that I completely forgot that some `.desktop` files refer to the full path :stuck_out_tongue_winking_eye: I mostly run things from the `$PATH`, so everything's generally quite consistent as long as everything sees the same `$PATH` variable :joy:
Author
Owner

@rusty-snake commented on GitHub (Jan 7, 2021):

I don't want to run firecfg to sandbox all applications with firejail.

Options for a selective firecfg: https://github.com/netblue30/firejail/issues/3665#issuecomment-707689049

<!-- gh-comment-id:756018966 --> @rusty-snake commented on GitHub (Jan 7, 2021): > I don't want to run firecfg to sandbox all applications with firejail. Options for a selective firecfg: https://github.com/netblue30/firejail/issues/3665#issuecomment-707689049
Author
Owner

@rusty-snake commented on GitHub (Jan 8, 2021):

Forgot https://github.com/rahiel/firectl.

<!-- gh-comment-id:756658956 --> @rusty-snake commented on GitHub (Jan 8, 2021): Forgot https://github.com/rahiel/firectl.
Author
Owner

@rusty-snake commented on GitHub (Apr 6, 2021):

I'm closing here due to inactivity, please fell free to request to reopen if you have more questions.

<!-- gh-comment-id:814163568 --> @rusty-snake commented on GitHub (Apr 6, 2021): I'm closing here due to inactivity, please fell free to request to reopen if you have more questions.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#2436
No description provided.