#!/usr/bin/suidperl$ENV{PATH} = "";
if($ARGV[0] eq "apache") {
if($ARGV[1] eq "restart") {
$result = `/usr/sbin/apachectl restart`;
print $result;
exit(0);
}
else {
print "-bash: run: command not found\n";
exit(1);
}
}
else {
print "-bash: run: command not found\n";
exit(1);
}
The script is saved in the /usr/sbin folder as
run. However, when I call run apache restart it does, well... nothing! How can I get it to actually execute that command?
My first thought was that apachectl might be confused because you've cleared the PATH. But in my apachectl, all the paths are hardcoded so that seems less likely. YMMV though.
Is your apache configuration in a non-standard place? You may need to add a -d /path/to/it if it is. You can coax the compiled-in path out of Apache by running httpd -V
apachectl restart from the command line things work fine. The funny thing is that I get httpd not running, trying to start when running from the browser! Should I do:
$< = $>;
Seems like it's trying to start apache for the user nobody, even though the perl script is running as root.
Sorry, a little distracted today. ;)