diff options
-rw-r--r-- | src/core/main.c | 11 | ||||
-rw-r--r-- | src/coredump/coredump.c | 2 | ||||
-rw-r--r-- | src/home/homed-conf.c | 9 | ||||
-rw-r--r-- | src/journal-remote/journal-remote-main.c | 9 | ||||
-rw-r--r-- | src/journal-remote/journal-upload.c | 9 | ||||
-rw-r--r-- | src/journal/journald-server.c | 9 | ||||
-rw-r--r-- | src/login/logind-core.c | 9 | ||||
-rw-r--r-- | src/network/networkd-conf.c | 17 | ||||
-rw-r--r-- | src/oom/oomd.c | 9 | ||||
-rw-r--r-- | src/pstore/pstore.c | 9 | ||||
-rw-r--r-- | src/resolve/resolved-conf.c | 9 | ||||
-rw-r--r-- | src/shared/conf-parser.c | 48 | ||||
-rw-r--r-- | src/shared/conf-parser.h | 27 | ||||
-rw-r--r-- | src/shared/sleep-config.c | 9 | ||||
-rw-r--r-- | src/shared/udev-util.c | 5 | ||||
-rw-r--r-- | src/timesync/timesyncd-conf.c | 9 |
16 files changed, 97 insertions, 103 deletions
diff --git a/src/core/main.c b/src/core/main.c index c7aec5df3b..d5c3bf0e46 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -736,11 +736,12 @@ static int parse_config_file(void) { }; if (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM) - (void) config_parse_config_file("systemd/system.conf", - "Manager\0", - config_item_table_lookup, items, - CONFIG_PARSE_WARN, - NULL); + (void) config_parse_standard_file_with_dropins( + "systemd/system.conf", + "Manager\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + /* userdata= */ NULL); else { _cleanup_strv_free_ char **files = NULL, **dirs = NULL; int r; diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 4478dd1be2..b87bc52bde 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -178,7 +178,7 @@ static int parse_config(void) { int r; - r = config_parse_config_file( + r = config_parse_standard_file_with_dropins( "systemd/coredump.conf", "Coredump\0", config_item_table_lookup, diff --git a/src/home/homed-conf.c b/src/home/homed-conf.c index 7fec29651d..3f74096b64 100644 --- a/src/home/homed-conf.c +++ b/src/home/homed-conf.c @@ -9,9 +9,12 @@ int manager_parse_config_file(Manager *m) { assert(m); - return config_parse_config_file("systemd/homed.conf", "Home\0", - config_item_perf_lookup, homed_gperf_lookup, - CONFIG_PARSE_WARN, m); + return config_parse_standard_file_with_dropins( + "systemd/homed.conf", + "Home\0", + config_item_perf_lookup, homed_gperf_lookup, + CONFIG_PARSE_WARN, + m); } DEFINE_CONFIG_PARSE_ENUM(config_parse_default_storage, user_storage, UserStorage, "Failed to parse default storage setting"); diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index 221b544fbc..91cb2eefaa 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -746,9 +746,12 @@ static int parse_config(void) { {} }; - return config_parse_config_file("systemd/journal-remote.conf", "Remote\0", - config_item_table_lookup, items, - CONFIG_PARSE_WARN, NULL); + return config_parse_standard_file_with_dropins( + "systemd/journal-remote.conf", + "Remote\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + /* userdata= */ NULL); } static int help(void) { diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 6d080d7370..327b7bacd7 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -531,9 +531,12 @@ static int parse_config(void) { {} }; - return config_parse_config_file("systemd/journal-upload.conf", "Upload\0", - config_item_table_lookup, items, - CONFIG_PARSE_WARN, NULL); + return config_parse_standard_file_with_dropins( + "systemd/journal-upload.conf", + "Upload\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + /* userdata= */ NULL); } static int help(void) { diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index fa340da4bb..508263046c 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1893,9 +1893,12 @@ static int server_parse_config_file(Server *s) { else conf_file = "systemd/journald.conf"; - return config_parse_config_file(conf_file, "Journal\0", - config_item_perf_lookup, journald_gperf_lookup, - CONFIG_PARSE_WARN, s); + return config_parse_standard_file_with_dropins( + conf_file, + "Journal\0", + config_item_perf_lookup, journald_gperf_lookup, + CONFIG_PARSE_WARN, + /* userdata= */ s); } static int server_dispatch_sync(sd_event_source *es, usec_t t, void *userdata) { diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 50346089ba..e09bb9f2de 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -82,9 +82,12 @@ void manager_reset_config(Manager *m) { int manager_parse_config_file(Manager *m) { assert(m); - return config_parse_config_file("systemd/logind.conf", "Login\0", - config_item_perf_lookup, logind_gperf_lookup, - CONFIG_PARSE_WARN, m); + return config_parse_standard_file_with_dropins( + "systemd/logind.conf", + "Login\0", + config_item_perf_lookup, logind_gperf_lookup, + CONFIG_PARSE_WARN, + /* userdata= */ m); } int manager_add_device(Manager *m, const char *sysfs, bool master, Device **ret_device) { diff --git a/src/network/networkd-conf.c b/src/network/networkd-conf.c index af8d04b4a5..0f7015eb25 100644 --- a/src/network/networkd-conf.c +++ b/src/network/networkd-conf.c @@ -14,14 +14,15 @@ int manager_parse_config_file(Manager *m) { assert(m); - r = config_parse_config_file("systemd/networkd.conf", - "Network\0" - "DHCPv4\0" - "DHCPv6\0" - "DHCP\0", - config_item_perf_lookup, networkd_gperf_lookup, - CONFIG_PARSE_WARN, - m); + r = config_parse_standard_file_with_dropins( + "systemd/networkd.conf", + "Network\0" + "DHCPv4\0" + "DHCPv6\0" + "DHCP\0", + config_item_perf_lookup, networkd_gperf_lookup, + CONFIG_PARSE_WARN, + /* userdata= */ m); if (r < 0) return r; diff --git a/src/oom/oomd.c b/src/oom/oomd.c index a88f57da0a..4f8c12bd54 100644 --- a/src/oom/oomd.c +++ b/src/oom/oomd.c @@ -31,9 +31,12 @@ static int parse_config(void) { {} }; - return config_parse_config_file("systemd/oomd.conf", "OOM\0", - config_item_table_lookup, items, - CONFIG_PARSE_WARN, NULL); + return config_parse_standard_file_with_dropins( + "systemd/oomd.conf", + "OOM\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + /* userdata= */ NULL); } static int help(void) { diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c index 529193c9e9..e2dfc4d1a1 100644 --- a/src/pstore/pstore.c +++ b/src/pstore/pstore.c @@ -77,9 +77,12 @@ static int parse_config(void) { {} }; - return config_parse_config_file("systemd/pstore.conf", "PStore\0", - config_item_table_lookup, items, - CONFIG_PARSE_WARN, NULL); + return config_parse_standard_file_with_dropins( + "systemd/pstore.conf", + "PStore\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + /* userdata= */ NULL); } /* File list handling - PStoreEntry is the struct and diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index f88f295437..b648c3e520 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -570,9 +570,12 @@ int manager_parse_config_file(Manager *m) { assert(m); - r = config_parse_config_file("systemd/resolved.conf", "Resolve\0", - config_item_perf_lookup, resolved_gperf_lookup, - CONFIG_PARSE_WARN, m); + r = config_parse_standard_file_with_dropins( + "systemd/resolved.conf", + "Resolve\0", + config_item_perf_lookup, resolved_gperf_lookup, + CONFIG_PARSE_WARN, + /* userdata= */ m); if (r < 0) return r; diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 3e3e19b67f..74ba6e6d4c 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -595,54 +595,6 @@ static int config_parse_many_files( return 0; } -/* 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( - const char *conf_file, - const char *sections, - ConfigItemLookup lookup, - const void *table, - ConfigParseFlags flags, - void *userdata) { - - _cleanup_strv_free_ char **dropins = NULL, **dropin_dirs = NULL; - char **conf_paths = CONF_PATHS_STRV(""); - int r; - - assert(conf_file); - - /* build the dropin dir list */ - dropin_dirs = new0(char*, strv_length(conf_paths) + 1); - if (!dropin_dirs) { - if (flags & CONFIG_PARSE_WARN) - return log_oom(); - return -ENOMEM; - } - - size_t i = 0; - STRV_FOREACH(p, conf_paths) { - char *d; - - d = strjoin(*p, conf_file, ".d"); - if (!d) { - if (flags & CONFIG_PARSE_WARN) - log_oom(); - return -ENOMEM; - } - - dropin_dirs[i++] = d; - } - - r = conf_files_list_strv(&dropins, ".conf", NULL, 0, (const char**) dropin_dirs); - if (r < 0) - return r; - - const char *sysconf_file = strjoina(SYSCONF_DIR, "/", conf_file); - - return config_parse_many_files(NULL, STRV_MAKE_CONST(sysconf_file), dropins, - sections, lookup, table, flags, userdata, NULL); -} - /* Parse each config file in the directories specified as strv. */ int config_parse_many( const char* const* conf_files, diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index d3c65bbf92..254d6cb70b 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -93,14 +93,6 @@ int config_parse( void *userdata, struct stat *ret_stat); /* possibly NULL */ -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); - int config_parse_many( const char* const* conf_files, /* possibly empty */ const char* const* conf_file_dirs, @@ -125,6 +117,25 @@ int config_parse_standard_file_with_dropins_full( Hashmap **ret_stats_by_path, /* possibly NULL */ char ***ret_dropin_files); /* possibly NULL */ +static inline int config_parse_standard_file_with_dropins( + const char *main_file, /* A path like "systemd/frobnicator.conf" */ + const char *sections, /* nulstr */ + ConfigItemLookup lookup, + const void *table, + ConfigParseFlags flags, + void *userdata) { + return config_parse_standard_file_with_dropins_full( + /* root= */ NULL, + main_file, + sections, + lookup, + table, + flags, + userdata, + /* ret_stats_by_path= */ NULL, + /* ret_dropin_files= */ NULL); +} + int config_get_stats_by_path( const char *suffix, const char *root, diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 19b75a706d..c96f8485dd 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -145,9 +145,12 @@ int parse_sleep_config(SleepConfig **ret) { {} }; - (void) config_parse_config_file("systemd/sleep.conf", "Sleep\0", - config_item_table_lookup, items, - CONFIG_PARSE_WARN, NULL); + (void) config_parse_standard_file_with_dropins( + "systemd/sleep.conf", + "Sleep\0", + config_item_table_lookup, items, + CONFIG_PARSE_WARN, + /* userdata= */ NULL); /* use default values unless set */ sc->allow[SLEEP_SUSPEND] = allow_suspend != 0; diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index 205afc5723..0014b7236f 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -28,11 +28,10 @@ int udev_parse_config_full(const ConfigTableItem config_table[]) { assert(config_table); - r = config_parse_config_file( + r = config_parse_standard_file_with_dropins( "udev/udev.conf", /* sections = */ NULL, - config_item_table_lookup, - config_table, + config_item_table_lookup, config_table, CONFIG_PARSE_WARN, /* userdata = */ NULL); if (r == -ENOENT) diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c index 66f3d177e9..4b1d4ddbfe 100644 --- a/src/timesync/timesyncd-conf.c +++ b/src/timesync/timesyncd-conf.c @@ -102,9 +102,12 @@ int manager_parse_config_file(Manager *m) { assert(m); - r = config_parse_config_file("systemd/timesyncd.conf", "Time\0", - config_item_perf_lookup, timesyncd_gperf_lookup, - CONFIG_PARSE_WARN, m); + r = config_parse_standard_file_with_dropins( + "systemd/timesyncd.conf", + "Time\0", + config_item_perf_lookup, timesyncd_gperf_lookup, + CONFIG_PARSE_WARN, + /* userdata= */ m); if (r < 0) return r; |