Пример #1
0
    # Fatal Error. Report to the user, even though there is not much he can
    # do with the error. Also reports to tbops.
    #
    if ($retval < 0) {
        SUEXECERROR(SUEXEC_ACTION_CONTINUE);
    }
    # User error. Tell user and exit.
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
    return;
}
#
# Parse the last line of output. Ick.
#
if (preg_match("/^Template\\s+(\\w+)\\/(\\w+)\\s+is being/", $suexec_output_array[count($suexec_output_array) - 1], $matches)) {
    $guid = $matches[1];
    $vers = $matches[2];
    $template = Template::Lookup($guid, $vers);
    if (!$template) {
        TBERROR("Could not lookup template object for {$guid}/{$vers}", 1);
        return;
    }
    echo $template->PageHeader();
    echo "<br><br>\n";
    STARTLOG($template);
} else {
    SUEXECERROR(SUEXEC_ACTION_DIE);
}
#
# Standard Testbed Footer
#
PAGEFOOTER();
Пример #2
0
# of the node running the checkin. We could return an http error, but
# that would be of no help to the user on the other side.
#
function SPITSTATUS($code, $msg)
{
    header("HTTP/1.0 {$code} {$msg}");
    exit;
}
# Required arguments
$reqargs = RequiredPageArguments("xmlstuff", PAGEARG_ANYTHING);
$xmlname = tempnam("/tmp", "sitecheckin");
if (!$xmlname) {
    TBERROR("Could not create temporary filename", 0);
    SPITSTATUS(404, "Could not create temporary file!");
}
if (!($fp = fopen($xmlname, "w"))) {
    TBERROR("Could not open temp file {$xmlname}", 0);
    SPITSTATUS(404, "Could not open temporary file!");
}
fwrite($fp, $xmlstuff);
fclose($fp);
chmod($xmlname, 0666);
#
# Invoke the backend and return the status.
#
$retval = SUEXEC("elabman", $TBADMINGROUP, "websitecheckin {$xmlname}", SUEXEC_ACTION_IGNORE);
if ($retval) {
    SUEXECERROR(SUEXEC_ACTION_CONTINUE);
    SPITSTATUS(404, "Could not do a site checkin!");
}
unlink($xmlname);
Пример #3
0
if (isset($action) && $action == "deletetemplate" && isset($confirmed) && $confirmed == "yep") {
    PAGEHEADER("Delete Template: {$guid}/{$vers}");
    STARTBUSY("Deleting template {$guid}/{$vers} recursively");
    # Pass recursive option all the time.
    $retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_delete -r {$guid}/{$vers}", SUEXEC_ACTION_IGNORE);
    CLEARBUSY();
    #
    # Fatal Error. Report to the user, even though there is not much he can
    # do with the error. Also reports to tbops.
    #
    if ($retval < 0) {
        SUEXECERROR(SUEXEC_ACTION_CONTINUE);
    }
    # User error. Tell user and exit.
    if ($retval) {
        SUEXECERROR(SUEXEC_ACTION_USERERROR);
        PAGEFOOTER();
        return;
    }
    #
    # Okay, lets zap back to the root, unless this was the root.
    #
    if ($template->IsRoot()) {
        PAGEREPLACE(CreateURL("showuser", $this_user));
    } else {
        PAGEREPLACE("template_show.php?guid={$guid}&version=1");
    }
    return;
}
#
# Standard Testbed Header after argument checking.
Пример #4
0
 function EditImageid($image, $args, &$errors)
 {
     global $suexec_output, $suexec_output_array;
     #
     # Generate a temporary file and write in the XML goo.
     #
     $xmlname = tempnam("/tmp", "editimageid");
     if (!$xmlname) {
         TBERROR("Could not create temporary filename", 0);
         $errors[] = "Transient error(1); please try again later.";
         return null;
     }
     if (!($fp = fopen($xmlname, "w"))) {
         TBERROR("Could not open temp file {$xmlname}", 0);
         $errors[] = "Transient error(2); please try again later.";
         return null;
     }
     # Add these. Maybe caller should do this?
     $args["imageid"] = $image->imageid();
     fwrite($fp, "<image>\n");
     foreach ($args as $name => $value) {
         fwrite($fp, "<attribute name=\"{$name}\">");
         fwrite($fp, "  <value>" . htmlspecialchars($value) . "</value>");
         fwrite($fp, "</attribute>\n");
     }
     fwrite($fp, "</image>\n");
     fclose($fp);
     chmod($xmlname, 0666);
     $retval = SUEXEC("nobody", "nobody", "webeditimageid {$xmlname}", SUEXEC_ACTION_IGNORE);
     if ($retval) {
         if ($retval < 0) {
             $errors[] = "Transient error(3, {$retval}); please try again later.";
             SUEXECERROR(SUEXEC_ACTION_CONTINUE);
         } else {
             # unlink($xmlname);
             if (count($suexec_output_array)) {
                 for ($i = 0; $i < count($suexec_output_array); $i++) {
                     $line = $suexec_output_array[$i];
                     if (preg_match("/^([-\\w]+):\\s*(.*)\$/", $line, $matches)) {
                         $errors[$matches[1]] = $matches[2];
                     } else {
                         $errors[] = $line;
                     }
                 }
             } else {
                 $errors[] = "Transient error(4, {$retval}); please try again later.";
             }
         }
         return null;
     }
     # There are no return value(s) to parse at the end of the output.
     # Unlink this here, so that the file is left behind in case of error.
     # We can then create the image by hand from the xmlfile, if desired.
     #unlink($xmlname);
     return true;
 }
Пример #5
0
 function NewNewUser($flags, $args, &$error)
 {
     global $suexec_output, $suexec_output_array;
     $typearg = "";
     if ($flags & TBDB_NEWACCOUNT_PROJLEADER) {
         $typearg = "-t leader";
     } elseif ($flags & TBDB_NEWACCOUNT_WIKIONLY) {
         $typearg = "-t wikionly";
     } elseif ($flags & TBDB_NEWACCOUNT_WEBONLY) {
         $typearg = "-t webonly";
     }
     if (!($xmlname = User::NewNewUserXML($args, $error))) {
         return null;
     }
     $retval = SUEXEC("nobody", "nobody", "webnewuser {$typearg} {$xmlname}", SUEXEC_ACTION_IGNORE);
     if ($retval) {
         if ($retval < 0) {
             $error = "Transient error(3, {$retval}); please try again later.";
             SUEXECERROR(SUEXEC_ACTION_CONTINUE);
         } else {
             $error = $suexec_output;
         }
         return null;
     }
     #
     # Parse the last line of output. Ick.
     #
     unset($matches);
     if (!preg_match("/^User\\s+(\\w+)\\/(\\d+)\\s+/", $suexec_output_array[count($suexec_output_array) - 1], $matches)) {
         $error = "Transient error(4, {$retval}); please try again later.";
         SUEXECERROR(SUEXEC_ACTION_CONTINUE);
         return null;
     }
     $uid_idx = $matches[2];
     $newuser = User::Lookup($uid_idx);
     if (!$newuser) {
         $error = "Transient error(5); please try again later.";
         TBERROR("Could not lookup new user {$uid_idx}", 0);
         return null;
     }
     # Unlink this here, so that the file is left behind in case of error.
     # We can then create the user by hand from the xmlfile, if desired.
     unlink($xmlname);
     return $newuser;
 }
Пример #6
0
function DOTIME($instance, $action)
{
    global $guid, $vers, $pid, $unix_pid, $unix_gid, $eid, $uid;
    $message = "";
    $template = $instance->GetTemplate();
    $experiment = $instance->GetExperiment();
    if ($action == "pause") {
        PAGEHEADER("Pause Experiment Time");
        $message = "Pausing experiment runtime";
    } else {
        PAGEHEADER("Continue Experiment Time");
        $message = "Continuing experiment runtime";
    }
    $command_options = "-e {$eid} -a {$action} ";
    #
    # Avoid SIGPROF in child.
    #
    set_time_limit(0);
    echo $instance->ExpPageHeader();
    echo "<br><br>\n";
    echo "<script type='text/javascript' language='javascript' " . "        src='template_sup.js'>\n";
    echo "</script>\n";
    STARTBUSY($message);
    #
    # Run the backend script.
    #
    $retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_exprun {$command_options} {$guid}/{$vers}", SUEXEC_ACTION_IGNORE);
    HIDEBUSY();
    #
    # Fatal Error. Report to the user, even though there is not much he can
    # do with the error. Also reports to tbops.
    #
    if ($retval < 0) {
        SUEXECERROR(SUEXEC_ACTION_CONTINUE);
    }
    # User error. Tell user and exit.
    if ($retval) {
        SUEXECERROR(SUEXEC_ACTION_USERERROR);
        return;
    }
    PAGEREPLACE(CreateURL("showexp", $experiment));
}
Пример #7
0
 function NewOSID($user, $project, $osname, $args, &$errors)
 {
     global $suexec_output, $suexec_output_array;
     #
     # Generate a temporary file and write in the XML goo.
     #
     $xmlname = tempnam("/tmp", "newosid");
     if (!$xmlname) {
         TBERROR("Could not create temporary filename", 0);
         $errors[] = "Transient error(1); please try again later.";
         return null;
     }
     if (!($fp = fopen($xmlname, "w"))) {
         TBERROR("Could not open temp file {$xmlname}", 0);
         $errors[] = "Transient error(2); please try again later.";
         return null;
     }
     # Add these. Maybe caller should do this?
     $args["osname"] = $osname;
     $args["pid"] = $project->pid();
     fwrite($fp, "<osid>\n");
     foreach ($args as $name => $value) {
         fwrite($fp, "<attribute name=\"{$name}\">");
         fwrite($fp, "  <value>" . htmlspecialchars($value) . "</value>");
         fwrite($fp, "</attribute>\n");
     }
     fwrite($fp, "</osid>\n");
     fclose($fp);
     chmod($xmlname, 0666);
     $retval = SUEXEC("nobody", "nobody", "webnewosid {$xmlname}", SUEXEC_ACTION_IGNORE);
     if ($retval) {
         if ($retval < 0) {
             $errors[] = "Transient error(3, {$retval}); please try again later.";
             SUEXECERROR(SUEXEC_ACTION_CONTINUE);
         } else {
             # unlink($xmlname);
             if (count($suexec_output_array)) {
                 for ($i = 0; $i < count($suexec_output_array); $i++) {
                     $line = $suexec_output_array[$i];
                     if (preg_match("/^([-\\w]+):\\s*(.*)\$/", $line, $matches)) {
                         $errors[$matches[1]] = $matches[2];
                     } else {
                         $errors[] = $line;
                     }
                 }
             } else {
                 $errors[] = "Transient error(4, {$retval}); please try again later.";
             }
         }
         return null;
     }
     #
     # Parse the last line of output. Ick.
     #
     unset($matches);
     if (!preg_match("/^OSID\\s+([^\\/]+)\\/(\\d+)\\s+/", $suexec_output_array[count($suexec_output_array) - 1], $matches)) {
         $errors[] = "Transient error(5); please try again later.";
         SUEXECERROR(SUEXEC_ACTION_CONTINUE);
         return null;
     }
     $osid = $matches[2];
     $newosid = OSinfo::Lookup($osid);
     if (!$newosid) {
         $errors[] = "Transient error(6); please try again later.";
         TBERROR("Could not lookup new osid {$osid}", 0);
         return null;
     }
     # Unlink this here, so that the file is left behind in case of error.
     # We can then create the osid by hand from the xmlfile, if desired.
     unlink($xmlname);
     return $newosid;
 }
Пример #8
0
 function NewNewProject($args, &$error)
 {
     global $suexec_output, $suexec_output_array;
     #
     # Generate a temporary file and write in the XML goo.
     #
     $xmlname = tempnam("/tmp", "newproj");
     if (!$xmlname) {
         TBERROR("Could not create temporary filename", 0);
         $error = "Transient error(1); please try again later.";
         return null;
     }
     if (!($fp = fopen($xmlname, "w"))) {
         TBERROR("Could not open temp file {$xmlname}", 0);
         $error = "Transient error(2); please try again later.";
         return null;
     }
     fwrite($fp, "<project>\n");
     foreach ($args as $name => $value) {
         fwrite($fp, "<attribute name=\"{$name}\">");
         fwrite($fp, "  <value>" . htmlspecialchars($value) . "</value>");
         fwrite($fp, "</attribute>\n");
     }
     fwrite($fp, "</project>\n");
     fclose($fp);
     chmod($xmlname, 0666);
     $retval = SUEXEC("nobody", "nobody", "webnewproj {$xmlname}", SUEXEC_ACTION_IGNORE | SUEXEC_ACTION_MAIL_TBLOGS);
     if ($retval) {
         if ($retval < 0) {
             $error = "Transient error(3, {$retval}); please try again later.";
             SUEXECERROR(SUEXEC_ACTION_CONTINUE);
         } else {
             $error = $suexec_output;
         }
         return null;
     }
     #
     # Parse the last line of output. Ick.
     #
     unset($matches);
     if (!preg_match("/^Project\\s+([-\\w]+)\\/(\\d+)\\s+/", $suexec_output_array[count($suexec_output_array) - 1], $matches)) {
         $error = "Transient error(4, {$retval}); please try again later.";
         SUEXECERROR(SUEXEC_ACTION_CONTINUE);
         return null;
     }
     $pid_idx = $matches[2];
     $newproj = Project::Lookup($pid_idx);
     if (!$newproj) {
         $error = "Transient error(5); please try again later.";
         TBERROR("Could not lookup new project {$pid_idx}", 0);
         return null;
     }
     # Unlink this here, so that the file is left behind in case of error.
     # We can then create the project by hand from the xmlfile, if desired.
     unlink($xmlname);
     return $newproj;
 }