mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #5505] Empty mkdir's should be cleaned up #3020
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#3020
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hirak99 on GitHub (Dec 4, 2022).
Original GitHub issue: https://github.com/netblue30/firejail/issues/5505
Description
Firejail has a directive to create empty directories for whitelisting, so that if the sandboxed program creates files in those directory then they are maintained.
These empty directories, created by firejail, are left even if the sandboxed program actually would not create them. This causes a lot of empty directories to be created; e.g. the steam profile makes it for every possible game that may be in the default firejail profile whether you own the game or not.
Steps to Reproduce
Steps to reproduce the behavior
firejail steam.config/RogueLegacy,.klei,.killingfloorto name a few. For a full list, see/etc/firejail/steam.profileExpected behavior
Firejail should mimic the behavior of the sandboxed application running without it; i.e. not leave a directory if it wasn't actually used by the sandboxed program.
Firejail should check if a directory it made was not used (i.e. is empty), and if so, clean it up. This errs on the side of deleting empty dirs created by the sandboxed program, but arguably that's better than leaving many empty directories silently that the user may not have ever intended for.
Actual behavior
Firejail created a bunch of directories when I sandboxed steam.
Behavior without a profile
The bug is about
mkdirdirective, and as long as it is used - with or without a profile, it would behave the same.However, the issue of leaving random directories that the user may be unaware is a problem of the firejail-profile system (not any specific profile).
Additional context
Any other detail that may help to understand/debug the problem
Environment
Checklist
/usr/bin/vlc) "fixes" it).https://github.com/netblue30/firejail/issues/1139)browser-allow-drm yes/browser-disable-u2f noinfirejail.configto allow DRM/U2F in browsers.--profile=PROFILENAMEto set the right profile. (Only relevant for AppImages)@ghost commented on GitHub (Dec 4, 2022):
Personally I can sympathise with your views on
mkdir(andmkfilefor that matter). I try my best to keep a reasonably clean filesystem and it sure isn't nice to have empty dirs/files being created when using Firejail.That being said, using
ignore mkdirandignore mkfilein either asteam.localoverride or even inglobals.localachieves what you want without touching the code. Whether or not this should be thedefaultFirejail behaviour is something to consider. But I haven't taken the time yet to check how much work it would take to implement such a change.@hirak99 commented on GitHub (Dec 4, 2022):
Yeah, that's a good workaround. But I wouldn't know when new directories are added to a profile after I update firejail, and can still end up with clutter over time.
I know it's not an easy decision (given that even removing the empty directories without checking if they were created by the app isn't exactly ideal).
[That said I kinda prefer to have them deleted if empty. To me it seems like an improvement over the current behavior creating and leaving them, but there are other complexities to consider.]
Thanks for considering this request. Looks like this doesn't have a high priority - I am not blocked since I'm gonna be selective on usage, and no one else appears to have asked for this. I'll leave it to you if you wanna close or deprioritize it.
@kmk3 commented on GitHub (Dec 5, 2022):
@hirak99 commented on Dec 4:
Indeed, not sure if defaulting to removing all directories, including those
created by the program would be desirable.
Maybe there could be a
remove-empty-mkdirsoption that only considersdirectories in the given
mkdircommands. With a separate command, the userwould have to explicitly opt-in to deleting the empty directories (which seems
to me like less surprising behavior).
This could then be added to globals.local to apply this behavior to every
profile.
@kmk3 commented on GitHub (Dec 5, 2022):
For now, here are some workarounds:
Delete every empty directory in the home directory:
Search and delete only in the most common locations:
clean-empty-dirs:
For the worst offenders, there could be a
$PATH-based override to run thescript after the given program. Example:
~/bin/steam:
@kmk3 commented on GitHub (Dec 5, 2022):
Long-term this seems like something that could maybe be better served by
supporting post-exec hooks on firejail.
That is, given an entry like
post-hook ${HOME}/bar.shin foo.profile,register bar.sh as an exit trap before running foo or something (not sure if it
would work this way).