Esempio n. 1
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>";
    echo "<blockquote><pre>{$suexec_output}<pre></blockquote>";
Esempio n. 2
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;
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
    echo "emulab_status={$status}\n";
}
# Required arguments
$reqargs = RequiredPageArguments("IP", PAGEARG_STRING, "privkey", PAGEARG_STRING);
$optargs = OptionalPageArguments("hostname", PAGEARG_STRING);
# Must use https,
if (!isset($_SERVER["SSL_PROTOCOL"])) {
    SPITSTATUS(WASTATUS_MUSTUSESSL);
    return;
}
if (!preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/', $IP) || !preg_match('/^[\\w]+$/', $privkey) || isset($hostname) && !preg_match('/^[-\\w\\.]+$/', $hostname)) {
    SPITSTATUS(WASTATUS_INVALIDARGS);
    return;
}
#
# Make sure this is a valid privkey before we invoke the backend.
#
$query_result = DBQueryFatal("select IP from widearea_nodeinfo where privkey='{$privkey}'");
if (!mysql_num_rows($query_result)) {
    SPITSTATUS(WASTATUS_BADPRIVKEY);
    return;
}
#
# Invoke the backend and return the status. We send the IP since cause we
# have to deal with nodes with dynamic IP addresses.
#
$retval = SUEXEC("nobody", $TBADMINGROUP, "webwanodecheckin " . (isset($hostname) ? "-h {$hostname} " : "") . "{$privkey} {$IP}", SUEXEC_ACTION_IGNORE);
if ($retval) {
    SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
SPITSTATUS($retval);
Esempio n. 5
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);
        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);
    }
    # User error. Tell user and exit.
    SUEXECERROR(SUEXEC_ACTION_USERERROR);
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));
}
    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.
if ($retval) {
Esempio n. 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}");
Esempio n. 10
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;
 }
Esempio n. 11
0
        #
        $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();
Esempio n. 12
0
} elseif ($type == "cvsrepo_public") {
    # Must validate the pid since we allow non-admins to do this.
    if (!TBvalid_pid($pid)) {
        PAGEARGERROR("Invalid characters in {$pid}");
    }
    if (!($project = Project::Lookup($pid))) {
        PAGEARGERROR("Project {$pid} is not a valid project!");
    }
    # Must be admin or project/group root.
    if (!$isadmin && !TBMinTrust(TBGrpTrust($uid, $pid, $pid), $TBDB_TRUST_GROUPROOT)) {
        USERERROR("You do not have permission to toggle {$type}!", 1);
    }
    $zapurl = CreateURL("showproject", $project);
    $project->SetCVSRepoPublic($value);
    $unix_pid = $project->unix_gid();
    SUEXEC($uid, $unix_pid, "webcvsrepo_ctrl {$pid}", SUEXEC_ACTION_DIE);
} elseif ($type == "workbench") {
    # Must validate the pid since we allow non-admins to do this.
    if (!TBvalid_pid($pid)) {
        PAGEARGERROR("Invalid characters in {$pid}");
    }
    if (!($project = Project::Lookup($pid))) {
        PAGEARGERROR("Project {$pid} is not a valid project!");
    }
    # Must be admin
    if (!$isadmin) {
        USERERROR("You do not have permission to toggle {$type}!", 1);
    }
    $zapurl = CreateURL("showproject", $project);
    $project->SetAllowWorkbench($value);
} elseif ($type == "hiderun") {
Esempio n. 13
0
 function SetRunAnnotation($this_user, $runidx, $annotation)
 {
     $exptidx = $this->exptidx();
     $annoname = "__experimentrun_annotation_{$exptidx}_{$runidx}";
     $template = $this->template();
     $uid = $this_user->uid();
     $foo = rand();
     $datafile = "/tmp/{$uid}-{$foo}.txt";
     $guid = $template->guid();
     $vers = $template->vers();
     $action = $this->GetRunAnnotation($runidx) ? "modify" : "add";
     if (!($fp = fopen($datafile, "w"))) {
         TBERROR("Could not create temporary file {$datafile}", 1);
     }
     fwrite($fp, $annotation);
     fclose($fp);
     chmod($datafile, 0666);
     SUEXEC($this_user->uid(), $template->UnixGID(), "webtemplate_metadata -a {$action} -f {$datafile} -t annotation " . " {$annoname} {$guid}/{$vers}", SUEXEC_ACTION_CONTINUE);
     unlink($datafile);
     return 0;
 }
    $foo = rand();
    $datafile = "/tmp/{$uid}-{$foo}.txt";
    if (!($fp = fopen($datafile, "w"))) {
        TBERROR("Could not create temporary file {$datafile}", 1);
    }
    fwrite($fp, $formfields["value"]);
    fclose($fp);
    chmod($datafile, 0666);
    $command_opts = " -f {$datafile} {$command_opts}";
}
#
# The backend does the actual work.
#
$pid = $template->pid();
$gid = $template->gid();
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_metadata " . "{$command_opts} {$template_guid}/{$template_vers}", SUEXEC_ACTION_IGNORE);
if ($action != "delete") {
    unlink($datafile);
}
#
# 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;
}
Esempio n. 15
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;
 }
Esempio n. 16
0
        SPITERROR();
    } else {
        header("Content-type: image/png");
        echo "{$data}";
    }
}
#
# If the request did not specify a zoom, return whatever we have.
#
if (!isset($zoom)) {
    SPITGRAPH($template);
    return;
}
#
# Otherwise regen the picture, zooming in or out.
#
$optarg = "-z " . ($zoom == "in" ? "in" : "out");
$pid = $template->pid();
$gid = $template->gid();
$unix_gid = $template->UnixGID();
$project = $template->GetProject();
$unix_pid = $project->unix_gid();
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_graph {$optarg} {$guid}", SUEXEC_ACTION_CONTINUE);
if ($retval) {
    SPITERROR();
} else {
    SPITGRAPH($template);
}
#
# No Footer!
#
Esempio n. 17
0
        while (!feof($fp)) {
            $string = fgets($fp, 1024);
            echo "{$string}";
            flush();
        }
        pclose($fp);
        $fp = 0;
    } else {
        USERERROR("Could not export", 1);
    }
    return;
}
#
# Standard mode ...
#
$retval = SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_export {$export_args}", 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.
if ($retval) {
Esempio n. 18
0
#
if (!preg_match("/^http[s]?:\\/\\/([-\\w\\.]*)\\//", $redirect_to, $matches)) {
    PAGEARGERROR("Invalid redirection argument!");
}
$redirect_host = $matches[1];
#
# Right now all we allow is www.datapository.net, and that is really
# nfs.emulab.net.
#
if ($redirect_host != "www.datapository.net" && $redirect_host != "nfs.emulab.net") {
    PAGEARGERROR("Invalid redirection host '{$redirect_host}'");
}
#
# Okay, now see if the user is logged in. If not, the user will be
# be brought back here after logging in.
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Generate a cookie.
#
$authhash = GENHASH();
#
# Send it over to the server where it will save it.
#
SUEXEC("nobody", "nobody", "xlogin {$redirect_host} {$uid} {$authhash}", SUEXEC_ACTION_DIE);
#
# Now redirect the user over, passing along the hash in the URL.
#
header("Location: {$redirect_to}?user={$uid}&auth={$authhash}");
Esempio n. 19
0
}
#
# Note - this script is not meant to be called by humans! It returns no useful
# information whatsoever, and expects the client to fill in all fields
# properly.
#
$reqargs = RequiredPageArguments("cert", PAGEARG_ANYTHING);
# Silent error if unusually big.
if (strlen($cert) > 0x4000) {
    return;
}
$fname = tempnam("/tmp", "register_ca");
if (!$fname) {
    TBERROR("Could not create temporary filename", 0);
    return;
}
if (!($fp = fopen($fname, "w"))) {
    TBERROR("Could not open temp file {$fname}", 0);
    return;
}
fwrite($fp, $cert);
fclose($fp);
chmod($fname, 0666);
$retval = SUEXEC("geniuser", $TBADMINGROUP, "webcacontrol -w {$fname}", SUEXEC_ACTION_IGNORE);
unlink($fname);
if ($retval) {
    #
    # Want to return status to the caller.
    #
    header("HTTP/1.0 406 Not Acceptable");
}
Esempio n. 20
0
function GraphChange($action, $recursive = 0, $no_output = 0)
{
    global $pid, $unix_gid, $eid, $uid, $guid, $TBSUEXEC_PATH, $TBADMINGROUP;
    global $template, $unix_pid;
    $html = "";
    $reqarg = "-a ";
    $versarg = $template->vers();
    if ($action == "zoomout" || $action == "zoomin") {
        $optarg = "";
        if ($action == "zoomin") {
            $optarg = "-z in";
        } else {
            $optarg = "-z out";
        }
        # Need to update the template graph.
        SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_graph {$optarg} {$guid}", SUEXEC_ACTION_DIE);
    } else {
        $optarg = $recursive ? "-r" : "";
        if ($action == "showtemplate") {
            $reqarg .= "show";
        } elseif ($action == "hidetemplate") {
            $reqarg .= "hide";
        } elseif ($action == "showhidden") {
            $reqarg .= "showhidden";
            # Applies only to root template
            $versarg = "1";
        } elseif ($action == "hidehidden") {
            $reqarg .= "hidehidden";
            # Applies only to root template
            $versarg = "1";
        } elseif ($action == "activate") {
            $reqarg .= "activate";
        } elseif ($action == "inactivate") {
            $reqarg .= "inactivate";
        } else {
            PAGEARGERROR("Invalid action {$action}");
            return;
        }
        $reqarg .= " {$guid}/{$versarg}";
        SUEXEC($uid, "{$unix_pid},{$unix_gid}", "webtemplate_control {$reqarg} {$optarg}", SUEXEC_ACTION_DIE);
    }
    $template->Refresh();
    $html = "";
    if (!$no_output) {
        $html = Show("graph", 0, 0);
    }
    return $html;
}
Esempio n. 21
0
}
#
# 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.
#
if ($retval < 0) {
    SUEXECERROR(SUEXEC_ACTION_CONTINUE);
}
# User error. Tell user and exit.
if ($retval) {
Esempio n. 22
0
    $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();
?>


Esempio n. 23
0
#
# 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);
    return;
}
#
# We need to locate this instance for STARTLOG() below.