/[pdpsoft]/nl.nikhef.ndpf.tools/sgmshell/sgmshell.cin
ViewVC logotype

Annotation of /nl.nikhef.ndpf.tools/sgmshell/sgmshell.cin

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations) (download)
Wed Aug 27 08:50:40 2008 UTC (14 years, 1 month ago) by davidg
File size: 850 byte(s)
Initial test version

1 davidg 23 #! /usr/bin/perl -w
2     #
3     use strict;
4     use File::Temp qw/ :mktemp /;
5    
6     my $verbose=0;
7    
8     my ($logf,$logfname) = mkstemp( "/var/tmp/sgmshell.$$.XXXXX" );
9    
10     my $logmsg = "starting sgmshell uid $< on ".(scalar gmtime)." with @ARGV\n";
11     $verbose and print $logf $logmsg;
12     system("logger -p daemon.notice -t sgmshell \'$logmsg\'");
13    
14     $ARGV[0] eq "-c" or do {
15     print $logf "Terminating due to invalid invocation (argv0 is not -c)\n";
16     die "Invalid invocation\n";
17     };
18     shift @ARGV;
19    
20     # verify validity of command
21     my $command = join ' ',@ARGV;
22     my $permitted=0;
23     foreach ( $command ) {
24     /^rsync --server( --sender)? -[a-zA-Z0-9]+ \. \/data\/esia\/\S+$/ and do {
25     @_ = split;
26     $permitted=1 unless $_[$#_]=~/\/\.\.\//;
27     };
28     }
29     $permitted or do {
30     print $logf "denied command $command (".$ARGV[$#ARGV].")\n";
31     die "Invalid invocation\n";
32     };
33    
34     # execute it
35     exec @ARGV;
36    

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28