Commit 9429968f authored by Leigh B. Stoller's avatar Leigh B. Stoller

Change NS syntax check page to allow for local and uploaded file, as

per Mike request.
parent 438cef80
......@@ -13,22 +13,70 @@ $uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# I am not going to allow shell experiments to be created (No NS file).
#
if (!isset($exp_nsfile) ||
strcmp($exp_nsfile, "") == 0 ||
strcmp($exp_nsfile, "none") == 0) {
USERERROR("You must supply an NS file!", 1);
# Not allowed to specify both a local and an upload!
#
$speclocal = 0;
$specupload = 0;
$nsfile = "";
if (isset($exp_localnsfile) && strcmp($exp_localnsfile, "")) {
$speclocal = 1;
}
if (isset($exp_nsfile) && strcmp($exp_nsfile, "") &&
strcmp($exp_nsfile, "none")) {
$specupload = 1;
}
if ($speclocal && $specupload) {
USERERROR("You may not specify both an uploaded NS file and an ".
"NS file that is located on the Emulab server", 1);
}
if (!$specupload && strcmp($exp_nsfile_name, "")) {
#
# Catch an invalid filename.
#
USERERROR("The NS file '$exp_nsfile_name' does not appear to be a ".
"valid filename. Please go back and try again.", 1);
}
#
# XXX
# Set the permissions on the NS file so that the scripts can get to it.
# It is owned by nobody, and most likely protected. This leaves the
# script open for a short time. A potential security hazard we should
# deal with at some point.
# Gotta be one or the other!
#
chmod($exp_nsfile, 0666);
if (!$speclocal && !$specupload) {
USERERROR("You must supply an NS file!", 1);
}
if ($speclocal) {
#
# No way to tell from here if this file actually exists, since
# the web server runs as user nobody. The startexp script checks
# for the file before going to ground, so the user will get immediate
# feedback if the filename is bogus.
#
# Do not allow anything outside of /users or /proj. I don't think there
# is a security worry, but good to enforce it anyway.
#
if (! ereg("^$TBPROJ_DIR/.*" ,$exp_localnsfile) &&
! ereg("^$TBUSER_DIR/.*" ,$exp_localnsfile)) {
USERERROR("You must specify a server resident in file in either ".
"$TBUSER_DIR/ or $TBPROJ_DIR/", 1);
}
$nsfile = $exp_localnsfile;
$nonsfile = 0;
}
else {
#
# XXX
# Set the permissions on the NS file so that the scripts can get to it.
# It is owned by nobody, and most likely protected. This leaves the
# script open for a short time. A potential security hazard we should
# deal with at some point.
#
chmod($exp_nsfile, 0666);
$nsfile = $exp_nsfile;
$nonsfile = 0;
}
#
# Run the script. We use a script wrapper to deal with changing
......@@ -38,8 +86,7 @@ chmod($exp_nsfile, 0666);
$output = array();
$retval = 0;
$result = exec("$TBSUEXEC_PATH $uid flux webnscheck $exp_nsfile",
$output, $retval);
$result = exec("$TBSUEXEC_PATH $uid flux webnscheck $nsfile", $output, $retval);
echo "<center>";
echo "<h1>Syntax Check Results</h1>";
......
......@@ -15,7 +15,7 @@ LOGGEDINORDIE($uid);
?>
<table align="center" border="1">
<tr>
<td align="center" colspan="2">
<td align="center" colspan="3">
<font size="+1">
Use this page to syntax check your NS file before
submitting it.
......@@ -27,20 +27,33 @@ LOGGEDINORDIE($uid);
echo "<form enctype=\"multipart/form-data\"
action=\"nscheck.php3\" method=\"post\">\n";
#
# NS file upload.
# NS file upload or on server.
#
echo "<tr>
<td>Your NS file (20K max):</td>
<td><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"20000\">
<td rowspan>*Your NS file: &nbsp</td>
<td rowspan><center>Upload (20K max)<br>
<br>
Or<br>
<br>
On Server (/proj or /users)
</center></td>
<td rowspan>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"20000\">
<input type=\"file\" name=\"exp_nsfile\" size=\"30\">
<br>
<br>
<input type=\"text\" name=\"exp_localnsfile\" size=\"40\">
</td>
</tr>\n";
?>
<tr>
<td align="center" colspan="2">
<td align="center" colspan="3">
<b><input type="submit" value="Check"></b></td>
</tr>
</form>
......
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