]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
guardian: Fix input validation from configfile.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 1 Nov 2014 11:19:54 +0000 (12:19 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sat, 1 Nov 2014 11:19:54 +0000 (12:19 +0100)
config/guardian/guardian

index 948997102b40266a12c4a3c8d91fe078ea15a301..2c1a6dd3b23e77a814dfbc5f572d34a9e79c0aa9 100644 (file)
@@ -517,7 +517,7 @@ sub load_conf {
                next if (/^\s*$/);
 
                # Skip comments.
-               next if (/^#/);
+               next if (/\#/);
 
                # Get loglevel.
                if (/LogLevel\s+(.*)/) {
@@ -589,7 +589,7 @@ sub load_conf {
        }
 
        # Check if a valid LogLevel has been given or use default one (info).
-       if(!$loglevels{$loglevel}) {
+       unless($loglevels{$loglevel}) {
                $loglevel = "info";
        }
 
@@ -601,26 +601,26 @@ sub load_conf {
        }
 
        # Check if our logfile is writeable.
-       if (! -w $logfile) {
+       unless(-w $logfile) {
                print "Warning! Logfile is not writeable! Engaging debug mode, output to STDOUT\n";
                $loglevel = "debug";
                $options{"d"} = 1;
        }
 
        # Check if the BlockCount is a valid number.
-       if (! $blockcount =~ /^\d+$/) {
+       unless($blockcount =~ /^\d+$/) {
                &logger("debug", "Got no or invalid BlockCount from config file. Using default one (5).\n");
                $blockcount = "3";
        }
 
        # Check if PriorityLevel for Snort Alerts has been given.
-       if (! $priority =~ /^\d+$/) {
+       unless($priority =~ /^\d+$/) {
                &logger("debug", "Got no or an invalid PriorityLevel. Using the default one (3).\n");
                $priority = 3;
        }
 
        # Check if guardianctrl is available.
-       if (! -e $guardianctrl) {
+       unless(-e $guardianctrl) {
                print "Error! Could not find $guardianctrl. Exiting. \n";
                exit;
        }