mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #5605] Using end-of-options indicator "--" and blacklisting $SHELL causes Cannot start application #3040
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#3040
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 @rusty-snake on GitHub (Jan 21, 2023).
Original GitHub issue: https://github.com/netblue30/firejail/issues/5605
Description
Blacklisting
$SHELLand using--causesCannot start application.Steps to Reproduce
firejail --quiet --noprofile --blacklist=$SHELL -- echo "*NULL"Expected behavior
See
*NULLActual behavior
Cannot start application: Permission deniedBehavior without a profile
N/A
Additional context
This does not happen with
firejail --quiet --noprofile --blacklist=$SHELL echo "*NULL".Relates to #5599.
Relates to #5598.
Environment
52898f4Checklist
/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)Log
logs
@rusty-snake commented on GitHub (Feb 14, 2023):
Looks like this is intentional.
7ad735deaf (diff-767ac3de885e9c994fed6eb2a0f8234fd8d8611a5f817d2b0a37b50f4101b321)@wentasah commented on GitHub (Feb 14, 2023):
Hmm. Blacklisting a shell is one of the primary use cases for firejail. Not using
--is not an option here, because then, there is no way to pass the jailed program an option with the same name as some firejail option. This can be clearly seen from the the code ofcheck_argfunction.The commit mentioned by @rusty-snake refers to #5196. I don't see how deprecating
--shellrelates to the use of--changed in the referenced commit.@rusty-snake commented on GitHub (Feb 14, 2023):
Correction. Passing an option with the same name as an firejail option is possible. What you can not do is to start a program whose name starts with
--or an untrusted command line.31d0c32be5/src/firejail/main.c (L986-L990)@rusty-snake commented on GitHub (Feb 14, 2023):
Read the comment in line 529:
start the program without using a shell.=> Starting a shell only for
--but not for normal start is intentional.It's a random feature (rather than a bug) that nobody can explain for what it is good.
@wentasah commented on GitHub (Feb 15, 2023):
Yes, you're right. I was too quick reading the code :-)
@rusty-snake commented on GitHub (Feb 24, 2023):
FWIW: sailfishos/sailjail is going to revert this. https://github.com/sailfishos/firejail/pull/17/files#diff-579c2ba1109122d6e4ac5657a8127e06989706c4816601f367a853f4ebf5deab
@tstarling commented on GitHub (Dec 12, 2023):
@netblue30 introduced this behaviour in
7ad735deafwithout explanation. Prior to4b4d752158(the previous day), the shell was always used unless--shell=nonewas given. My theory is that @netblue30 erroneously believed that there was a need to preserve the feature which forwarded the double dash to the shell.The POSIX specification of sh requires that shell options prefixed with
-and+be respected when they appear after-cand before the command string. It also requires that sh implement--as an end-of-options marker. So to safely pass a command string to a POSIX-compliant shell, it is necessary to always add--.Firejail was adding
--to the shell arguments only when--appeared in its input arguments. This was incorrect. It should have always added--.It was reported in #5599 that Fish is not POSIX compliant in that it does not correctly implement
-c --. In my opinion, the bug in Firejail was that it was using the user's shell when it needed a POSIX-compliant shell. Firejail should have used/bin/sh, or indeed, used no shell.In https://github.com/netblue30/firejail/pull/5600#issuecomment-1386044151 , @kmk3 posted a correct analysis of the situation, but came to the conclusion that it's more important to support
fishthan it is to supportsh. I disagree.Assuming that the rationale for
7ad735deafwas to preserve double-dash forwarding, the merge of #5600 has rendered that rationale moot by removing the feature.7ad735deafshould be reverted.I'm here because, per https://phabricator.wikimedia.org/T353194 , we are adding
--to firejail input arguments when the user's shell is/usr/sbin/nologinand $SHELL is unset. That worked prior tofc912c0821(part of the same sequence of commits in June 2022), which removed guess_shell() in favour of using the shell from getpwuid(). I would like that commit to also be reverted. The user's shell in the password database is conventionally set to a non-functional shell for system accounts which do not allow login.