mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3434] Default shell is guessed from $SHELL, despite manpage specifying /bin/bash #2160
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#2160
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 @iltep64 on GitHub (May 26, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3434
Bug and expected behavior
Firejail's man page describes the default shell for execution as
/bin/bash.However, if the given command line contains bash-isms(?) such as adding
--infirejail -- ls, and an incompatible shell is currently used and present in$SHELL(e.g. fish), then the command fails.This issue was encountered in the
zoom-firejailAUR package.Steps and Output
The logs are collapsed for brevity.
Unexpected
The external shell environment has
$SHELL=/bin/fishset, unless stated otherwise.Running without any flags
Running with
--noprofileExpected
Direct execution
With
firejail+ a workaround, other than the command line itself, the results of execution are the same.Running with
SHELL=/bin/fishand--shell=noneflagRunning with
SHELL=/bin/fishand--shell=/bin/bashflagRunning with
SHELL=/bin/bash(withSHELL=/bin/fishin the external environment)Environment
firejail-0.9.62-1package./usr/bin/ls, nor has it a profile. Onlybash,fish,ls, andfirejailare used.Checklist
/bin/ls./bin/lsdoes not have a profile.$SHELLandfishreturned nothing.Workarounds
As seen in the last 3 examples, forcing either the
$SHELLenvironment variable or the--shellflag makes it work.Possible causes
This is the relevant line of manpage documentation:
63c44c7743/src/man/firejail.txt (L2274)From a cursory search in the code,
guess_shell()reads the environment here:63c44c7743/src/firejail/main.c (L906)This seems like the reason why
fishis launched, and so it errors out on the--argument separator.EDIT: Fixed markdown to follow bug report template better.
@rusty-snake commented on GitHub (May 27, 2020):
I'd rather ask why does firejail pass the
--to the command.In general I recommend to use bash as login shell many program in the world tend to odd behaviour without it. In addition, non-posix shells such as fish can lead to security issues. If you want an other interactive shell, you can set it in the preferences of you terminal-emulator.
@iltep64 commented on GitHub (May 27, 2020):
IMO this is at least a documentation inconsistency. Do you think updating the manpage to note the guessing behaviour would be an acceptable resolution? Though mandating bash as login shell feels a bit too opinionated. Another possibility would be to avoid guessing from
$SHELLat all, and just check forbashorsh.@rusty-snake commented on GitHub (May 27, 2020):
The manpage should be fixed, sure. But IMHO we shouldn't pass
--to the command we start.@iltep64 commented on GitHub (May 27, 2020):
I looked through the code again, and I think I found the cause of the extra
--.In the argument parser in
main.c, if firejail finds--inargv, it setsarg_doubledash.28c099bdc3/src/firejail/main.c (L2587)Then, in
sandbox.c, when building the arguments for the shell, ifarg_doubledashis set, then after the initial-carg,--is added.35ac39ee55/src/firejail/sandbox.c (L576)The git blame trail for that line of logic goes cold after
1379851360though.EDIT: The POSIX-compliant shells (
dash, zsh, kshtested) all accept the extra--, and it does seem to be part of the POSIX standards. Perhaps the docs should specify that$SHELLshould be POSIX-complaint.Alternatively,
guess_shellcan compare$SHELLto a whitelist of known-good shells, and skip using it if it fails. If the user wants to force a noncompliant shell, the--shell=...option is still available.@rusty-snake commented on GitHub (Jun 4, 2020):
IMHO we should hardcode
/bin/bashand maybe use $SHELL or a list ad fallback.#3448, #2934, #2857
@Thaodan commented on GitHub (Oct 6, 2020):
why do you request explicitly bash? There a systems without bash and unless you depend on bash features that should not be required.
But you could force to use /bin/sh as this is always installed on a POSIX system.
@ryneeverett commented on GitHub (Sep 18, 2021):
This seems particularly problematic in combination with
allow-bin-sh.inc-- any program using this will break ifSHELLisn't set to /bin/bash, /bin/sh, or /bin/dash.For reference, see https://github.com/netblue30/firejail/pull/4098#discussion_r598327311:
If this is going to be the case then firejail should just do an initial check and if
SHELLisn't one of these acceptable values it should just error out.@kmk3 commented on GitHub (Sep 18, 2021):
@ryneeverett commented on Sep 18:
In the case of allow-bin-sh.inc, one way to make custom /bin/sh shells work
would be to add exceptions to ~/.config/firejail/allow-bin-sh.local or
/etc/firejail/allow-bin-sh.local:
To test it:
By the way, is there any distro that ships with another shell by default?
Using a path other than /bin/bash, /bin/dash or /bin/sh?
@ryneeverett commented on GitHub (Sep 18, 2021):
I don't have any problem overriding it but ideally firejail would notify users of this issue so they don't have to track it down by process of elimination.
I'm not aware of a distro that defaults to another SHELL value. I see the relevance of this point towards what shells should go in
allow-bin-sh.incbut I don't think it's an argument for maintaining the status quo. Is there any standard that says SHELL has to be one of these values?Also, even if we accept that supporting stock distributions is the only goal, wouldn't it be simpler to hardcode /bin/sh and replace all instances of
allow-bin-sh.incwithnoblacklist ${PATH}/sh? What's the point of using the SHELL variable if firejail breaks if it's set to anything other than /bin/sh (or the shell /bin/sh is linked to)?@rusty-snake commented on GitHub (Sep 19, 2021):
To say it again,
allow-bin-sh.incis only to make programs using (wrapper-)scripts with a/bin/sh(or/bin/bash) shebang work withdisable-shellwithout the need to maintain thesenoblacklistin all profiles in parallel. Nobody will use anything like fish for (wrapper-)scripts.The whole discussion about which other shells should be included in allow-bin-sh.inc is pointless.
/bin/shto/bin/frogsh,frogshshould be included. That's the only reason to add a shell toallow-bin-shnothing else.allow-shells.incwith exactly the same lines as indisable-shell.incprefixed with ano. See for yourself that this is nonsense and you just don't doinclude disable-shell.inc.private-binfor example.No because if
/bin/shis a symlink to a blacklisted/bin/bashit don't work, therefore we createdallow-bin-sh.incto have one point where to maintenance the necessarynoblacklists for/bin/sh.No
@ryneeverett commented on GitHub (Sep 21, 2021):
Maybe that's the intent of allow-bin-sh.inc but the combined effect of these modules seems to require $SHELL to point to one of these allowed shell paths, regardless of what shell the shebang points to. For a concrete example:
@rusty-snake commented on GitHub (Sep 21, 2021):
@ryneeverett commented on GitHub (Sep 21, 2021):
My point is not that there are an insufficient number of workarounds but that there doesn't seem to be any good reason for overriding the firejail profile to be necessary. Modifying an environment variable from the distribution's default shouldn't be regarded as unconventional and, unless there's a technical reason this needs to be, shouldn't break firejailed applications.
As far as I know there's no objection to hardcoding /bin/sh rather than using $SHELL.
@rusty-snake commented on GitHub (Sep 21, 2021):
Why do we use a shell at all? The most profile have
shell none. We could makeshell nonethe default.@rusty-snake commented on GitHub (Jun 20, 2022):
shell nonebecomes default (#5196).