Checking Submission Method with file_filter

Particularly in introductory courses, it may be helpful to have an initial assignment that records whether a submission was made from Odyssey or from the submit command. The following script will, in the majority of reasonable cases (although it is possible to fake Odyssey use via submit), record which was used. It should be placed in /u/csXXX/bin/file_filter so the default ISG filter will detect and call it.

#!/usr/bin/env perl

# Log individual server accesses (web or not) for assignment 0.
use constant LOGGED_ASSIGN => '00';
use constant WWW_SERVER => 'services08.student.cs';

my $assign = $ARGV[1];

# Need to fix PATH... blech.
$ENV{'PATH'} = '/bin';


if ($assign eq LOGGED_ASSIGN) {
   # Get the location of the hostname executable, then run it.
   chomp(my $hostname = `/bin/showpath vendor findfirst=hostname`);
   $hostname =~ /^(.*)$/;
   chomp($hostname = `$1`);

   my $submit_method = 'submit';
   if ($hostname eq WWW_SERVER) {
      $submit_method = 'odyssey';
   }

   # These arguments have been supplied by the submit command and are assumed
   # safe as a result; untaint them unconditionally.
   $ARGV[0] =~ /^(.*)$/;
   my $course_name = $1;

   $ARGV[2] =~ /^(.*)/;
   my $student = substr($1, 0, 8);

   # Don't create this directory when it doesn't exist, as this script is not
   # running as the course account userid.
   my $dir = "/u/$course_name/submethod_log";
   die("Submit method directory $dir does not exist: $!") unless (-d $dir);
   die("Cannot write to submit method directory $dir: $!") unless (-w $dir);

   # Touch the log file...
   my $targetfile =  "$dir/$student.$submit_method";
   umask 0707;
   unless (-e $targetfile) {
      open(FH, ">$targetfile") or die "Can't create $targetfile: $!";
      close(FH);
   }
   chmod 0060, $targetfile;
}


# Now re-call the main ISG filter; this environment variable
# was set by the calling program, and again is known to be 
# safe as a result.
$ENV{'ISG_FILTER'} =~ /^(.*)$/;
my $filter = $1;
for my $arg (@ARGV) {
   $arg =~ /^(.*)$/;
   $arg = $1;
}
exec $filter, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4];

This script records results in the directory /u/csXXX/submethod_log/; the public tests can then check here for the files userid.submit and userid.odyssey. It is possible to do such a test using BitterSuite. Note that, as nothing is ever written to standard output, this "filter" does not actually do any filtering. Note also that the directory /u/csXXX/submethod_log/ must be created by the course account before the filter goes live.

The reason that this script does not write to the student's submission directory is that it is possible to set up submit such that it deletes the student's old submission when a new one is created, and this setup configuration is required for the default ISG file_filter to work properly in all cases.

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2009-09-04 - TerryVaskor
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback