Shawn McKenzie wrote:
Matt palermo wrote:
My PHP is running as a user with limited rights. I'd like to execute a command line as a different user. I'm trying to delete a file and the PHP user doesn't have access to do this. I know the username and password for the admin user that has rights to delete a file. Is there a command I can use to make PHP run a delete command as the admin user? If so, how can I do this?

Thanks,

Matt

There are several ways on *nix systems. I would probably write a shell script to do the deletions and setuid of the script to root or a user with rights to delete the files. Then just exec() the shell script.

On winbloze you can use the runas command.

-Shawn

Actually, a quick search shows that many *nix may not let you setuid on
a executable script, so sudo would be an approach. You should be able to setup the apache user in the sudoers file so that it can only run a very specif command, such as 'rm /path/to/file/to/delete'. Then just use that:

exec('sudo rm /path/to/file/to/delete');


-Shawn

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to