mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #704] Login shells through FireJail - Interpreter initialization files are never read #479
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#479
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 @nuxwin on GitHub (Aug 12, 2016).
Original GitHub issue: https://github.com/netblue30/firejail/issues/704
Current behavior
When using Firejail for login shells (login.users), interpreter initialization files ( /etc/profile or any of the personal initialization files ~/.bash_profile, ~/.bash_login, or ~/.profile), depending on the interpreter in use (Bash, Dash, ASH ...), are never read.
Expected behavior
Interpreter initialization files should be read.
@nuxwin commented on GitHub (Aug 12, 2016):
@netblue30
my workaround for now:
login.users
But I would prefer see firejail to do the job.
Note also that here, I remove the
PROMPT_COMMANDenvironment variable because my/etc/profilefile take care of this. My thinking is that in case of login shell, you should considere to mimic the default behavior. For common interpreters (bash, dash, ash ...) this can be easily achieved by invoking them with the-lparameter.My system-wide
/etc/profilefile which is automatically copied inside the chroot by our underlying jail builder look as follow:@netblue30 commented on GitHub (Aug 14, 2016):
I think I have a fix, you can give it a try. Somehow it ends up calling both .bash_profile and .bashrc:
@nuxwin commented on GitHub (Aug 14, 2016):
@netblue30
I'll check now. Hope that /etc/profile is also read to cover case where .bash_profile and .bashrc are missing.
@nuxwin commented on GitHub (Aug 14, 2016):
@netblue30
-cand-loptions. If I remove the-coption, that works as expected. Anyway, in the context oflogin_shell(we have now a var to detect it), I think that we should discard additional argv (we should only allow firejail options in that context). This would also solve next point.Current result:
Expected behavior
After fixing the assert:
I've a fix. I'll do a PR in few minutes with explanations here.
@nuxwin commented on GitHub (Aug 14, 2016):
@netblue30
See https://github.com/netblue30/firejail/pull/714
Summary
cfg.command_lineis passed in (either through SSH or in the login.users file), we start the shell with the-loption without further argumentcfg.shellas usually, using the-coptionExamples
Note that here, the initialization files are read.
Note that here, the initialization files are not read. This shouldn't be an issue since the shell will terminate immediately after running
cfg.command_linewhich here is thedatecommand.Furthermoor
With that PR, we avoid an ueless subprocess.
@netblue30 commented on GitHub (Aug 15, 2016):
I think there is more to come, now it doesn't work for me, it goes directly to .bashrc. I'll look into it tomorrow.
@nuxwin commented on GitHub (Aug 15, 2016):
@netblue30
I'll have a look too.
@nuxwin commented on GitHub (Aug 15, 2016):
@netblue30
I've just tested with current master. For me, there is no problem.
First of all:
.bashrcmust be run only in case of non-login shell..bashrc:
To simulate a non-login shell, I've set my
login.usersfile as follow:Then, I get the following result:
As you can see here, only the
.bashrcis read. Thedatecommand is run and the session terminate immediately. Here we are in a non-login context and therefore,/etc/profileand/home/nuxwin/.profileare not read.Now, if I don't put any command (true login shell context):
We get the following result:
As you can see here,
.bashrcis not read. That is expected because.bashrcmust be read in context of non-login shells only. However, since we are in login shell context, both/etc/profileand/home/nuxwin/.profileare read.Implementation is simple here: If the
-coption is used, we are not in login shell context. This is same as Bash (and other shells) implementations.@netblue30 commented on GitHub (Aug 15, 2016):
I put in some fixes, also the green prompt was removed.
@netblue30 commented on GitHub (Aug 16, 2016):
Got your email, don't worry about it, it's not a problem. Let's reset and move to this thread: https://github.com/netblue30/firejail/issues/719