Commit 9f10683e authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Clean up the SUEXEC stuff. I need to change all the calls to SUEXEC

at some point, but default args are the finest!
parent 366c843a
...@@ -137,9 +137,8 @@ function USERERROR($message, $death) { ...@@ -137,9 +137,8 @@ function USERERROR($message, $death) {
$msg = "<font size=+1><br> $msg = "<font size=+1><br>
$message $message
<br>
</font> </font>
<br><br><br><br> <br><br><br>
<font size=-1> <font size=-1>
Please contact $TBMAILADDR if you feel this message is an error. Please contact $TBMAILADDR if you feel this message is an error.
</font>\n"; </font>\n";
...@@ -160,32 +159,78 @@ function FORMERROR($field) { ...@@ -160,32 +159,78 @@ function FORMERROR($field) {
} }
# #
# Run a program as a user. # SUEXEC stuff.
# #
function SUEXEC($uid, $gid, $cmdandargs, $die) { # Save this stuff so we can generate better error messages and such.
global $TBSUEXEC_PATH; #
$suexec_cmdandargs = "";
$suexec_retval = 0;
$suexec_output;
ignore_user_abort(1); #
# Actions for suexec.
#
define("SUEXEC_ACTION_CONTINUE", 0);
define("SUEXEC_ACTION_DIE", 1);
define("SUEXEC_ACTION_USERERROR", 2);
define("SUEXEC_ACTION_IGNORE", 3);
$output = array(); #
$retval = 0; # An suexec error.
$result = exec("$TBSUEXEC_PATH $uid $gid $cmdandargs", #
$output, $retval); function SUEXECERROR($action)
{
global $suexec_cmdandargs, $suexec_retval, $suexec_output;
if ($retval) { $foo = "Shell Program Error. Exit status: $suexec_retval\n";
$foo = "SUEXEC failure: '$uid/$gid $cmdandargs'"; $foo .= " '$suexec_cmdandargs'\n";
if (count($output)) { if (count($suexec_output)) {
$foo = "$foo\nError output:\n\n"; $foo .= "\n";
for ($i = 0; $i < count($output); $i++) { for ($i = 0; $i < count($suexec_output); $i++) {
$foo .= "$output[$i]\n"; $foo .= "$suexec_output[$i]\n";
}
} }
TBERROR($foo, $die, 1);
} }
return $retval; switch ($action) {
case SUEXEC_ACTION_CONTINUE:
TBERROR($foo, 1, 0);
break;
case SUEXEC_ACTION_DIE:
TBERROR($foo, 1, 1);
break;
case SUEXEC_ACTION_USERERROR:
USERERROR("<XMP>$foo</XMP>", 1);
break;
case SUEXEC_ACTION_IGNORE:
break;
default:
TBERROR($foo, 1, 1);
}
}
#
# Run a program as a user.
#
function SUEXEC($uid, $gid, $cmdandargs, $action) {
global $TBSUEXEC_PATH;
global $suexec_cmdandargs, $suexec_retval, $suexec_output;
ignore_user_abort(1);
$suexec_cmdandargs = "$uid $gid $cmdandargs";
$suexec_output = array();
$suexec_retval = 0;
exec("$TBSUEXEC_PATH $suexec_cmdandargs", $suexec_output, $suexec_retval);
#
# The output is still available of course, via $suexec_output.
#
if ($suexec_retval == 0 || $action == SUEXEC_ACTION_IGNORE) {
return $suexec_retval;
}
SUEXECERROR($action);
} }
function ADDPUBKEY($uid, $cmdandargs) { function ADDPUBKEY($uid, $cmdandargs) {
......
Supports Markdown
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