Results 1 to 10 of 10
how i can give apache server root permissions?
please help me....
- 06-12-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 38
permissions
how i can give apache server root permissions?
please help me.
- 06-12-2008 #2
You wouldn't want to do that for security reasons. root has access to your entire computer so you don't want people having access so easily.
Why do you want it to have root permissions?Linux User #453176
- 06-13-2008 #3
Set the apache user UID and GID=0 from /etc/passwd, but suffer the consequences
- 06-16-2008 #4Just Joined!
- Join Date
- Apr 2008
- Posts
- 38
i want to give apache root permissions because i want to execute iptables commands through php code.
- 06-16-2008 #5Linux Guru
- Join Date
- Nov 2007
- Posts
- 1,695
I'll have to echo Kieren - this is a *really* bad idea.
As a last resort, use setuid on the iptables command instead.
- 06-17-2008 #6
I would suggest using sudo...
put in sudo:
Then instead of executing iptables directly you will be allowed to execute only the the iptables rules starting with the above example.. this will allow you for an instance to execute from the php script the following:Code:Cmnd_Alias ADD=/usr/sbin/iptables -A FORWARD -j ACCEPT -s Cmnd_Alias DEL=/usr/sbin/iptables -D FORWARD -j ACCEPT -s apache ALL=NOPASSWD: ADD apache ALL=NOPASSWD: DEL
PS: This will be especially secure if you are 100% sure that nothing but:Code:sudo iptables -A FORWARD -j ACCEPT -s 192.168.0.1
is parsed to the system/exec functionsCode:/^\d+\.\d+\.\d+\.\d+$/
- 06-17-2008 #7Linux Guru
- Join Date
- Nov 2007
- Posts
- 1,695
Shyma has ~10 threads about iptables, apache, and php. Most have told him to use sudo - he keeps asking again (I guess) because no one has spelled out the exact code/steps, so I assume he gave up on sudo and is now trying to just make apache run as root.
Maybe Vigour's post will give him new inspiration.
- 06-18-2008 #8
Oh... so it's good to say how to put things in sudo...
Just type:
Or if you are unfamiliar with Vi, edit /etc/sudoers with your favorite text redactor. The good thing of visudo is that it checks for errors on exit.Code:visudo
But anyway.. once you put the above lines in sudo, then you will be able to execute iptables commands (BUT STARTING WITH THE EXACT OPTIONS FROM SUDO) as the apache user...
Good luck..
PS: My only advise is to check the things you add to iptables.
e.g. if you are adding an ip address.. make something like:
Code:preg_match("/^\d+\.\d+\.\d+\.\d+$/",$ipaddress,$match); if($match[0]) { go_to_sudo_execution(); } else { die("Invalid IP address"); }
- 06-29-2008 #9Just Joined!
- Join Date
- Apr 2008
- Posts
- 38
iptables restart
hi
i want to execute this command throgh php
service iptables restart
can you give me steps to do this?
i means that steps to edit sudo.what i should type?
please help me because i try any solution that i find in this forum but i faild.
- 07-07-2008 #10
1. Open the sudo conf file
2. Save the following lines:Code:visudo
3. Execute from the php script:Code:Cmnd_Alias RES=/etc/init.d/httpd restart apache ALL=NOPASSWD: RES
And you should not have any problems restarting the iptables rules.Code:exec("/usr/bin/sudo /etc/init.d/iptables restart");Last edited by vigour; 07-07-2008 at 01:43 PM. Reason: little mistake


Reply With Quote
