Reputation: 21391
We need some scripts to generate config files for network services such as DHCP, DNS and Network based on user input. These require root access, but I don't know how to run the PHP application as root. It's run through a public web interface.
Upvotes: 1
Views: 1530
Reputation: 449613
Awww... granting root rights to PHP or the web server is never a good practice, no matter how secure your setup.
How about having PHP write the changed configuration files into a temporary directory:
/home/system/transfer/apache/httpd.conf
/home/system/transfer/system/dhcp.conf
/home/system/transfer/mysql/my.ini
and a sudo
cron job running a shell script fetching them from there, and copying them to the proper location (also taking care of restarting services and all that), on a five-minute basis?
It would be a bit safer than having the Web/PHP user write the configuration files directly, plus it would be relatively easy to set up a versioning process that allows to roll back a configuration file to an earlier version.
Upvotes: 6
Reputation: 75629
Instead of giving the PHP script root access, make the configuration files writable by the web user.
Upvotes: 2