DangerIsGo
2[H]4U
- Joined
- Apr 16, 2005
- Messages
- 3,000
To make this absolutely clear, I need to start from the beginning.
I have a dc++ server running on my nix box. To start it i do
sudo dbhub <commands>
and it starts it from /home/me/.dbhub
There is a file in there called reglist which is write and read protected only by root (chmod 600) as are some other files that the hub software uses and checks on a constant basis (every 2-3 minutes). Now. I have a pop3 php file which is automatically run every few minutes by cron under sudo ... because it has this line of code in it:
exec("sudo chmod 755 /home/me/.dbhub/reglist");
So I can add that user to the reglist for the hub.
With me so far?
The next piece of code (new php file) is somewhat different. In this case, the code is NOT run by cron and is executed when a user clicks submit (its a change password form...they enter their username, old pass, and newpass and if all is good, it changes the password in the reglist file with sed). The problem is....this code is NOT given sudo permission when executed. It just runs. I have these lines of code in it:
exec("sudo chmod 755 /home/me/.dbhub/reglist");
exec("sed -i <change line in reglist>");
exec("sudo <run perl script>");
That i need executed as sudo. How would I go about that with apache, php and the file permissions of linux? If I chmod 755 the reglist file from a regular terminal, the file will go back to 600 every 2-3 minutes which defeats the purpose of this change form.
In a nutshell, how would i give write permissions to that file when submit is pressed whith those lines of code? Thanks.
I have a dc++ server running on my nix box. To start it i do
sudo dbhub <commands>
and it starts it from /home/me/.dbhub
There is a file in there called reglist which is write and read protected only by root (chmod 600) as are some other files that the hub software uses and checks on a constant basis (every 2-3 minutes). Now. I have a pop3 php file which is automatically run every few minutes by cron under sudo ... because it has this line of code in it:
exec("sudo chmod 755 /home/me/.dbhub/reglist");
So I can add that user to the reglist for the hub.
With me so far?
The next piece of code (new php file) is somewhat different. In this case, the code is NOT run by cron and is executed when a user clicks submit (its a change password form...they enter their username, old pass, and newpass and if all is good, it changes the password in the reglist file with sed). The problem is....this code is NOT given sudo permission when executed. It just runs. I have these lines of code in it:
exec("sudo chmod 755 /home/me/.dbhub/reglist");
exec("sed -i <change line in reglist>");
exec("sudo <run perl script>");
That i need executed as sudo. How would I go about that with apache, php and the file permissions of linux? If I chmod 755 the reglist file from a regular terminal, the file will go back to 600 every 2-3 minutes which defeats the purpose of this change form.
In a nutshell, how would i give write permissions to that file when submit is pressed whith those lines of code? Thanks.