Commit a05d2fae authored by Timothy Stack's avatar Timothy Stack

Add webcopy script for copying uploaded files to a /proj or /groups

directory.
parent dc995f64
......@@ -2155,7 +2155,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/nsgen/GNUmakefile utils/nsgen/webnsgen \
utils/link_config utils/import_commitlog utils/dhcpd_wrapper \
utils/opsreboot utils/deletenode utils/webdeletenode utils/spewleds \
utils/grabwebcams utils/loghole \
utils/grabwebcams utils/loghole utils/webcopy \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
www/swish.conf www/websearch www/garcia-telemetry/GNUmakefile \
vis/GNUmakefile vis/webvistopology vis/dbvistopology \
......
......@@ -738,7 +738,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/nsgen/GNUmakefile utils/nsgen/webnsgen \
utils/link_config utils/import_commitlog utils/dhcpd_wrapper \
utils/opsreboot utils/deletenode utils/webdeletenode utils/spewleds \
utils/grabwebcams utils/loghole \
utils/grabwebcams utils/loghole utils/webcopy \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 \
www/swish.conf www/websearch www/garcia-telemetry/GNUmakefile \
vis/GNUmakefile vis/webvistopology vis/dbvistopology \
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
#
# Configure variables
#
my $TB = "@prefix@";
my $FSDIR_PROJ = "@FSDIR_PROJ@";
my $FSDIR_GROUPS = "@FSDIR_GROUPS@";
use lib "@prefix@/lib";
use libdb;
use libtestbed;
if ($UID == 0) {
die("*** $0: Cannot be run as root\n");
}
# un-taint path
$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin:$TB/bin";
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Handle command-line arguments
# TODO: Allow a user to specify some of their own arguments to uisp
#
sub usage() {
warn "Usage: $0 <src> <dst>\n";
exit(-1);
}
if (@ARGV != 2) {
usage();
}
$src = `realpath $ARGV[0]`;
if ($src =~ /^([-\w\/.]+)$/) {
$src = $1;
} else {
die("*** Tainted source: $src\n");
}
$dst = `realpath $ARGV[1]`;
if ($dst =~ /^([-\w\/.]+)$/) {
$dst = $1;
} else {
die("*** Tainted destination: $dst\n");
}
my $tmpdir = $ENV{'TMPDIR'};
$tmpdir = "/tmp"
if (!defined($tmpdir));
if ($src =~ /^($tmpdir\/[-\w\/.]+)$/) {
$src = $1;
} else {
die("*** Source isn't a php temp file.\n");
}
my $pr = PROJROOT();
my $gr = GROUPROOT();
if ($dst =~ /^(($pr|$FSDIR_PROJ|$gr|$FSDIR_GROUPS)\/[-\w\/.]+)$/) {
$dst = $1;
} else {
die("*** Destination must be in "
. PROJROOT() . " or " . GROUPROOT() . "\n");
}
system("cp $src $dst");
if ($dst) {
chmod(0644, $dst);
}
exit $?
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment