From d94bab0805cd3007414ee6ff33e2a24d585f1217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 11 Sep 2020 15:42:23 +0200 Subject: [PATCH] systemctl: immediately reject invalid log levels Symbolic names and number in the appropriate range are allowed (log_level_from_string() DTRT already). The target names are more messy, so we leave the verification to the service. --- src/systemctl/systemctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 86de4848a5..4e31dc7889 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -81,6 +81,7 @@ #include "stat-util.h" #include "string-table.h" #include "strv.h" +#include "syslog-util.h" #include "sysv-compat.h" #include "terminal-util.h" #include "tmpfile-util.h" @@ -6307,6 +6308,12 @@ static int log_setting_internal(sd_bus *bus, const BusLocator* bloc, const char int r; if (value) { + if (level) { + if (log_level_from_string(value) < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "\"%s\" is not a valid log level.", value); + } + r = bus_set_property(bus, bloc, level ? "LogLevel" : "LogTarget", &error, "s", value);