Revision: 2822
          http://ipcop.svn.sourceforge.net/ipcop/?rev=2822&view=rev
Author:   owes
Date:     2009-05-09 22:45:25 +0000 (Sat, 09 May 2009)

Log Message:
-----------
Set debugLevel to 0 and add a method to use debugging through -d command line 
option.

Debugoutput breaks things like ipsecctrl and ovpnctrl when use through the GUI, 
but is very usefull to have around when testing.

Modified Paths:
--------------
    ipcop/trunk/src/scripts/puzzleFwRules.pl

Modified: ipcop/trunk/src/scripts/puzzleFwRules.pl
===================================================================
--- ipcop/trunk/src/scripts/puzzleFwRules.pl    2009-05-09 18:53:30 UTC (rev 
2821)
+++ ipcop/trunk/src/scripts/puzzleFwRules.pl    2009-05-09 22:45:25 UTC (rev 
2822)
@@ -45,7 +45,7 @@
 #      0 - create rules, no print
 #      1 - create rules, print
 #      2 - only print rules
-my $debugLevel = 1;
+my $debugLevel = 0;
 
 #&General::log("BlockOutTraffic: Renew rules");
 # Debug
@@ -80,8 +80,17 @@
 
 &General::readhash($FW::timeframeLogfile, \%timeframeSettings) if (-e 
$FW::timeframeLogfile);
 
-# Check if the iptables rules need an update because of timeframe settings
-if (defined($ARGV[0]) && $ARGV[0] eq '-c') {
+
+if ($#ARGV == -1) {
+    # call without arguments (maybe testing on commandline), run all types
+    @runRuleTypes = @allRuleTypes;
+}
+
+while (@ARGV) {
+my $argument = shift;
+
+if ($argument eq '-c') {
+    # Check if the iptables rules need an update because of timeframe settings
     foreach my $type (@allRuleTypes) {
         print "Should we re-create the $type rules?\n" if ($debugLevel > 0);
         my $noUpdate = 0;
@@ -119,10 +128,10 @@
         }
     }
 }
-elsif (defined($ARGV[0]) && $ARGV[0] eq '-f' && defined($ARGV[1])) {
+elsif (($argument eq '-f') && ($#ARGV >= 0)) {
 
     # force update of one rule type
-    my $type = $ARGV[1];
+    my $type = shift;
 
     push(@runRuleTypes, grep(/^$type$/, @allRuleTypes));
 
@@ -131,7 +140,7 @@
         &General::log("Force update of '$type' rules");
     }
 }
-elsif (defined($ARGV[0]) && $ARGV[0] eq '-a') {
+elsif ($argument eq '-a') {
 
     # force update of all (user & IPCop services) rules
     @runRuleTypes          = @allRuleTypes;
@@ -143,7 +152,7 @@
         &General::log("Force update of all rules");
     }
 }
-elsif (defined($ARGV[0]) && $ARGV[0] eq '-u') {
+elsif ($argument eq '-u') {
 
     # force update of user rules
     @runRuleTypes = @allRuleTypes;
@@ -153,7 +162,7 @@
         &General::log("Force update of user rules");
     }
 }
-elsif (defined($ARGV[0]) && $ARGV[0] eq '-i') {
+elsif ($argument eq '-i') {
 
     $doUpdateIpcopRules = 1;
 
@@ -162,7 +171,7 @@
         &General::log("Force update of services rules");
     }
 }
-elsif (defined($ARGV[0]) && $ARGV[0] eq '-w') {
+elsif ($argument eq '-w') {
 
     $doUpdateWirelessRules = 1;
 
@@ -171,7 +180,10 @@
         &General::log("Force update of BLUE access rules");
     }
 }
-elsif (defined($ARGV[0])) {
+elsif ($argument eq '-d') {
+    $debugLevel++;
+}
+else {
 
     # If we are here, a parameter was given to us that we do not know about.
 
@@ -179,11 +191,9 @@
     # rm -rf /
     # something else ?
 }
-else {
+} # while (@ARGV)
 
-    # call without arguments (maybe testing on commandline), run all types
-    @runRuleTypes = @allRuleTypes;
-}
+
 print "\n--> count: $#runRuleTypes \n\n" if ($debugLevel > 0);
 if ($#runRuleTypes < 0 && $doUpdateIpcopRules == 0 && $doUpdateWirelessRules 
== 0) {
     if ($debugLevel > 0) {


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

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to