Commit 8e6c0141 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Clean up and do the zombie prevention stuff like I did in

sprewlogfile. Also add -w (waitmode) when calling node_reboot so that
user gets to wait until all the nodes come back up.
parent ab8b901f
...@@ -102,38 +102,48 @@ if (!$confirmed) { ...@@ -102,38 +102,48 @@ if (!$confirmed) {
} }
# #
# Pass it off to the script. # For the audit message.
# #
$retval = 0; TBUserInfo($uid, $uid_name, $uid_email);
header("Content-Type: text/plain");
ignore_user_abort(1);
if ($nodemode) { if ($nodemode) {
$result = system("$TBSUEXEC_PATH $uid nobody webnodereboot $node_id", $message = "$node_id was rebooted via the web interface by $uid\n";
$retval); $subject = "Node Reboot: $node_id";
} }
else { else {
$result = system("$TBSUEXEC_PATH $uid nobody webnodereboot -e $pid,$eid", $message = "Nodes in $pid/$eid were rebooted via the web interface ".
$retval); "by $uid\n";
} $subject = "Nodes Rebooted: $pid/$eid";
if ($retval) {
USERERROR("Reboot failed!", 1);
} }
# #
# And send an audit message. # A cleanup function to keep the child from becoming a zombie, since
# the script is terminated, but the children are left to roam.
# #
TBUserInfo($uid, $uid_name, $uid_email); $fp = 0;
function SPEWCLEANUP()
{
global $fp;
if (connection_aborted() && $fp) {
pclose($fp);
}
exit();
}
register_shutdown_function("SPEWCLEANUP");
ignore_user_abort(1);
if ($nodemode) { if ($nodemode) {
$message = "$node_id was rebooted via the web interface by $uid\n"; $fp = popen("$TBSUEXEC_PATH $uid nobody webnodereboot -w $node_id",
$subject = "Node Reboot: $node_id"; "r");
} }
else { else {
$message = "Nodes in $pid/$eid were rebooted via the web interface ". $fp = popen("$TBSUEXEC_PATH $uid nobody webnodereboot -w -e $pid,$eid",
"by $uid\n"; "r");
$subject = "Nodes Rebooted: $pid/$eid"; }
if (! $fp) {
USERERROR("Reboot failed!", 1);
} }
TBMAIL($TBMAIL_AUDIT, TBMAIL($TBMAIL_AUDIT,
...@@ -141,13 +151,18 @@ TBMAIL($TBMAIL_AUDIT, ...@@ -141,13 +151,18 @@ TBMAIL($TBMAIL_AUDIT,
"From: $uid_name <$uid_email>\n". "From: $uid_name <$uid_email>\n".
"Errors-To: $TBMAIL_WWW"); "Errors-To: $TBMAIL_WWW");
# header("Content-Type: text/plain");
# Spit out a redirect so that the history does not include a post header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
# in it. header("Cache-Control: no-cache, must-revalidate");
# header("Pragma: no-cache");
#if ($nodemode) flush();
# header("Location: shownode.php3?node_id=$node_id");
#else while (!feof($fp)) {
# header("Location: showexp.php3?exp_pid=$pid&exp_eid=$eid"); $string = fgets($fp, 1024);
echo "$string";
flush();
}
pclose($fp);
$fp = 0;
?> ?>
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