#!/usr/bin/perl ####################################################################### # Robomod Maintainers: Modify this section until _END_ # $approvedAddress = "scrm-approved\@algebra.com"; # # _END_ # Do NOT modify the rest ####################################################################### $reason = shift( @ARGV ); sub sendMessage { $reason = pop( @_ ); open( SENDING, "| (pgp -eaf +batchmode $approvedAddress 2>/dev/null " . " | mail $approvedAddress)" ); $whoami = `whoami`; chop $whoami; print SENDING "$approvalCommand $whoami $Explanation\n"; while( <> ) { print SENDING; } close( SENDING ); } sub isInPath { local( $exec ) = pop( @_ ); local( @Path ) = split( /:/, $ENV{'PATH'} ); local( $i ); foreach $i (@Path) { return 1 if( -x "$i/$exec" ); } return 0; } sub checkPath { local( @execs ) = ( 'whoami', 'pgp', 'mail' ); local( $i ); foreach $i (@execs) { if( !&isInPath( $i ) ) { die "ATTENTION: Program '$i' is REQUIRED to reject articles, but is\n" . "not in your PATH. Check settings of your PATH environment " . "variable. \n"; } } } ################################################################# askQuestion # asks a Q according to text and regexp # sub askQuestion { local( $regexp ) = pop( @_ ); local( $question ) = pop( @_ ); open( TTYIN, "/dev/tty" ); do { print "$question ==>"; $_ = ; } until( /$regexp/i ); close( TTYIN ); return uc( "$1" ); } checkPath; open( TTYIN, "/dev/tty" ); open( TTYOUT, "> /dev/tty" ); print TTYOUT "\n\nType a ONE-LINE comment to your approval. \nIf you do " . "not feel like typing, simply press ENTER.\n\n==>"; $Explanation = ; chop $Explanation; close( TTYIN ); $answer = &askQuestion( "\n\nDo you think that this poster is TRUSTWORTHY enough\n" . "to be put on our preapproved list? (Y/N)", "^(Y|N)\$" ); if( $answer eq 'Y' || $answer eq 'y' ) { $approvalCommand = "processPreapproved"; } else { $approvalCommand = "processApproved"; } &sendMessage( $reason );