diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2024-01-25 18:30:43 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2024-03-07 18:49:44 +0100 |
commit | e5abff372d028d28d50165358cd48b624cd0c2d2 (patch) | |
tree | deff5a7ab41edcf31dedd391c90f19bc3650c6d0 /src | |
parent | constants: drop duplicated CONF_PATHS defines (diff) | |
download | systemd-e5abff372d028d28d50165358cd48b624cd0c2d2.tar.xz systemd-e5abff372d028d28d50165358cd48b624cd0c2d2.zip |
shared/conf-parser: collapse pkgdir and conf_file args into one
This essentially reverts 5656cdfeeabc16b5489f5ec7a0a36025a2ec1f23. I find it
much easier to understand what is going on when the
path-relative-to-the-search-path is passed in full, instead of being constructed
from two parts, with one of the parts being implicit in some places.
Also, we call 'systemd-analyze cat-config <path>' with <path> with the same
meaning, so this makes the internal and external APIs more consistent.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/main.c | 2 | ||||
-rw-r--r-- | src/coredump/coredump.c | 2 | ||||
-rw-r--r-- | src/home/homed-conf.c | 2 | ||||
-rw-r--r-- | src/journal-remote/journal-remote-main.c | 2 | ||||
-rw-r--r-- | src/journal-remote/journal-upload.c | 2 | ||||
-rw-r--r-- | src/journal/journald-server.c | 6 | ||||
-rw-r--r-- | src/login/logind-core.c | 2 | ||||
-rw-r--r-- | src/network/networkd-conf.c | 2 | ||||
-rw-r--r-- | src/oom/oomd.c | 2 | ||||
-rw-r--r-- | src/pstore/pstore.c | 2 | ||||
-rw-r--r-- | src/resolve/resolved-conf.c | 2 | ||||
-rw-r--r-- | src/shared/conf-parser.c | 10 | ||||
-rw-r--r-- | src/shared/conf-parser.h | 15 | ||||
-rw-r--r-- | src/shared/sleep-config.c | 2 | ||||
-rw-r--r-- | src/shared/udev-util.c | 5 | ||||
-rw-r--r-- | src/timesync/timesyncd-conf.c | 2 |
16 files changed, 24 insertions, 36 deletions
diff --git a/src/core/main.c b/src/core/main.c index 1e66770df0..c7aec5df3b 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -736,7 +736,7 @@ static int parse_config_file(void) { }; if (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM) - (void) config_parse_config_file("system.conf", + (void) config_parse_config_file("systemd/system.conf", "Manager\0", config_item_table_lookup, items, CONFIG_PARSE_WARN, diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 51218fc4c8..4478dd1be2 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -179,7 +179,7 @@ static int parse_config(void) { int r; r = config_parse_config_file( - "coredump.conf", + "systemd/coredump.conf", "Coredump\0", config_item_table_lookup, items, diff --git a/src/home/homed-conf.c b/src/home/homed-conf.c index ffa4bb3bd7..7fec29651d 100644 --- a/src/home/homed-conf.c +++ b/src/home/homed-conf.c @@ -9,7 +9,7 @@ int manager_parse_config_file(Manager *m) { assert(m); - return config_parse_config_file("homed.conf", "Home\0", + return config_parse_config_file("systemd/homed.conf", "Home\0", config_item_perf_lookup, homed_gperf_lookup, CONFIG_PARSE_WARN, m); } diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index 6c09c068c8..221b544fbc 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -746,7 +746,7 @@ static int parse_config(void) { {} }; - return config_parse_config_file("journal-remote.conf", "Remote\0", + return config_parse_config_file("systemd/journal-remote.conf", "Remote\0", config_item_table_lookup, items, CONFIG_PARSE_WARN, NULL); } diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 97b5f929ab..6d080d7370 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -531,7 +531,7 @@ static int parse_config(void) { {} }; - return config_parse_config_file("journal-upload.conf", "Upload\0", + return config_parse_config_file("systemd/journal-upload.conf", "Upload\0", config_item_table_lookup, items, CONFIG_PARSE_WARN, NULL); } diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index a8c186dc20..fa340da4bb 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1884,12 +1884,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat } static int server_parse_config_file(Server *s) { - const char *conf_file = "journald.conf"; + const char *conf_file; assert(s); if (s->namespace) - conf_file = strjoina("journald@", s->namespace, ".conf"); + conf_file = strjoina("systemd/journald@", s->namespace, ".conf"); + else + conf_file = "systemd/journald.conf"; return config_parse_config_file(conf_file, "Journal\0", config_item_perf_lookup, journald_gperf_lookup, diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 582cbcbea8..50346089ba 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -82,7 +82,7 @@ void manager_reset_config(Manager *m) { int manager_parse_config_file(Manager *m) { assert(m); - return config_parse_config_file("logind.conf", "Login\0", + return config_parse_config_file("systemd/logind.conf", "Login\0", config_item_perf_lookup, logind_gperf_lookup, CONFIG_PARSE_WARN, m); } diff --git a/src/network/networkd-conf.c b/src/network/networkd-conf.c index 063732a3b4..af8d04b4a5 100644 --- a/src/network/networkd-conf.c +++ b/src/network/networkd-conf.c @@ -14,7 +14,7 @@ int manager_parse_config_file(Manager *m) { assert(m); - r = config_parse_config_file("networkd.conf", + r = config_parse_config_file("systemd/networkd.conf", "Network\0" "DHCPv4\0" "DHCPv6\0" diff --git a/src/oom/oomd.c b/src/oom/oomd.c index ecc2eda5dc..a88f57da0a 100644 --- a/src/oom/oomd.c +++ b/src/oom/oomd.c @@ -31,7 +31,7 @@ static int parse_config(void) { {} }; - return config_parse_config_file("oomd.conf", "OOM\0", + return config_parse_config_file("systemd/oomd.conf", "OOM\0", config_item_table_lookup, items, CONFIG_PARSE_WARN, NULL); } diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c index 835348f90e..529193c9e9 100644 --- a/src/pstore/pstore.c +++ b/src/pstore/pstore.c @@ -77,7 +77,7 @@ static int parse_config(void) { {} }; - return config_parse_config_file("pstore.conf", "PStore\0", + return config_parse_config_file("systemd/pstore.conf", "PStore\0", config_item_table_lookup, items, CONFIG_PARSE_WARN, NULL); } diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index 182ac20c3f..f88f295437 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -570,7 +570,7 @@ int manager_parse_config_file(Manager *m) { assert(m); - r = config_parse_config_file("resolved.conf", "Resolve\0", + r = config_parse_config_file("systemd/resolved.conf", "Resolve\0", config_item_perf_lookup, resolved_gperf_lookup, CONFIG_PARSE_WARN, m); if (r < 0) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 40d3675b7e..fba0001242 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -600,9 +600,8 @@ static int config_parse_many_files( /* Parse one main config file located in /etc/$pkgdir and its drop-ins, which is what all systemd daemons * do. */ -int config_parse_config_file_full( +int config_parse_config_file( const char *conf_file, - const char *pkgdir, const char *sections, ConfigItemLookup lookup, const void *table, @@ -614,7 +613,6 @@ int config_parse_config_file_full( int r; assert(conf_file); - assert(pkgdir); /* build the dropin dir list */ dropin_dirs = new0(char*, strv_length(conf_paths) + 1); @@ -628,10 +626,10 @@ int config_parse_config_file_full( STRV_FOREACH(p, conf_paths) { char *d; - d = strjoin(*p, pkgdir, "/", conf_file, ".d"); + d = strjoin(*p, conf_file, ".d"); if (!d) { if (flags & CONFIG_PARSE_WARN) - return log_oom(); + log_oom(); return -ENOMEM; } @@ -642,7 +640,7 @@ int config_parse_config_file_full( if (r < 0) return r; - const char *sysconf_file = strjoina(SYSCONF_DIR, "/", pkgdir, "/", conf_file); + const char *sysconf_file = strjoina(SYSCONF_DIR, "/", conf_file); return config_parse_many_files(STRV_MAKE_CONST(sysconf_file), dropins, sections, lookup, table, flags, userdata, NULL); diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index 3057356479..2c75ba5d8b 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -93,25 +93,14 @@ int config_parse( void *userdata, struct stat *ret_stat); /* possibly NULL */ -int config_parse_config_file_full( - const char *conf_file, - const char *pkgdir, +int config_parse_config_file( + const char *conf_file, /* a path like "systemd/frobnicator.conf" */ const char *sections, /* nulstr */ ConfigItemLookup lookup, const void *table, ConfigParseFlags flags, void *userdata); -static inline int config_parse_config_file( - const char *conf_file, - const char *sections, /* nulstr */ - ConfigItemLookup lookup, - const void *table, - ConfigParseFlags flags, - void *userdata) { - return config_parse_config_file_full(conf_file, "systemd", sections, lookup, table, flags, userdata); -} - int config_parse_many( const char* const* conf_files, /* possibly empty */ const char* const* conf_file_dirs, diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 7282111f49..19b75a706d 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -145,7 +145,7 @@ int parse_sleep_config(SleepConfig **ret) { {} }; - (void) config_parse_config_file("sleep.conf", "Sleep\0", + (void) config_parse_config_file("systemd/sleep.conf", "Sleep\0", config_item_table_lookup, items, CONFIG_PARSE_WARN, NULL); diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index 9acdaeff52..205afc5723 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -28,9 +28,8 @@ int udev_parse_config_full(const ConfigTableItem config_table[]) { assert(config_table); - r = config_parse_config_file_full( - "udev.conf", - "udev", + r = config_parse_config_file( + "udev/udev.conf", /* sections = */ NULL, config_item_table_lookup, config_table, diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c index 9c0b6f7ce1..66f3d177e9 100644 --- a/src/timesync/timesyncd-conf.c +++ b/src/timesync/timesyncd-conf.c @@ -102,7 +102,7 @@ int manager_parse_config_file(Manager *m) { assert(m); - r = config_parse_config_file("timesyncd.conf", "Time\0", + r = config_parse_config_file("systemd/timesyncd.conf", "Time\0", config_item_perf_lookup, timesyncd_gperf_lookup, CONFIG_PARSE_WARN, m); if (r < 0) |