[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipcop-svn
Subject:    [Ipcop-svn] SF.net SVN: ipcop:[2404] ipcop/trunk
From:       owes () users ! sourceforge ! net
Date:       2009-01-31 19:33:51
Message-ID: E1LTLbD-0001bh-BL () c3vjzd1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 2404
          http://ipcop.svn.sourceforge.net/ipcop/?rev=2404&view=rev
Author:   owes
Date:     2009-01-31 19:33:51 +0000 (Sat, 31 Jan 2009)

Log Message:
-----------
Add a quick and dirty GUI page that only displays iptables rules. Useful when working \
on the rulesset. At some later stage we can drop or beautify and keep this page and \
helper program.

Modified Paths:
--------------
    ipcop/trunk/config/rootfiles/common/apache
    ipcop/trunk/src/libs/header.pl
    ipcop/trunk/src/misc-progs/Makefile

Added Paths:
-----------
    ipcop/trunk/html/cgi-bin/iptablesgui.cgi
    ipcop/trunk/src/misc-progs/iptableswrapper.c

Modified: ipcop/trunk/config/rootfiles/common/apache
===================================================================
--- ipcop/trunk/config/rootfiles/common/apache	2009-01-30 19:58:07 UTC (rev 2403)
+++ ipcop/trunk/config/rootfiles/common/apache	2009-01-31 19:33:51 UTC (rev 2404)
@@ -68,6 +68,7 @@
 home/httpd/cgi-bin/index.cgi
 home/httpd/cgi-bin/ipinfo.cgi
 home/httpd/cgi-bin/ipsec.cgi
+home/httpd/cgi-bin/iptablesgui.cgi
 #home/httpd/cgi-bin/logs.cgi
 home/httpd/cgi-bin/logs.cgi/config.dat
 home/httpd/cgi-bin/logs.cgi/firewalllog.dat

Added: ipcop/trunk/html/cgi-bin/iptablesgui.cgi
===================================================================
--- ipcop/trunk/html/cgi-bin/iptablesgui.cgi	                        (rev 0)
+++ ipcop/trunk/html/cgi-bin/iptablesgui.cgi	2009-01-31 19:33:51 UTC (rev 2404)
@@ -0,0 +1,111 @@
+#!/usr/bin/perl
+#
+################################################################################
+#
+# IPCop iptables Web-Iface
+#
+# Copyright (C) 2007 Olaf (weizen_42) Westrik
+#
+# This program is free software; you can redistribute it and/or modify it under the \
terms of the GNU General Public License as published by the Free Software Foundation; \
either version 2 of the License, or (at your option) any later version.  +#
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY \
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A \
PARTICULAR PURPOSE. See the GNU General Public License for more details.  +#
+# You should have received a copy of the GNU General Public License along with this \
program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth \
Floor, Boston, MA 02110, USA  +#
+#
+# Dieses Programm ist freie Software. Sie k\xF6nnen es unter den Bedingungen der GNU \
General Public License, wie von der Free Software Foundation ver\xF6ffentlicht, \
weitergeben und/oder modifizieren, entweder gem\xE4\xDF Version 2 der Lizenz oder \
(nach Ihrer Option) jeder sp\xE4teren Version.  +#
+# Die Ver\xF6ffentlichung dieses Programms erfolgt in der Hoffnung, da\xDF es Ihnen \
von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die implizite \
Garantie der MARKTREIFE oder der VERWENDBARKEIT F\xDCR EINEN BESTIMMTEN ZWECK. \
Details finden Sie in der GNU General Public License.  +#
+# Sie sollten ein Exemplar der GNU General Public License zusammen mit diesem \
Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software Foundation, \
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA. +#
+################################################################################
+#
+# $Id$
+#
+# 2007-03 created by weizen_42
+#
+
+use strict;
+
+# enable only the following on debugging purpose
+use warnings;
+use CGI::Carp 'fatalsToBrowser';
+
+use LWP::UserAgent;
+
+require '/usr/lib/ipcop/general-functions.pl';
+require '/usr/lib/ipcop/lang.pl';
+require '/usr/lib/ipcop/header.pl';
+
+my $option_table = '';
+
+
+my %cgiparams=();
+$cgiparams{'ACTION'} = '';              # refresh
+$cgiparams{'TABLE'} = 'filter';         # filter / mangle / nat / raw
+$cgiparams{'CHAIN'} = '';
+&General::getcgihash(\%cgiparams);
+
+
+if ( $cgiparams{'ACTION'} eq $Lang::tr{'refresh'} ) {
+}
+
+&Header::showhttpheaders();
+&Header::openpage('iptables', 1, '');
+&Header::openbigbox('100%', 'left');
+
+foreach my $table ( ("filter", "mangle", "nat", "raw") ) {
+  if ( $cgiparams{'TABLE'} eq $table ) {
+    $option_table = $option_table ."<option value='$table' \
selected='selected'>$table</option>"; +  }
+  else {
+    $option_table = $option_table ."<option value='$table'>$table</option>";
+  }
+}
+
+&Header::openbox('100%', 'left', 'iptables:');
+
+print <<END
+<form method='post' action='$ENV{'SCRIPT_NAME'}'>
+<table width='100%'>
+<tr>
+    <td width='20%' class='base'>Table:</td><td colspan='3'><select \
name='TABLE'>$option_table</select></td> +</tr><tr>
+    <td width='20%' class='base'>Chain:&nbsp;<img src='/blob.gif' alt='*' /></td><td \
colspan='3'><input type='text' name='CHAIN' value='$cgiparams{'CHAIN'}' size='20' \
/></td> +</tr>
+</table>
+<hr />
+<table width='100%'>
+<tr>
+  <td width='70%' class='base' valign='top'><img src='/blob.gif' alt='*' \
/>&nbsp;$Lang::tr{'this field may be blank'}</td> +  <td width='30%'><input \
type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> +</tr>
+</table></form>
+<hr />
+END
+;
+
+my $output = '';
+if ($cgiparams{'CHAIN'} eq '') {
+  $output = `/usr/local/bin/iptableswrapper $cgiparams{'TABLE'} 2>&1`;
+}
+else {
+  $output = `/usr/local/bin/iptableswrapper chain $cgiparams{'TABLE'} \
$cgiparams{'CHAIN'} 2>&1`; +}
+$output = &Header::cleanhtml($output);
+
+(my @lines) = split(/\n/, $output);
+
+print "<pre>";
+foreach my $line ( @lines )
+{
+  $line = substr($line, 0, rindex($line, ' ', 120)) . "\n" . substr($line, \
rindex($line, ' ', 120)) if ( length($line) > 120 ); +  print $line ."\n";
+}
+print "</pre>";
+
+&Header::closebox();
+
+&Header::closebigbox();
+&Header::closepage();


Property changes on: ipcop/trunk/html/cgi-bin/iptablesgui.cgi
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:keywords
   + Id

Modified: ipcop/trunk/src/libs/header.pl
===================================================================
--- ipcop/trunk/src/libs/header.pl	2009-01-30 19:58:07 UTC (rev 2403)
+++ ipcop/trunk/src/libs/header.pl	2009-01-31 19:33:51 UTC (rev 2404)
@@ -147,6 +147,10 @@
         @{$menu{'2.status'}{'subMenu'}},
         [ $Lang::tr{'connections'}, '/cgi-bin/connections.cgi', "IPCop \
$Lang::tr{'connections'}" ]  );
+    push(
+        @{$menu{'2.status'}{'subMenu'}},
+        [ 'iptables', '/cgi-bin/iptablesgui.cgi', "IPCop iptables" ]
+    );
 
     %{$menu{'3.network'}} = (
         'contents'   => $Lang::tr{'network'},

Modified: ipcop/trunk/src/misc-progs/Makefile
===================================================================
--- ipcop/trunk/src/misc-progs/Makefile	2009-01-30 19:58:07 UTC (rev 2403)
+++ ipcop/trunk/src/misc-progs/Makefile	2009-01-31 19:33:51 UTC (rev 2404)
@@ -11,7 +11,7 @@
 	ipcopbkcfg ipcoprscfg installpackage installfcdsl ipsecctrl \
 	setaliases ipcopbackup restartshaping restartntpd \
 	setdate rebuildhosts snortrules conntrack_helper \
-	restartsyslogd logwatch sysinfo openvpnctrl
+	restartsyslogd logwatch sysinfo openvpnctrl iptableswrapper
 
 all : helper.o $(PROGS) $(SUID_PROGS)
 

Added: ipcop/trunk/src/misc-progs/iptableswrapper.c
===================================================================
--- ipcop/trunk/src/misc-progs/iptableswrapper.c	                        (rev 0)
+++ ipcop/trunk/src/misc-progs/iptableswrapper.c	2009-01-31 19:33:51 UTC (rev 2404)
@@ -0,0 +1,46 @@
+/* 
+ * Q&D wrapper for iptables
+ *
+ * This program is distributed under the terms of the GNU General Public
+ * Licence.  See the file COPYING for details.
+ *
+ * Copyright (C) 2007-2008 weizen_42 at ipcop-forum dot de
+ *
+ * $Id$
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include "setuid.h"
+
+
+#define BUFFER_SIZE 1024
+
+char command[BUFFER_SIZE];
+
+int main(int argc, char *argv[])
+{
+    if ( argc < 2 ) {
+        printf("invalid parameter(s)\n");
+        return(1);
+    }
+
+    if (!(initsetuid()))
+		exit(1);
+
+    if ( (argc == 2) && (!strcmp("filter", argv[1]) || !strcmp("mangle", argv[1]) || \
!strcmp("nat", argv[1]) || !strcmp("raw", argv[1])) ) { +        snprintf(command, \
BUFFER_SIZE-1, "/sbin/iptables -t %s --line-numbers -nvL", argv[1]); +    }
+    else if ( (argc == 4) && !strcmp("chain", argv[1]) ) {
+        snprintf(command, BUFFER_SIZE-1, "/sbin/iptables -t %s --line-numbers -nvL \
%s", argv[2], argv[3]); +    }
+
+    safe_system(command);
+
+    return(0);
+}


Property changes on: ipcop/trunk/src/misc-progs/iptableswrapper.c
___________________________________________________________________
Added: svn:keywords
   + Id


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic