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
439 stars 111 forks source link

Restrict exit #156

Closed guanana closed 8 years ago

guanana commented 8 years ago

Is any possibility that we can restrict exit command in lshell? I'm having env problems trying to login directly with lshell. One solution could be define the shell as bash and then execute lshell. It works perfect, the only problem... the user can just execute exit and come back to the bash. I tried adding exit in the forbidden commands but doesn't work. I also commented in the file /usr/lib/python2.6/site-packages/lshell.py this lines:

148:        #if self.g_cmd in ['quit', 'exit', 'EOF']:
149:        #    self.log.error('Exited')
150:        #    if self.g_cmd == 'EOF':
151:        #        self.stdout.write('\n')
152:       #    sys.exit(0)

No luck neither.

Could you please tell me if is a feature it exists? Am I editing the incorrect file?

ghantoos commented 8 years ago

This feature is not implemented for the moment. I will add it to the wishilist.

Were you able to find a temporary solution?

ghantoos commented 8 years ago

@guanana you just need to comment #sys.exit(0), the rest of the lines need to be uncommented to catch the "exit"

guanana commented 8 years ago

Even with your solution I'm unable to avoid the exit

centos-server ~ $ grep -A5 quit /usr/lib/python2.6/site-packages/lshell.py
        if self.g_cmd in ['quit', 'exit', 'EOF']:
            self.log.error('Exited')
            if self.g_cmd == 'EOF':
                self.stdout.write('\n')
        #    sys.exit(0)

centos-server ~ $ lshell

Welcome to your shell
Type '?' or 'help' to get a list of allowed commands

Contact support@company.com with any queries or problems
viewlogs:~$ exit
centos-server ~ $
centos-server ~ $ lshell --version
lshell-0.9.18 - Limited Shell
ghantoos commented 8 years ago

@guanana what version of lshell are you running?

guanana commented 8 years ago

It is on the previous comment @ghantoos , 0.9.18