3 # "Shell" for a restricted account, limiting the available commands
4 # Roland Mas, debian-sf (Sourceforge for Debian)
6 # Inspired from the grap.c file in Sourceforge 2.5
9 use vars qw/ @allowed_options @allowed_commands $errmsg @cmd / ;
10 use subs qw/ &reject / ;
14 @allowed_options = ('-c', '-e') ;
15 @allowed_commands = ('cvs','scp','/usr/lib/openssh/sftp-server','svnserve','bzr','git-upload-pack','git-receive-pack','git-upload-archive') ;
17 # Clean up our environment
18 delete @ENV{qw(IFS CDPATH ENV BASH_ENV PATH)};
22 $errmsg = "Not enough arguments." ;
24 $errmsg = "Too many arguments." ;
29 if (scalar (grep { $_ eq $ARGV[0] } @allowed_options) == 0) {
30 $errmsg = "Option not allowed." ;
34 @cmd = shellwords ($ARGV[1]) ;
37 $errmsg = "Command not allowed." ;
41 if (scalar (grep { $_ eq $cmd[0] } @allowed_commands) == 0) {
42 $errmsg = "Command not allowed." ;
49 print "This is a restricted account.\n" .
50 "You cannot execute anything here.\n" .