RE: [PHP] running commands as root from a script
Good day, A bit off topic, but you can run a Perl script setuid. You have to pass a flag to Perl to let it know that it's OK, though (it's -U, I believe) which would appear in your first she-bang line. I've never had to run a PHP script setuid. I would imagine that one would have to write it CGI-like instead of via the server module. Darren Gamble Planner, Regional Services Shaw Cablesystems GP 630 - 3rd Avenue SW Calgary, Alberta, Canada T2P 4L4 (403) 781-4948 -Original Message- From: Ken Nagorski [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 10:37 AM To: [EMAIL PROTECTED] Subject: [PHP] running commands as root from a script Hi there, I have a little problem. I need to run a few commands for Courier from a script. What I have is a php based application that makes it easy to create and manage virtual domains and the addresses for them from the web. However when You Apply the changes everything is written to /tmp dir and the a little perl script parses the file and moves things where they need to go and then runs couriers makealiases command. Now you can't run a perl script SUID so I wrote a C program that just calls system() and runs the script and it is SUID. This doens't work however. No matter what I do. It is like Courier ignores this. I can't imagine there isn't anyone who has not run into the problem of automating things via PHP and not had to run a system command as root at some point in time. I am wondering what the different approaches to this problem are. Thanks Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running commands as root from a script
On Friday 29 March 2002 01:44, Darren Gamble wrote: Good day, A bit off topic, but you can run a Perl script setuid. You have to pass a flag to Perl to let it know that it's OK, though (it's -U, I believe) which would appear in your first she-bang line. I've never had to run a PHP script setuid. I would imagine that one would have to write it CGI-like instead of via the server module. Some systems disable setuid Perl scripts (RH for example). The only way to enable it is to recompile Perl. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Whenever I hear anyone arguing for slavery, I feel a strong impulse to see it tried on him personally. -- Abraham Lincoln */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running commands as root from a script
I have done a similar thing by executing another script via sudo using the PHP command passthru() (or you could use exec(), system(), whatever's appropriate). See http://www.courtesan.com/sudo/ for more info. The whole setup was (and is) a bit of a kluge, but the script didn't need to be run often so it doesn't impact server performance any. -steve At 09:37 AM 3/28/02 , Ken Nagorski wrote: Hi there, I have a little problem. I need to run a few commands for Courier from a script. What I have is a php based application that makes it easy to create and manage virtual domains and the addresses for them from the web. However when You Apply the changes everything is written to /tmp dir and the a little perl script parses the file and moves things where they need to go and then runs couriers makealiases command. Now you can't run a perl script SUID so I wrote a C program that just calls system() and runs the script and it is SUID. This doens't work however. No matter what I do. It is like Courier ignores this. I can't imagine there isn't anyone who has not run into the problem of automating things via PHP and not had to run a system command as root at some point in time. I am wondering what the different approaches to this problem are. Thanks Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ++ | Steve Edberg [EMAIL PROTECTED] | | Database/Programming/SysAdmin(530)754-9127 | | University of California, Davis http://pgfsun.ucdavis.edu/ | +-- Gort, Klaatu barada nikto! --+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php