]> git.ipfire.org Git - people/stevee/guardian.git/blobdiff - modules/Config.pm
Set default FirewallEngine to "none".
[people/stevee/guardian.git] / modules / Config.pm
index 9f2fc55c89c2bbe6b769ac8976c40af36e562826..8da587cde15eb3357add35718f18d1b5ccdce708 100644 (file)
@@ -18,6 +18,7 @@ my %defaults = (
        "LogFacility" => "syslog",
        "BlockCount" => "3",
        "BlockTime" => "86400",
+       "FirewallEngine" => "none",
 );
 
 #
@@ -56,7 +57,7 @@ sub UseConfig ($) {
 
        # If an error message is returned, exit and print the error message.
        } else {
-               die "Invalid configuration: $error\n";
+               die "Invalid configuration: $error";
        }
 }
 
@@ -74,11 +75,11 @@ sub ReadConfig ($) {
 
        # Check if the configfile exists and is read-able.
        unless (-r "$file") {
-                       die "The given configfile ($file) does not exist, or is not read-able: $!\n";
+                       die "The given configfile ($file) does not exist, or is not read-able: $!";
        }
 
        # Open the config file and read-in all configuration options and values.
-       open(CONF, "$file") or die "Could not open $file: $!\n";
+       open(CONF, "$file") or die "Could not open $file: $!";
 
        # Process line by line.
        while (my $line = <CONF>) {
@@ -91,15 +92,14 @@ sub ReadConfig ($) {
                # Remove any newlines.
                chomp($line);
 
-               # Remove any spaces at the start and end of the line.
-               $line =~ s/^\s*//;
-               $line =~ s/\s*$//;
-
                # Check line lenght, skip it, if it is longer than, the
                # allowed maximum.
                my $length = length("$line");
                next if ($length gt $maxlength);
 
+               # Remove any whitespaces.
+               $line=~ s/ //g;
+
                # Splitt line into two parts.
                my ($option, $value) = split (/=/, $line);
 
@@ -154,7 +154,13 @@ sub CheckConfig (\%) {
                }
        }
 
-       # XXX - add check for validating the configured loglevel.
+       # Gather details about supported log levels.
+       my %supported_loglevels = &Guardian::Logger::GetLogLevels();
+
+       # Check if the configured log level is valid.
+       unless (exists ($supported_loglevels{$config{LogLevel}})) {
+               return "Invalid LogLevel: $config{LogLevel}";
+       }
 
        # The config looks good, so return nothing (no error message).
        return undef