From: Zbigniew Jędrzejewski-Szmek Date: Thu, 8 Feb 2018 12:57:05 +0000 (+0100) Subject: path-lookup: include paths from --global in --user search path too X-Git-Tag: v238~121^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b6344d35fdbe523fb6eff2fdfa892d7f07ebfa9;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index 91b2aa8638c..3c57aa6732e 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -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);