mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #6358] docs: manpage should explain precedence of CLI options vs profile settings #3249
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#3249
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 @smheidrich on GitHub (May 26, 2024).
Original GitHub issue: https://github.com/netblue30/firejail/issues/6358
Is your feature request related to a problem? Please describe.
As far as I can tell, settings in a profile always take precedence over settings provided via CLI arguments. Is that right? And as far as I can tell, this isn't documented anywhere in the manpage. Even if I'm wrong, the inverse statement isn't documented in the manpage either (again: AFAICT).
Describe the solution you'd like
The precedence of profiles vs CLI options should be explained in the manpage. Probably in the section at the beginning, either just before or just after the profile discovery algorithm is explained.
Describe alternatives you've considered
None.
Additional context
None.
Relates to:
@rusty-snake commented on GitHub (May 26, 2024):
Firejails options work by staring with a minimal sandbox and then adding stuff like mounts, seccomp filters, process attributes, …. The most options do not have an inverse, hence there is no precedence, either they are present somewhere or nowhere.
There is only a small number of options that have any kind of inverse or an single value option (most are flags or collections):
ignorenoblacklist/blacklistnowhitelist/whitelistprivate/private /foo/barprivate-cwdprotocolcaps*dbus-{user,system}hostnamejoin-or-startnameoomThe override behaviour of each of them has to be documented separately cause they do not follow any global logic. Secondly the usage of
--profileinfluences the cli vs. profile semantic.Documenting override behaviour is not limited to cli vs. profile. Also inside profiles (and include chains) it is non-intuitive. Given the following profile, how will
${DOCUMENTS}end up?a) blacklisted (ro/rw does not matter)
b) not blacklisted and read-only
c) not blacklisted and read-write [right answer]
@ghost commented on GitHub (May 26, 2024):
Not what I'm seeing:
Observations: default.profile contains
include disable-common.incand CLI can and does override that when desired...Do you have a reproducers for your assumed behaviour?
I do agree this might need extra clarity in documentation, cfr. @rusty-snake's remarks.
@smheidrich commented on GitHub (May 26, 2024):
Thanks for the replies!
@rusty-snake
So what happens for collections without an inverse like e.g.
--protocol? Is the end result just the union of values given at each point where it was specified? If at least these collections follow a simple logic like that, that's something that could be explained in the manpage. And likewise for flags without an inverse ("if it's there once, it applies").There is probably a way to say that in the manpage, too. Maybe something like:
@glitsj16 I arrived at that conclusion because I wasn't able to un-blacklist
nc(blacklisted indisable-common.inc) by doing--noblacklist=/usr/bin/nc(plus--noblacklistfor each of that symlink's targets, recursively). I similarly wasn't able to disallow UNIX domain socket connections via--protocol=inet, becausedefault.profilealready containsprotocol unix,inet,inet6. In each case, commenting out those lines in the profiles resolved it.But given @rusty-snake's comment, it seems it's much more complicated than I thought.
I'll write a PR with a draft of what I think might be an OK explanation, then we can refine it from there.
@smheidrich commented on GitHub (May 26, 2024):
Sorry, I only now saw that at least for
--protocol, the behavior is already specified in the manpage:And searching for
accumulatein the manpage, I see a lot of other options have similar sentences. In that case, disregard what I wrote about collections - that is actually fine as-is.Then maybe just 1 sentence to explain the precedence for multiple or conflicting options is explained in the option's own docs, done.
@ghost commented on GitHub (May 26, 2024):
I can see the confusion.
For the
nccase, it's important to note that disable-common.inc refers to it asblacklist ${PATH}/nc, not /usr/bin/nc. Once you keep that in mind things work fine on CLI:$ firejail --ignore=quiet --ignore='blacklist ${PATH}/nc' nc -h
$ firejail --ignore=quiet --noblacklist='${PATH}/nc' nc -h
For overriding protocol you need (1) a new protocol option AND (2) stop that from being overriden by the profile via a additional
--ignore=protocol.HTH
@rusty-snake commented on GitHub (May 26, 2024):
protocolis crazy, seee25596bfb7/src/firejail/profile.c (L1959-L1973)caps*andseccompvs.seccomp syscallmight be too a bit complicated.For the most collections it will be the union. But be careful what a collection is.
Think of
List[Box(Object()), Box(Object()), Box(Object())]vs.Box(List[Object(), Object(), Object()]). I.e. internal representation != external representation.Every bit of clarity helps. Even if only the simple case are covered first.
That works. In general and for all options.
protocolhas a second way, see above.@smheidrich commented on GitHub (May 26, 2024):
Thanks for the replies again!
@glitsj16 That makes sense. And I just saw that
--noblacklist='${PATH}/nc'works as well, so maybe the--noblacklistexample in the manpage (which uses a hardcodedncpath and hence doesn't work for the default profile) could be updated to use that. I'll put that in the PR.@rusty-snake I can see why this has been difficult to document 😮 The
+/-/=syntax in that comment doesn't seem to work on the command line though (at least when I tried with--protocol=-unixjust now), so is that something only available in profiles or internally?