RE: [PHP] How to execute script as root
| From: | Samantha Savvakis | Date: | Tue, 28 Nov 2000 03:57:08 +0000 |
| Subject: | RE: [PHP] How to execute script as root | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27540@lists.php.net to get a copy of this message | ||
You can write a wrapper for the program you want to run. The PHP script uses
"exec(...)" to call the wrapper program.
The wrapper program calls the script or program you wish to run.
The wrapper program has "chmod u+s" permissions. I just write a simple C
program that is the wrapper. It's only a few lines
****************************************************************************
******
#include <unistd.h>
#define EXECPATH "path_to_script_you_want_to_run"
// eg. /usr/local/apache/htdocs/myscript.php
int main(int argc, char **argv)
{
execv(EXECPATH, argv);
return 1;
}
****************************************************************************
******
The important thing to remember is to change the mode of the wrapper file
"chmod u+s". By setting these permissions, the program will run as the owner
of who owns the wrapper function.
Hope this makes sense.
Sam
> -----Original Message-----
> From: CHIU, Jonathan [mailto:jonathan.chiu@hk.origin-it.com]
> Sent: Tuesday, 28 November 2000 13:44
> To: php-general@lists.php.net
> Subject: [PHP] How to execute script as root
>
>
> Hi,
>
> I want to use our web-email client (written in php) to provide on-line
> account creation service which involves to execute a script to create user
> account in FreeBSD. I think exec() will not do the trick. Can
> anyone give
> me some insights?
>
> Thanks.
>
> Jonathan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>