From: Stefan Schantl Date: Mon, 18 Jan 2016 12:50:43 +0000 (+0100) Subject: Validate configured LogLevel when reading-in the config file. X-Git-Tag: 2.0~51 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=43ab646af96f6de5ba820a38c0c5c5f5ff5ba7dc Validate configured LogLevel when reading-in the config file. Signed-off-by: Stefan Schantl --- diff --git a/modules/Config.pm b/modules/Config.pm index 569b2ce..038ba35 100644 --- a/modules/Config.pm +++ b/modules/Config.pm @@ -153,7 +153,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 diff --git a/modules/Logger.pm b/modules/Logger.pm index 270a059..dbd3a81 100644 --- a/modules/Logger.pm +++ b/modules/Logger.pm @@ -91,7 +91,7 @@ sub Log ($$) { ## This really simple function just returns the hash which ## contains all supported log levels. # -sub LogLevels () { +sub GetLogLevels () { # Nothing to do, just return the loglevels hash. return %loglevels; }