Bruce Nik wrote:
Should the following file (if run from [a browser]) reboot the system:     
/var/www/cgi-bin/reboot
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"
echo "<h1>Rebooting now $(shutdown -r now)</h1>"
echo "</body></html>"

It might, but not on a correctly configured system.

The web server account should not have system admin privileges on the machine,
for obvious and basic security reasons.

You might be able to allow it using sudo; you'd just have to make an entry in the sudo config file to allow "apache" or "httpd" or whatever, to use the command "shutdown -r".

I would also change the 2nd last line to:

echo "<h1>Rebooting now...</h1>"
sudo shutdown -r now

e.g., there is no reason to embed the shutdown inside an echo, it wouldn't seem 
to buy you anything.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to