]> git.ipfire.org Git - people/stevee/guardian.git/commitdiff
Validate configured LogLevel when reading-in the config file.
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 18 Jan 2016 12:50:43 +0000 (13:50 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Mon, 18 Jan 2016 12:50:43 +0000 (13:50 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
modules/Config.pm
modules/Logger.pm

index 569b2ceb99da109242265b772d13e66eff9f6795..038ba35b6f625d414743cacbba2c1f8398bad291 100644 (file)
@@ -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
index 270a059944be058c9fc29aeb4375d34dc3829df3..dbd3a815dfed5badbf827e8b004a7cde6d57483a 100644 (file)
@@ -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;
 }