LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-05-2006, 10:29 AM   #1
atomicfire
LQ Newbie
 
Registered: Jul 2006
Posts: 1

Rep: Reputation: 0
Interfacing IPTABLES with PHP


Currently I have a little fedora box doing my routing at home. It secure, fast and powerful, but I need a easy way to forward ports to local machines.

There are two network cards, eth0 and eth1. eth0 is the internet, eth1 is local net with subnet 192.168.100.XXX

I wrote out a little script in PHP to forward ports to it, but in order for PHP (which is on top of Apache, which runs as user apache) to interface with iptables, I needed to add apache to the sudoers file, and use exec() to sudo and execute the iptables command as root.

As you can guess, this is horribly insecure and i'm hoping there was a cleaner or more elegant way to do it. I've seen scripts like the babel.com.au/phpfwgen/ that can do it, i'm not sure how they do it. I tried to go through their code, but its so dirty and hard to follow I gave up after a few hours.

Any thoughts?

thanks

--AtomicFire
 
Old 07-05-2006, 11:50 AM   #2
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 200

Rep: Reputation: 30
If you need to perform some selective piviliged actions from apache level, I'd recommend writing a simple daemon that runs with the privileges you need and receives a commands from unprivileged processes (apache) through something, for example pipe to which apache can write. Then the daemon executes the desired command for apache. This way you can control what operations are permited and what aren't on the level of this daemon and your apache can still run with the lowest possible privileges. It would be easy and efficient with Perl but you can choose whatever you prefer to implement the daemon.
 
  


Reply



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
Php And Iptables Richtown Linux - Newbie 3 04-28-2006 01:57 AM
PHP and IPTABLES Richtown Linux - Newbie 5 04-21-2006 03:21 AM
running iptables from php rookiepaul Linux - Security 20 03-29-2006 08:28 PM
interfacing TI-83 1337 Twinkie Programming 2 10-15-2004 07:09 PM
php and iptables hkerssies Programming 3 10-22-2003 02:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:43 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