1
0
mirror of https://github.com/systemd/systemd.git synced 2025-08-29 01:49:55 +03:00

Merge pull request #27633 from DaanDeMeyer/repart-dropin

repart: Make sure we look up dropin files in the root directory
This commit is contained in:
Luca Boccassi
2023-05-12 21:29:38 +01:00
committed by GitHub
8 changed files with 18 additions and 16 deletions

View File

@ -726,6 +726,7 @@ static int parse_config_file(void) {
(const char* const*) files,
(const char* const*) dirs,
"user.conf.d",
/* root = */ NULL,
"Manager\0",
config_item_table_lookup, items,
CONFIG_PARSE_WARN,

View File

@ -787,7 +787,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
dropin_dirname = strjoina(basename(filename), ".d");
r = config_parse_many(
STRV_MAKE_CONST(filename), NETWORK_DIRS, dropin_dirname,
STRV_MAKE_CONST(filename), NETWORK_DIRS, dropin_dirname, /* root = */ NULL,
NETDEV_COMMON_SECTIONS NETDEV_OTHER_SECTIONS,
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN,
@ -823,7 +823,7 @@ int netdev_load_one(Manager *manager, const char *filename) {
NETDEV_VTABLE(netdev)->init(netdev);
r = config_parse_many(
STRV_MAKE_CONST(filename), NETWORK_DIRS, dropin_dirname,
STRV_MAKE_CONST(filename), NETWORK_DIRS, dropin_dirname, /* root = */ NULL,
NETDEV_VTABLE(netdev)->sections,
config_item_perf_lookup, network_netdev_gperf_lookup,
CONFIG_PARSE_WARN,

View File

@ -493,7 +493,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
};
r = config_parse_many(
STRV_MAKE_CONST(filename), NETWORK_DIRS, dropin_dirname,
STRV_MAKE_CONST(filename), NETWORK_DIRS, dropin_dirname, /* root = */ NULL,
"Match\0"
"Link\0"
"SR-IOV\0"

View File

@ -1638,6 +1638,7 @@ static int partition_read_definition(Partition *p, const char *path, const char
STRV_MAKE_CONST(path),
conf_file_dirs,
dropin_dirname,
arg_definitions ? NULL : arg_root,
"Partition\0",
config_item_table_lookup, table,
CONFIG_PARSE_WARN,
@ -1795,21 +1796,17 @@ static int find_verity_sibling(Context *context, Partition *p, VerityMode mode,
return 0;
}
static int context_read_definitions(
Context *context,
char **directories,
const char *root) {
static int context_read_definitions(Context *context) {
_cleanup_strv_free_ char **files = NULL;
Partition *last = NULL;
int r;
const char *const *dirs;
int r;
assert(context);
dirs = (const char* const*) (directories ?: CONF_PATHS_STRV("repart.d"));
dirs = (const char* const*) (arg_definitions ?: CONF_PATHS_STRV("repart.d"));
r = conf_files_list_strv(&files, ".conf", directories ? NULL : root, CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED, dirs);
r = conf_files_list_strv(&files, ".conf", arg_definitions ? NULL : arg_root, CONF_FILES_REGULAR|CONF_FILES_FILTER_MASKED, dirs);
if (r < 0)
return log_error_errno(r, "Failed to enumerate *.conf files: %m");
@ -6738,7 +6735,7 @@ static int run(int argc, char *argv[]) {
strv_uniq(arg_definitions);
r = context_read_definitions(context, arg_definitions, arg_root);
r = context_read_definitions(context);
if (r < 0)
return r;

View File

@ -88,7 +88,7 @@ static int dnssd_service_load(Manager *manager, const char *filename) {
dropin_dirname = strjoina(service->name, ".dnssd.d");
r = config_parse_many(
STRV_MAKE_CONST(filename), DNSSD_SERVICE_DIRS, dropin_dirname,
STRV_MAKE_CONST(filename), DNSSD_SERVICE_DIRS, dropin_dirname, /* root = */ NULL,
"Service\0",
config_item_perf_lookup, resolved_dnssd_gperf_lookup,
CONFIG_PARSE_WARN,

View File

@ -584,6 +584,7 @@ int config_parse_config_file(
static int config_get_dropin_files(
const char* const* conf_file_dirs,
const char *dropin_dirname,
const char *root,
char ***ret) {
_cleanup_strv_free_ char **dropin_dirs = NULL;
@ -599,7 +600,7 @@ static int config_get_dropin_files(
if (r < 0)
return r;
return conf_files_list_strv(ret, ".conf", NULL, 0, (const char* const*) dropin_dirs);
return conf_files_list_strv(ret, ".conf", root, 0, (const char* const*) dropin_dirs);
}
/* Parse each config file in the directories specified as strv. */
@ -607,6 +608,7 @@ int config_parse_many(
const char* const* conf_files,
const char* const* conf_file_dirs,
const char *dropin_dirname,
const char *root,
const char *sections,
ConfigItemLookup lookup,
const void *table,
@ -623,7 +625,7 @@ int config_parse_many(
assert(sections);
assert(table);
r = config_get_dropin_files(conf_file_dirs, dropin_dirname, &files);
r = config_get_dropin_files(conf_file_dirs, dropin_dirname, root, &files);
if (r < 0)
return r;
@ -659,7 +661,7 @@ static int dropins_get_stats_by_path(
if (!strextend(&dropin_dirname, ".d"))
return -ENOMEM;
r = config_get_dropin_files(conf_file_dirs, dropin_dirname, &files);
r = config_get_dropin_files(conf_file_dirs, dropin_dirname, /* root = */ NULL, &files);
if (r < 0)
return r;

View File

@ -105,6 +105,7 @@ int config_parse_many(
const char* const* conf_files, /* possibly empty */
const char* const* conf_file_dirs,
const char *dropin_dirname,
const char *root,
const char *sections, /* nulstr */
ConfigItemLookup lookup,
const void *table,

View File

@ -260,6 +260,7 @@ int link_load_one(LinkConfigContext *ctx, const char *filename) {
STRV_MAKE_CONST(filename),
NETWORK_DIRS,
dropin_dirname,
/* root = */ NULL,
"Match\0"
"Link\0"
"SR-IOV\0",