mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #5879] How to whitelist (permit user) to a single directory? #3119
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#3119
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 @danielkrajnik on GitHub (Jul 3, 2023).
Original GitHub issue: https://github.com/netblue30/firejail/issues/5879
Whitelisting a single directory causes other directories to be blacklisted. Is there a method that simply whitelists a directory/file without any side effects?
Sorry if this has been asked before, but I couldn't find any answer to that (not sure how would you find it). I realize that there is a template for this type of issues, but it's a really simple question and I would be really grateful for your help.
@ghost commented on GitHub (Jul 3, 2023):
If you're asking if there is a kind of whitelisting without blacklisting other directories the answer is no. That's what whitelisting is all about. Perhaps we can offer more help if you provide an example of what you're trying to achieve exactly.
@danielkrajnik commented on GitHub (Jul 3, 2023):
thunderbird requires access to a directory that stores an .ics file (a calendar). This directory is a symlink in home (
~/notes) to a folder in /mnt (/mnt/notes), which user normally has permissions to access. However, when default firejail thunderbird.profile is applied it doesn't see this directory.I've added thunderbird.local to .config/firejail:
however this doesn't work - you can see notes folder from thunderbird, but access is denied.
If you uncomment the
whitelist /mnt/notesline thunderbird doesn't start at all - I assume that's because whitelist implicitly blacklists everything else?Is there another way to give access to that folder/file? A global override?
Thank you for not closing this issuing straight away by the way, I imagine that this same question must be asked all the time and it's probably answered somewhere in the documentation already.
@ghost commented on GitHub (Jul 3, 2023):
No problem. This isn't all that straightforward if one isn't yet very familiar with the Firejail profiles and the rather large set of options. The reason why your whitelisting isn't working can be found if you follow the include logic. In this case our thunderbird.profile includes firefox-common.profile, which has the option
disable-mnt:33c75b8932/etc/profile-a-l/firefox-common.profile (L58)So you need to
ignore disable-mntin your thunderbird.local and then whitelisting ${HOME}/notes and /mnt/notes should work. No need for any noblacklist. That option only makes sense to override a previously blacklisted path, which isn't done anywhere for ~/notes in any of our profiles.@danielkrajnik commented on GitHub (Jul 3, 2023):
Sorry, but this doesn't seem to work:
thunderbird.local:
$ thunderbird
The same happens even if you comment out
whitelist ${HOME}/notes@danielkrajnik commented on GitHub (Jul 3, 2023):
Would it be useful to add "global overrides" to firejail instead of looking for specific profiles that affect each directory? These problems often come up in the middle of your day when you're focused on something else than solving firejail sandbox, which forces you to remove firejail altogether, run application directly and add it to your later todo list, by the time it may be too late and your previous data may be gone.
Wouldn't it make sense to provide simpler overrides instead (e.g.
permit /path/to/directory) ? This feels more like dealing with complexities of selinux labels.@ghost commented on GitHub (Jul 3, 2023):
This works for me with only whitelisting ~/notes. Who owns your ~/notes and what are the file permissions on /mnt/notes/foo.isc?
@danielkrajnik commented on GitHub (Jul 3, 2023):
Hmm... that's strange.
something strange is going on, I've had a vaguely similar error with user permissions 3 days ago when trying to set up librewolf profile in USERRUN directory. firejail may just not like mozilla products (that firefox) or is there any other setting that could affect the way permissions are read?
@rusty-snake commented on GitHub (Jul 4, 2023):
Who owns the notes directory.
Does it work if you comment the whitelist if the symlink.
@ghost commented on GitHub (Jul 4, 2023):
There's nothing in Firejail that dislikes Mozilla software AFAICT. Honestly, I think there's something off with your permissions that's causing this (and the referenced librewolf) issue. If you cannot fix this by using default dir/file permissions, you might want to write a small shell script that temporarily moves this
org-agenda.icsout of /mnt/notes BEFORE starting thunderbird and copies it back afterwards. Placing it in either ${HOME}/.cache/thunderbird, ${HOME}/.thunderbird or ${DOWNLOADS} shouldn't need any additional options in a thunderbird.local as these paths are whitelisted in thunderbird.profile by default.@danielkrajnik commented on GitHub (Jul 4, 2023):
@rusty-snake
both directory and symlink are owned by the user
I've tried commenting out the symlink, but then thunderbird won't start. If you comment out both whitelists it starts but doesn't see that folder.
@danielkrajnik commented on GitHub (Jul 4, 2023):
Sorry, that was just my poor attempt at humour (it just happened that both mozilla products failed around same time, but these are complex programs after all).
I think so too, it may just manifest itself later on as I keep messing with the system. If I ever find out, will report it back here.
@pedrib commented on GitHub (Jul 5, 2023):
Sorry guys don't want to hijack this thread, but I am running some experiments which are very similar to what @danielkrajnik is attempting to do.
disable-mntin my globals/mntUsing
--ignore=disable-mnton the command line works... but addingignore disable-mntto the profile doesn't. Is this expected behaviour?@ghost commented on GitHub (Jul 5, 2023):
@pedrib
No, expected behaviour is that an option works both from command line and from inside a profile. If you have disable-mnt in
globals.localyou need to place an override for itBEFOREthat file is included. Placing it in afoo.localoverride file should automatically take care of this as those get included first, before globals.local. I've been using such a setup for quite a long time myself and it always worked/never broke. Please open a separate issue with code examples of what is and isn't working as expected.@danielkrajnik commented on GitHub (Jul 9, 2023):
This is really frustrating, noblacklist option does absolutely nothing. Programs randomly complain about permissions and there is nothing you can do to configure firejail to allow access to directories.
This is overly complicated and impossible to debug.
@rusty-snake commented on GitHub (Jul 10, 2023):
Simply start with the way it is not accessible. EACCES directs to blacklist options, while ENOENT directs to whitelist options.
@danielkrajnik commented on GitHub (Jul 10, 2023):
Thanks, that's really helpful. Yes, I think the error is ENOENT - but iwhitelisting this directory stil doesn't work
Adding neither whitelist nor noblacklist options doesn't work:
firejail --noblacklist=/home/user/exact/path/to/file/location --whitelist=/home/user/exact/path/to/file/location libreoffice
This results in the same error (but now it doesn't see desktop themes)
@danielkrajnik commented on GitHub (Jul 17, 2023):
Solved:
This is exactly what glitsj16 mentioned in his second comment. I kept messing it up with other unnecessary options there that caused thunderbird to not start at all.
Extra comments:
For me solving this required familiarizing myself for a few days with firejail manual, watching half the channel, meltdown, switch to flatpak, realizing that wine bottles (which are based on flatpak) won't work with wine, returning to firejail and getting a good grasp of the linux system overall (that takes years). The most important moment for me (besides being told about the
ignore disable-mntoption) was finding out that you can inspect your sandbox VERY QUICKLY by going into shell with its current profile by runningfirejail --profile=thunderbirdfor thunderbird in this instance. This made a huge difference in iterating and finding out which options are working and which don't. It is for obvious reasons much quicker than running thunderbird or any other application itself. Nothing beats the terminal when it comes to startup speed.One thing, which would have made this process a lot easier I think for anyone without having to put so much effort in learning firejail is showing clearly which profile causes any certain directory to be blacklisted/read-only/temporary (for example in the output of
firejail --debugcommand or in firetools).Sorry for the misleading title in this issue. I was really confused about firejail's mechanisms at the beginning. Thank you for your patience.