mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3673] bug? --rmenv seems to fire after check for length of environment variables, which makes long variables impossible to remove from firejail side #2312
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#2312
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 @MahouShoujoMivutilde on GitHub (Oct 15, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3673
First of all, thank you for this amazing tool, really enjoyed playing with it recently!
As for issue, there is not much to describe aside from the title, so here is
how to reproduce
steps
Let's set 2 short environment variables:
As expected,
AAAAis removed, andAAAA2is available.But now let's see what happens if we set
AAAAto something really long.I expected same as in the first case to happen, but, as you can see, it just exits with error.
why even do this
My actual use case for it is removing LS_COLORS, which is generated by vivid and about is 8000 characters long.
I know about a workaround with alias as shown here, but LS_COLORS is also used by e.g. lf (which sometimes i launch just by itself, not from interactive shell), and my various scripts (which i usually call from sxhkd).
Of course, it's fixable even from my side, but i think it makes more sense for --rmenv to work before the length check.
That way, i could just add
to
~/.config/firejail/globals.localAnd have just one LS_COLORS in .profile, instead of a bunch of local
env LS_COLORS="$(vivid ...)" whateveror similar.So what do you think? Is this expected behavior?
Environment
0ab64e277f(because i want new dbus stuff for firefox, because #3290 )Checklist
The upstream profile (and redirect profile if exists) have no changes fixing it.The program has a profile. (If not, request one in # 1139)Programs needed for interaction are listed in the profile.If it is a AppImage,--profile=PROFILENAMEis used to set the right profile....Behavior is not related to particular program, in regards to duplicates - i haven't seen anything about length check / --rmenv order.
debug output (with long AAAA)
(yes, there is nothing else)
EDIT:
Ops, i didn't actually need to use latest master to fix #3290.
Turns out, it's an error on my side - what i wanted to do is to have 2 separate isolated profiles with different configs and stuff, and naturally i used firefox with -no-remote flag, so two instances could run simultaneously.
And when i tried to open new links in one of them with
firejail firefox -no-remote -p pr1 *link*- i was getting the same error, as in #3290.After messing around in the middle of the night with a launch script (in which i wrapped conditional whitelisting and stuff) and upgrading to the latest master it eventually work, so i assumed that master fixed it and forgot about now missing -no-remote.
Turns out, when you run firefox in firejail, you can run two instances simultaneously without -no-remote.
Well, that's embarrassing. 😅
But i think original question about --rmenv / length checking order is still valid, since i (and probably other vivid users too) eventually will have to deal with it.
In case anyone wants the launching script - here it is:
fjfirefox
@topimiettinen commented on GitHub (Oct 15, 2020):
Currently the environment variables are checked as early as possible, then config files are read, then program arguments including
--rmenvand--env. It would make sense to handle--rmenvand--envspecially before env var check. That way also env vars added by--envwould be subject to the same restrictions.@topimiettinen commented on GitHub (Oct 15, 2020):
This seems more tricky than I thought. It makes sense to process
--rmenvearly (and even remove the environment variables immediately), but--envis not so clear.--rmenvand--envonly apply to the sandboxed program, not to the main program of Firejail. Removing variables from the sandbox (and also from Firejail itself) should be safe. The length checks are made to protect Firejail as it's a set-uid program. But for the sandboxed program it should be OK to pass any kind of variables, so the checks shouldn't be necessary for them. Though similar length checks are also applied to arguments, which makes impossible to pass long variables with--env.Maybe the argument length checks should be dropped for
--env. But #3322 would remove most of the env variables from Firejail (they would still be passed to sandboxes), then the environment variable length checks could be made to apply only to those variables which are retained and the others could be any length.@MahouShoujoMivutilde commented on GitHub (Oct 15, 2020):
Wow, that was fast! Thank you for working on it.
I've built your PR against
a3d415a1a4, and it seems to work, but only with --rmenv, not with rmenv inside config files.here is a quick test
As you can see, globals.local is read and applied as expected when AAAA is short.
But firejail still exits with an error when AAAA is long.
--rmenv, however, now works as expected.
@topimiettinen commented on GitHub (Oct 16, 2020):
I see. The problem with
rmenvin profiles is that the profiles are read during processing of program arguments where lots of other stuff also happens, so if the length check would be moved after that, it would be very late. Reading the profiles earlier is also not possible since profiles can be added also with--profile. So for that I'd rather finalize #3322 first, but since we're now closer to a new release, it may not be a good move to do that just now.The error message could be more helpful and suggest using
--rmenv. Maybe the long variables and program arguments could be even removed automatically with a warning, but Firejail would not need to exit. Removing excess variables or arguments could be too random.@MahouShoujoMivutilde commented on GitHub (Oct 16, 2020):
Makes sense.
But until #3322 is finished, wouldn't you always want to remove them anyway - so firejail will actually run?
If you decide to go this route - i think length check can be just a warning about dropped variables, but if, e.g. user also has too many variables - it's his job to clean them, and there should be an error.
But i get what you mean, as a quick fix a warning instead of error is maybe ok, but in a long run #3322 seems like is a way to go.
@topimiettinen commented on GitHub (Oct 17, 2020):
I think the workarounds should be good enough for just now, the user could miss the warnings for removing and removing could cause other problems.