LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-27-2005, 10:26 PM   #1
Bassam
Member
 
Registered: Mar 2003
Location: Malaysia
Posts: 63

Rep: Reputation: 15
How to execute iptables command by the user apache ???


Dear All,
I am writing a CGI application for my gateway using Perl programming language on a Linux redhat 9 system, and I have a choice in my application where hosts can be denied our allowed to access the Internet.

I need to call the following iptables commands from my CGI application:
Code:
iptables -t filter -I FORWARD 1 -i eth1 -m mac --mac-source ff:22:23:01:8c:f3 -s 10.0.0.30 -j ACCEPT

iptables -t filter -D FORWARD -i eth1 -m mac --mac-source ff:22:23:01:8c:f3 -s 10.0.0.30 -j ACCEPT
But unfortunately they are not executed and I am getting the following error in my error_log file:

iptables v1.2.7a: can't initialize iptables table `filter': Permission denied (you must be root)

I realized that the user apache of my web server is not privileged to executed this iptables command.

I wonder if there is a way to make the apache user of my apache web server be able to execute this command.

Your help is appreciatiable


Regards
Bassam

Last edited by Bassam; 10-27-2005 at 10:39 PM.
 
Old 10-28-2005, 02:35 AM   #2
ashamril
Member
 
Registered: Jan 2003
Location: cyberjaya
Distribution: rh mdk deb fed suse
Posts: 99

Rep: Reputation: 15
maybe u can try using sudo
 
Old 10-28-2005, 07:10 AM   #3
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
Certainly from php you can use exec("iptables"); if your www-data user is addded to the sudoers file as being able to manipulate ip tables. Would guess it would be the same with your CGI script. Install the sudo package and read the manpage for adding your user.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
boot script execute command as non-root user wampfler Linux - Security 7 09-24-2004 04:56 AM
Execute a command as another user mpgram Linux - Newbie 6 06-08-2004 11:45 PM
Apache : execute pages as different user guideweb Linux - Security 2 03-15-2004 06:41 PM
execute command as different user kilobravo Linux - General 2 06-02-2003 10:03 AM
Ordinary user can execute the "halt" command ederts Linux - Newbie 7 05-24-2001 11:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration