-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug? --rmenv seems to fire after check for length of environment variables, which makes long variables impossible to remove from firejail side #3673
Comments
Currently the environment variables are checked as early as possible, then config files are read, then program arguments including |
This seems more tricky than I thought. It makes sense to process
Maybe the argument length checks should be dropped for |
Remove environment variables with --rmenv (and profile rmenv) immediately. This fixes removing long environment variables (LS_COLORS generated by vivid), previously the length filter would trip before the command was processed. This changes user visible behavior slightly, for example --rmenv=LANG now applies also to Firejail, while earlier it would only apply to sandboxed program. Closes netblue30#3673. Signed-off-by: Topi Miettinen <[email protected]>
Remove environment variables with --rmenv (and profile rmenv) immediately. This fixes removing long environment variables (LS_COLORS generated by vivid), previously the length filter would trip before the command was processed. This changes user visible behavior slightly, for example --rmenv=LANG now applies also to Firejail, while earlier it would only apply to sandboxed program. Closes netblue30#3673. Signed-off-by: Topi Miettinen <[email protected]>
Wow, that was fast! Thank you for working on it. I've built your PR against a3d415a, and it seems to work, but only with --rmenv, not with rmenv inside config files. here is a quick test~ ❯ export AAAA2=bbbb
~ ❯ cat ~/.config/firejail/globals.local
rmenv AAAA
~ ❯ export AAAA=bbbb
~ ❯ firejail env | grep -i aaaa
Reading profile /etc/firejail/default.profile
Reading profile /home/witch/.config/firejail/globals.local
Reading profile /etc/firejail/disable-common.inc
Reading profile /etc/firejail/disable-passwdmgr.inc
Reading profile /etc/firejail/disable-programs.inc
** Note: you can use --noprofile to disable default.profile **
Parent pid 677723, child pid 677725
Warning: /sbin directory link was not blacklisted
Warning: /usr/sbin directory link was not blacklisted
Warning: cleaning all supplementary groups
Child process initialized in 63.74 ms
AAAA2=bbbb
Parent is shutting down, bye... As you can see, globals.local is read and applied as expected when AAAA is short. ~ ❯ export AAAA=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 8000)
~ ❯ firejail env | grep -i aaaa
Error: too long environment variables
~ ❯ firejail --profile=default env | grep -i aaaa
Error: too long environment variables But firejail still exits with an error when AAAA is long. ~ ❯ firejail --rmenv=AAAA env | grep -i aaaa
Reading profile /etc/firejail/default.profile
Reading profile /home/witch/.config/firejail/globals.local
Reading profile /etc/firejail/disable-common.inc
Reading profile /etc/firejail/disable-passwdmgr.inc
Reading profile /etc/firejail/disable-programs.inc
** Note: you can use --noprofile to disable default.profile **
Parent pid 681426, child pid 681428
Warning: /sbin directory link was not blacklisted
Warning: /usr/sbin directory link was not blacklisted
Warning: cleaning all supplementary groups
Child process initialized in 75.99 ms
AAAA2=bbbb
Parent is shutting down, bye...
~ ❯ firejail --noprofile --rmenv=AAAA env | grep -i aaaa
Parent pid 724839, child pid 724842
Child process initialized in 12.36 ms
AAAA2=bbbb
Parent is shutting down, bye... --rmenv, however, now works as expected. |
I see. The problem with The error message could be more helpful and suggest using |
Remove environment variables with --rmenv immediately. This fixes removing long environment variables (LS_COLORS generated by vivid), previously the length filter would trip before the command was processed. This changes user visible behavior slightly, for example --rmenv=LANG now applies also to Firejail, while earlier it would only apply to sandboxed program. Partially fixes netblue30#3673, but not handling `rmenv` in profiles. Also suggest --rmenv when there are problems with enviroment variables. Signed-off-by: Topi Miettinen <[email protected]>
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. |
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. |
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,
AAAA
is removed, andAAAA2
is available.But now let's see what happens if we set
AAAA
to 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.local
And have just one LS_COLORS in .profile, instead of a bunch of local
env LS_COLORS="$(vivid ...)" whatever
or similar.So what do you think? Is this expected behavior?
Environment
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=PROFILENAME
is 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
The text was updated successfully, but these errors were encountered: