Skip to content

Commit

Permalink
Avoid useless processes launching shell
Browse files Browse the repository at this point in the history
There's no reason to keep 3 shell processes to execute one.
Remove "()" in command to avoid one additional process.
Add "exec" on last command to replace current process.
Remove exports, not necessary as changing one single command
environment.

This changes this:

$ pstree -alp | grep -4 bash
...
  |-python,2051 /usr/lib64/xsconsole/XSConsole.py -f root
  |   `-sh,3238 -c ( export HOME=/root; export TMOUT=300 && cat /etc/motd && /bin/bash --login )
  |       `-sh,3239 -c ( export HOME=/root; export TMOUT=300 && cat /etc/motd && /bin/bash --login )
  |           `-bash,3241 --login
...

to this:

$ pstree -alp | grep -4 bash
...
  |-python,2044 /usr/lib64/xsconsole/XSConsole.py -f root
  |   `-bash,3128 --login
...

Signed-off-by: Frediano Ziglio <[email protected]>
  • Loading branch information
freddy77 authored and andyhhp committed Jan 30, 2024
1 parent 889435c commit 08e12be
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins-base/XSFeatureLocalShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def StartLocalShell(self):
user = os.environ.get('USER', 'root')
Layout.Inst().ExitBannerSet(Lang("\rShell for local user '")+user+"'.\r\r"+
Lang("Type 'exit' to return to the management console.\r"))
Layout.Inst().SubshellCommandSet("( export HOME=/root; export TMOUT="+str(State.Inst().AuthTimeoutSeconds())+" && cat /etc/motd && /bin/bash --login )")
Layout.Inst().SubshellCommandSet("cat /etc/motd && HOME=/root TMOUT="+str(State.Inst().AuthTimeoutSeconds())+" exec /bin/bash --login")
XSLog('Local shell')

@classmethod
Expand Down

0 comments on commit 08e12be

Please sign in to comment.