From: David Tardon Date: Fri, 5 Jan 2024 13:30:37 +0000 (+0100) Subject: conf-parser: generalize config_parse_config_file() X-Git-Tag: v256-rc1~1183^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5656cdfeeabc16b5489f5ec7a0a36025a2ec1f23;p=thirdparty%2Fsystemd.git conf-parser: generalize config_parse_config_file() --- diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 1d201528ace..8eea2235353 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -598,10 +598,11 @@ static int config_parse_many_files( return 0; } -/* Parse one main config file located in /etc/systemd and its drop-ins, which is what all systemd daemons +/* 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( +int config_parse_config_file_full( const char *conf_file, + const char *pkgdir, const char *sections, ConfigItemLookup lookup, const void *table, @@ -613,6 +614,7 @@ int config_parse_config_file( int r; assert(conf_file); + assert(pkgdir); /* build the dropin dir list */ dropin_dirs = new0(char*, strv_length(conf_paths) + 1); @@ -626,7 +628,7 @@ int config_parse_config_file( STRV_FOREACH(p, conf_paths) { char *d; - d = strjoin(*p, "systemd/", conf_file, ".d"); + d = strjoin(*p, pkgdir, "/", conf_file, ".d"); if (!d) { if (flags & CONFIG_PARSE_WARN) return log_oom(); @@ -640,7 +642,7 @@ int config_parse_config_file( if (r < 0) return r; - const char *sysconf_file = strjoina(PKGSYSCONFDIR, "/", conf_file); + const char *sysconf_file = strjoina(SYSCONF_DIR, "/", pkgdir, "/", 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 a1768cd9198..4e0054de5e2 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -93,14 +93,25 @@ int config_parse( void *userdata, struct stat *ret_stat); /* possibly NULL */ -int config_parse_config_file( +int config_parse_config_file_full( const char *conf_file, + const char *pkgdir, 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,