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 @commands_requiring_unquote $errmsg @cmd / ;
10 use subs qw/ &reject / ;
13 @allowed_options = ('-c', '-e') ;
14 @allowed_commands = ('cvs','scp','svnserve','bzr','git-upload-pack','git-receive-pack','git-upload-archive') ;
15 @commands_requiring_unquote = ('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 = split (/ +/, $ARGV[1]) ;
36 if (scalar (grep { $_ eq $cmd[0] } @allowed_commands) == 0) {
37 $errmsg = "Command not allowed." ;
41 if (scalar (grep { $_ eq $cmd[0] } @commands_requiring_unquote) != 0) {
42 foreach my $i (1..$#cmd) {
43 if ($cmd[$i] =~ /^'(.*)'$/) {
52 print "This is a restricted account.\n" .
53 "You cannot execute anything here.\n" .