Web Hosting Talk







View Full Version : PHP Script To Restart Apache & Named - PlesK


SynHost
02-10-2003, 01:48 PM
Hi -

I need a method to have a PHP script (apache module, not external binary) restart Apache and Named - I've been able to make the script change some system files, but now it needs to restart Apache and Named - Note that this will not be on a hosting environment, the script owner has full and sole control over the server. I've tried reading up a bit about setuid and setgui wrappers but I'm not sure I really understand them - Plus most of them seem like they need PHP to be run as a binary. Could I just write a simple shell script that restarts both owner=root and use the sticky bit and then just use PHP's system?

Any input on this is appreciated.

Thanks,
Ben

luxline
02-10-2003, 02:20 PM
Youd have to use suid OR have a separate apache installation on a different port/ip running as root.

Personally I'd go with the apache/root rather than suid, despite all the security warnings about doing so. I also dont like suid because it doesnt do what its supposed to, I can see you're having the same problem!

If its just for apahce/bind ok, but Im sure you're going to need it for something else further down the road, so go with the apache/root solution.

SynHost
02-10-2003, 02:50 PM
No, thats literally all I need it for - I'm not developing a control panel. I can't imagine with all the computer innovation it would require a new compilation of Apache running as root just to execute a darn script.

By "using suid", do you mean just set the sticky bit for a script owned as root?

darksoul
02-10-2003, 02:52 PM
suid doesn't work for scripts,
the best solution is sudo it will save you of a lot of trouble

SynHost
02-10-2003, 03:07 PM
Ok, so what should I do then?

darksoul
02-10-2003, 03:16 PM
sudo
its a program that allows you to execute commands as root
you can use it in your scripts

SynHost
02-10-2003, 04:03 PM
So just a system() call to "sudo" will run a script as root? how does it authenticate?

darksoul
02-10-2003, 04:09 PM
/etc/sudoers controls it
you can setup it with NOPASSWD
for only those two commands

SynHost
02-10-2003, 04:36 PM
Ok Great! Thanks for the help