ghantoos / lshell

lshell is a shell coded in Python, that lets you restrict a user's environment to limited sets of commands, choose to enable/disable any command over SSH (e.g. SCP, SFTP, rsync, etc.), log user's commands, implement timing restriction, and more.
GNU General Public License v3.0
436 stars 112 forks source link

lshell .profile to run command on user login? #77

Closed hostingnuggets closed 8 years ago

hostingnuggets commented 10 years ago

Does lshell support a file such as the .bash_profile where one can run commands when the user logs in? I would like to run the following command as soon as the user logs in:

eval "$(rbenv init -)"

xlr-8 commented 10 years ago

Hello, I believe this already works.

I created the ".profile" in my user's home with execution/user/group rights appropriated. The content of the file is a comment, then basic commands (e.g. eval) with ENV variable.

# ll /home/lshell/.profile
-rwxr--r-- 1 lshell lshell 47 Jun 28 01:18 /home/lshell/.profile*
# cat /home/lshell/.profile
# Testing .profile
echo "Hello World or $USER"
eval "$(echo VAR=42)"
v=VAR
eval echo \${$v}
# End of testing .profile

The variable to use is 'login_script':

# grep .profile /etc/lshell.conf
login_script     : "/home/lshell/.profile"

Considering you also have the latest -current- version: 0.9.16, you should be good to go:

> lshell --version
lshell-0.9.16 - Limited Shell
> su - lshell
Password: 
You are in a limited shell.
Type '?' or 'help' to get the list of allowed commands
Hello World or lshell
42
lshell:~$ 

It seems relevant to point out that eval -due to its properties- can be a dangerous command to use.

hostingnuggets commented 9 years ago

unfortunately adding eval "$(rbenv init -)" to my lshell login_script does not work, see #89

ghantoos commented 8 years ago

Closing, duplicate of #89