Commit ebe4652e authored by Leigh B Stoller's avatar Leigh B Stoller

Couple of additional checks to make sure we do not create a profile

with no rspec, nor try to start an experiment with no rspec.
parent 63c10c6d
...@@ -346,9 +346,20 @@ $version = $profile->version(); ...@@ -346,9 +346,20 @@ $version = $profile->version();
# #
if (exists($xmlparse->{'attribute'}->{"rspec"})) { if (exists($xmlparse->{'attribute'}->{"rspec"})) {
$rspecstr = $xmlparse->{'attribute'}->{"rspec"}->{'value'}; $rspecstr = $xmlparse->{'attribute'}->{"rspec"}->{'value'};
# Trim()
$rspecstr =~ s/^\s+|\s+$//g;
if ($rspecstr eq "") {
UserError("Not a valid rspec");
}
} }
else { else {
$rspecstr = $profile->CheckFirewall(!$localuser); $rspecstr = $profile->rspec();
# Trim()
$rspecstr =~ s/^\s+|\s+$//g;
if ($rspecstr eq "") {
UserError("Profile does not have a valid rspec");
}
$rspecstr = $profile->CheckFirewall(!$localuser);
} }
# #
# Optional rspec and/or script, as for a repo-based profile. # Optional rspec and/or script, as for a repo-based profile.
...@@ -653,13 +664,11 @@ if ($localuser) { ...@@ -653,13 +664,11 @@ if ($localuser) {
$emulab_user, $project)); $emulab_user, $project));
# Hack for Kobus' class, generalize someday. # Hack for Kobus' class, generalize someday.
if (0) {
if ($pid eq "CS4480-2018") { if ($pid eq "CS4480-2018") {
my $termination = str2time("2018-05-02"); my $termination = str2time("2018-05-02");
# convert to hours till then # convert to hours till then
$duration = int(($termination - time()) / 3600); $duration = int(($termination - time()) / 3600);
} }
}
} }
elsif (!$localuser) { elsif (!$localuser) {
if (defined($sshkey)) { # if (defined($sshkey)) { #
......
...@@ -129,12 +129,16 @@ function Do_Create() ...@@ -129,12 +129,16 @@ function Do_Create()
if (! TBvalid_rspec($formfields["profile_rspec"])) { if (! TBvalid_rspec($formfields["profile_rspec"])) {
$errors["profile_rspec"] = TBFieldErrorString(); $errors["profile_rspec"] = TBFieldErrorString();
} }
elseif (trim($formfields["profile_rspec"]) == "") {
$errors["profile_rspec"] = "no rspec provided";
}
else { else {
$rspec = $formfields["profile_rspec"]; $rspec = $formfields["profile_rspec"];
} }
} }
if (isset($formfields["profile_script"]) && if (isset($formfields["profile_script"]) &&
$formfields["profile_script"] != "") { $formfields["profile_script"] != "" &&
trim($formfields["profile_script"]) != "") {
$script = $formfields["profile_script"]; $script = $formfields["profile_script"];
} }
if (isset($formfields["portal_converted"]) && if (isset($formfields["portal_converted"]) &&
......
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