X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=blobdiff_plain;f=modules%2FConfig.pm;h=8da587cde15eb3357add35718f18d1b5ccdce708;hp=9f2fc55c89c2bbe6b769ac8976c40af36e562826;hb=b3dd9bd01dae6081384fb48d4ca8b775debb5c4d;hpb=2aed491c227848297a9e4e7c9a38a087afab95e2 diff --git a/modules/Config.pm b/modules/Config.pm index 9f2fc55..8da587c 100644 --- a/modules/Config.pm +++ b/modules/Config.pm @@ -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 = ) { @@ -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