Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for Web-Interface modifying config-file

Tags:

php

For a new project, I have to write a webinterface, which has the capability of modifying a configuration file. The system this will run on is a standard debian installation with apache and php5. The only idea I came up with so far, is to write small c programms, setting the setuid bit to root and supplying the string to be inserted in the config file as a parameter. However I really have a bad feeling about this, since I would rather avoid any setuid programms in my system, for security reasons. Unfortunatelly, the programm to witch the config file belongs refuses to start, if the config file hasn't exclusive root permissions.

How do projects like webmin adress this issue? I would really appreciate some best-practice tipps, of how to implement this.

Thanks in advance

like image 791
ftiaronsem Avatar asked Aug 07 '26 16:08

ftiaronsem


1 Answers

You don't need the Web server to write this file at all. In fact, that just seems like a very bad idea altogether. I'm assuming that this is an Intranet-only website? IF it were me I'd simply store the public key in a database and later have a cron job script come through and validate the certificate and then insert it. Sure, the script has to run as root (stick it in the root's crontab) but you don't have to lose sleep about your webserver writing to files with root permissions. :)

like image 73
Bretticus Avatar answered Aug 09 '26 06:08

Bretticus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!