plasmatwin
Programmer
ok, I am doing a web based admin system for a little project I am working on. To see what I could do as a start I decided to start on reading the iptables rules and formatting them nicely on the page - just to start. I hit a rather large road block though, I need root permissions. I am using the Apache webserver to execute my CGI and I can find next to no documentation on how to SUID. So, here is my simple script that for a start will just read in the currently active firewall configuration and print it.
Ofcourse the script fails because I don't have root privilages, help?
Code:
#!/usr/bin/perl -w
print "Content-type: text/plain\n\n";
if(!open(FIREWALL, `iptables-save`)) { print "ARG!!"; die "Can\'t open Iptables save file"; }
my @firewall = <FIREWALL>;
close(FIREWALL);
foreach(@firewall)
{
print "$_";
}