Executing shell_exec() as root user
Posted: Thu Feb 11, 2010 3:48 pm
Does anyone have a sample code line that shows the proper and successful use of the shell_exec() function to run as root? I have tried numerous ways to get it to work and I continue to either get permission errors or "sudo: must be setuid root" errors.
Further, is it possible to successfully use shell_exec() as root without having to make tweaks to the server?
Basically I am trying to create a flat text file above the web document root directory and save a few lines of text. Given my web user ("nobody") does not have directory permissions to this location, I am trying to evoke a bash script that I wrote to assist me with my objective. Everything works except the fact that I cannot get shell_exec() to run as root for a moment in order to allow the bash script to do its thing.
Also, storing values in a db table and running a cron task every 1-minute (which seems to be the most popular answer) will not work for me because the file I am trying to create is meant to hold my db connection string credentials. Thus I do not have access to the db at this point in the process.
Further, is it possible to successfully use shell_exec() as root without having to make tweaks to the server?
Basically I am trying to create a flat text file above the web document root directory and save a few lines of text. Given my web user ("nobody") does not have directory permissions to this location, I am trying to evoke a bash script that I wrote to assist me with my objective. Everything works except the fact that I cannot get shell_exec() to run as root for a moment in order to allow the bash script to do its thing.
Also, storing values in a db table and running a cron task every 1-minute (which seems to be the most popular answer) will not work for me because the file I am trying to create is meant to hold my db connection string credentials. Thus I do not have access to the db at this point in the process.