path-lookup: include paths from --global in --user search path too

This doesn't matter that much, because set-property --global does not work,
so at least those paths wouldn't be used automatically. It is still possible
to create such snippets manually, so we better fix this.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-02-08 13:57:05 +01:00
parent c59479e790
commit 7b6344d35f

View File

@@ -169,6 +169,8 @@ int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs) {
static char** user_dirs(
const char *persistent_config,
const char *runtime_config,
const char *global_persistent_config,
const char *global_runtime_config,
const char *generator,
const char *generator_early,
const char *generator_late,
@@ -209,12 +211,19 @@ static char** user_dirs(
if (strv_extend(&res, persistent_config) < 0)
return NULL;
/* global config has lower priority than the user config of the same type */
if (strv_extend(&res, global_persistent_config) < 0)
return NULL;
if (strv_extend_strv(&res, (char**) user_config_unit_paths, false) < 0)
return NULL;
if (strv_extend(&res, runtime_config) < 0)
return NULL;
if (strv_extend(&res, global_runtime_config) < 0)
return NULL;
if (strv_extend(&res, generator) < 0)
return NULL;
@@ -484,6 +493,7 @@ int lookup_paths_init(
_cleanup_free_ char
*root = NULL,
*persistent_config = NULL, *runtime_config = NULL,
*global_persistent_config = NULL, *global_runtime_config = NULL,
*generator = NULL, *generator_early = NULL, *generator_late = NULL,
*transient = NULL,
*persistent_control = NULL, *runtime_control = NULL;
@@ -522,6 +532,12 @@ int lookup_paths_init(
if (r < 0)
return r;
if (scope == UNIT_FILE_USER) {
r = acquire_config_dirs(UNIT_FILE_GLOBAL, &global_persistent_config, &global_runtime_config);
if (r < 0)
return r;
}
if ((flags & LOOKUP_PATHS_EXCLUDE_GENERATED) == 0) {
/* Note: if XDG_RUNTIME_DIR is not set, this will fail completely with ENXIO */
r = acquire_generator_dirs(scope, tempdir,
@@ -621,6 +637,7 @@ int lookup_paths_init(
case UNIT_FILE_USER:
add = user_dirs(persistent_config, runtime_config,
global_persistent_config, global_runtime_config,
generator, generator_early, generator_late,
transient,
persistent_control, runtime_control);