From: David Tardon Date: Fri, 5 Jan 2024 14:45:04 +0000 (+0100) Subject: udev-util: use config. parser to parse udev.conf X-Git-Tag: v256-rc1~1183^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07f5e35fe7967c824a87f18a3a1d3c22e5be70f5;p=thirdparty%2Fsystemd.git udev-util: use config. parser to parse udev.conf --- diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index cf28ba86479..5ea03d6740c 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -5,6 +5,7 @@ #include #include "alloc-util.h" +#include "conf-parser.h" #include "device-nodes.h" #include "device-private.h" #include "device-util.h" @@ -45,20 +46,27 @@ int udev_set_max_log_level(char *str) { } int udev_parse_config(void) { - _cleanup_free_ char *log_val = NULL; - int r; + int r, log_val = -1; + const ConfigTableItem config_table[] = { + { NULL, "udev_log", config_parse_log_level, 0, &log_val }, + {} + }; - r = parse_env_file(NULL, "/etc/udev/udev.conf", - "udev_log", &log_val); + r = config_parse_config_file_full( + "udev.conf", + "udev", + /* sections = */ NULL, + config_item_table_lookup, + config_table, + CONFIG_PARSE_WARN, + /* userdata = */ NULL); if (r == -ENOENT) return 0; if (r < 0) return r; - r = udev_set_max_log_level(log_val); - if (r < 0) - log_syntax(NULL, LOG_WARNING, "/etc/udev/udev.conf", 0, r, - "Failed to set udev log level '%s', ignoring: %m", log_val); + if (log_val >= 0) + log_set_max_level(log_val); return 0; }