SPITFORM($formfields, $errors);
        PAGEFOOTER();
        exit(1);
    }
    chmod($thensfile, 0666);
}
#
# Grab the unix GID for running scripts.
#
$unix_gid = $group->unix_gid();
$unix_pid = $project->unix_gid();
# Okay, we can spit back a header now that there is no worry of redirect.
PAGEHEADER("Create an Experiment Template");
echo "<script type='text/javascript' language='javascript' " . "        src='template_sup.js'>\n";
echo "</script>\n";
STARTBUSY("Starting template creation!");
# And run that script!
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_create -E {$description} " . "-g {$gid} {$pid} {$tid} {$thensfile}", SUEXEC_ACTION_IGNORE);
if ($deletensfile) {
    unlink($thensfile);
}
/* Clear the various 'loading' indicators. */
HIDEBUSY();
if ($retval) {
    #
    # 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);
    }
    $error = "UID: Must supply a new UID";
} elseif (!TBvalid_uid($new_uid)) {
    $error = "UID: " . TBFieldErrorString();
} elseif (User::Lookup($new_uid) || posix_getpwnam($new_uid)) {
    $error = "UID: Already in use. Pick another";
}
if ($error) {
    SPITFORM($target_user, $new_uid, $error);
    return;
}
#
# Standard Testbed Header.
#
PAGEHEADER("Change login UID for user");
# Okay, call out to backend to change.
STARTBUSY("Changing UID");
#
# Run the backend script.
#
SUEXEC($uid, $TBADMINGROUP, "webchangeuid {$target_idx} {$new_uid}", SUEXEC_ACTION_USERERROR);
# Stop the busy indicator and zap to user page.
STOPBUSY();
PAGEREPLACE(CreateURL("showuser", $target_user));
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>


    echo "<b><input type=submit name=canceled value=Cancel></b>\n";
    echo "</form>\n";
    echo "</center>\n";
    PAGEFOOTER();
    return;
}
#
# Avoid SIGPROF in child.
#
set_time_limit(0);
PAGEHEADER("Create Template from Instance");
echo $instance->ExpPageHeader();
echo "<br><br>\n";
echo "<script type='text/javascript' language='javascript' " . "        src='template_sup.js'>\n";
echo "</script>\n";
STARTBUSY("Starting commit");
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_commit -e {$eid} {$guid}/{$vers}", SUEXEC_ACTION_IGNORE);
/* Clear the 'loading' indicators above */
if ($retval) {
    CLEARBUSY();
} else {
    STOPBUSY();
}
#
# 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.
}
#
# See if this request is to the above function. Does not return
# if it is. Otherwise return and continue on.
#
sajax_handle_client_request();
#
# Active/Inactive is a plain menu link.
#
if (isset($action) && ($action == "activate" || $action == "inactivate")) {
    GraphChange($action, 0, 1);
}
# Delete is just plain special!
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;
    echo "<input type=hidden name=referrer value={$referrer}>\n";
    echo "</form>\n";
    echo "</center>\n";
    PAGEFOOTER();
    return;
}
#
# Avoid SIGPROF in child.
#
set_time_limit(0);
PAGEHEADER("Reconstitute");
echo $template->PageHeader();
echo "<br><br>\n";
echo "<script type='text/javascript' src='template_sup.js'>\n";
echo "</script>\n";
STARTBUSY("Starting Database Reconstitution");
sleep(1);
#
# Run the backend script
#
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_analyze -i {$exptidx} {$guid}/{$vers}", SUEXEC_ACTION_IGNORE);
/* Clear the 'loading' indicators above */
if ($retval) {
    CLEARBUSY();
} else {
    STOPBUSY();
}
#
# Fatal Error. Report to the user, even though there is not much he can
# do with the error. Also reports to tbops.
#
Exemple #6
0
}
if (isset($formfields["exp_linktest"]) && $formfields["exp_linktest"] != "") {
    $linktestarg = "-t " . $formfields["exp_linktest"];
}
#
# Grab the unix GID for running scripts.
#
$unix_pgid = $project->unix_gid();
$unix_ggid = $group->unix_gid();
#
# Run the backend script.
#
# Avoid SIGPROF in child.
#
set_time_limit(0);
STARTBUSY("Starting Experiment");
$retval = SUEXEC($uid, "{$unix_pgid},{$unix_ggid}" . $extragroups, "webbatchexp {$batcharg} -E {$exp_desc} {$exp_swappable} " . "{$linktestarg} -p {$exp_pid} -g {$exp_gid} -e {$exp_id} " . ($nonsfile ? "" : "{$thensfile}"), SUEXEC_ACTION_IGNORE);
HIDEBUSY();
if ($deletensfile) {
    unlink($thensfile);
}
#
# 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) {
    echo "<br>";
if (isset($overwrite) && $overwrite) {
    $overwrite = 1;
} else {
    $overwrite = 0;
}
#
# Avoid SIGPROF in child.
#
set_time_limit(0);
if (!$spew) {
    PAGEHEADER("Template Export");
    echo $template->PageHeader();
    echo "<br><br>\n";
    echo "<script type='text/javascript' language='javascript' " . "        src='template_sup.js'>\n";
    echo "</script>\n";
    STARTBUSY("Starting export");
    sleep(1);
}
#
# A cleanup function to keep the child from becoming a zombie, since
# the script is terminated, but the children are left to roam.
#
$fp = 0;
function SPEWCLEANUP()
{
    global $fp;
    if (!$fp || !connection_aborted()) {
        exit;
    }
    pclose($fp);
    exit;
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));
}
Exemple #9
0
$reqargs = RequiredPageArguments("peer", PAGEARG_STRING);
$optargs = OptionalPageArguments("user", PAGEARG_USER);
$safe_peer = addslashes($peer);
$query_result = DBQueryFatal("select * from emulab_peers " . "where name='{$safe_peer}' or urn='{$safe_peer}'");
if (!mysql_num_rows($query_result)) {
    USERERROR("Unknown peer: {$peer}", 1);
}
$row = mysql_fetch_array($query_result);
$urn = $row['urn'];
$url = $row['weburl'];
#
# Allow admin to xlogin as another user.
#
if (isset($user) && !$this_user->SameUser($user)) {
    if ($isadmin) {
        $uid = $user->uid();
    } else {
        USERERROR("Not allowed to login as another user", 1);
    }
}
STARTBUSY("Contacting peer");
#
# Do the xlogin, which gives us back a hash to stick in the redirect URL.
#
SUEXEC($uid, "nobody", "webmanageremote xlogin " . escapeshellarg($urn) . " {$uid}", SUEXEC_ACTION_DIE);
STOPBUSY();
if (!preg_match("/^(\\w*)\$/", $suexec_output, $matches)) {
    TBERROR($suexec_output, 1);
}
$hash = $matches[1];
PAGEREPLACE("{$url}/peer_login.php?user={$uid}&key={$hash}");
        #
        $tmpfname = tempnam("/tmp", "archive_tag");
        $fp = fopen($tmpfname, "w");
        fwrite($fp, $formfields["message"]);
        fclose($fp);
        chmod($tmpfname, 0666);
        $message = "-m {$tmpfname}";
    }
} else {
    $errors["Message"] = "Please provide a minimal message!";
}
#
# If any errors, respit the form with the current values and the
# error messages displayed. Iterate until happy.
#
if (count($errors)) {
    SPITFORM($formfields, $errors);
    PAGEFOOTER();
    return;
}
STARTBUSY("Revising the record");
SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_revise -t ReviseRecord {$message} {$command} ", SUEXEC_ACTION_DIE);
STOPBUSY();
if (!isset($referrer)) {
    $referrer = CreateURL("instance_show", $instance);
}
PAGEREPLACE($referrer);
#
# Standard Testbed Footer
#
PAGEFOOTER();
    SPITFORM($template, $formfields, $parameters, $errors);
    PAGEFOOTER();
    exit(1);
}
#
# Avoid SIGPROF in child.
#
set_time_limit(0);
# Okay, we can spit back a header now that there is no worry of redirect.
PAGEHEADER("Instantiate Experiment Template");
echo $template->PageHeader();
echo "<font size=+2>, Instance <b>" . MakeLink("project", "pid={$pid}", $pid) . "/" . MakeLink("experiment", "pid={$pid}&eid={$eid}", $eid) . "</b></font>";
echo "<br><br>\n";
echo "<script type='text/javascript' language='javascript' " . "        src='template_sup.js'>\n";
echo "</script>\n";
STARTBUSY("Starting template instantiation!");
#
# Run the backend script.
#
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_instantiate " . "{$command_options} -e {$eid} {$guid}/{$vers}", SUEXEC_ACTION_IGNORE);
HIDEBUSY();
if ($retval) {
    #
    # 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);