nsfiles.pl 890 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006, 2007 University of Utah and the Flux Group.
# All rights reserved.
#
use English;

use lib "/usr/testbed/lib";
use libdb;
use libtestbed;
use Experiment;

my $tmpfile = "/tmp/nsfile.$$";

#
# Untaint the path
# 
$ENV{'PATH'} = '/bin:/usr/bin:/usr/sbin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};

my $query_result =
    DBQueryFatal("select * from nsfiles");

while (my ($pid, $eid, $exptidx, $nsfile) = $query_result->fetchrow_array()) {
    my $experiment = Experiment->Lookup($exptidx);
    if (!defined($experiment)) {
28 29
	print "Could not lookup experiment object for $exptidx\n";
	next;
30 31 32 33 34 35 36 37 38 39
    }
    open(NSFILE, ">$tmpfile")
	or die("Could not open $tmpfile for writing!\n");
    print NSFILE $nsfile;
    close(NSFILE);

    $experiment->SetNSFile($tmpfile) == 0
	or die("Could not add $tmpfile to $experiment!\n");
}