X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fpath-lookup.c;h=8f75a8e83290db85540d544d82af45c4343e2852;hb=f32d2db140150b9d38684a699c9875b6e24ca27c;hp=7a715b713375cb23aa8798762c266e535c6e1e49;hpb=cf7d80a5fe549d4db11800015e02220dccec3096;p=elogind.git diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index 7a715b713..8f75a8e83 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -61,6 +61,23 @@ int user_config_home(char **config_home) { return 0; } +int user_runtime_dir(char **runtime_dir) { + const char *e; + char *r; + + e = getenv("XDG_RUNTIME_DIR"); + if (e) { + r = strappend(e, "/systemd/user"); + if (!r) + return -ENOMEM; + + *runtime_dir = r; + return 1; + } + + return 0; +} + static char** user_dirs( const char *generator, const char *generator_early, @@ -69,10 +86,11 @@ static char** user_dirs( const char * const config_unit_paths[] = { USER_CONFIG_UNIT_PATH, "/etc/systemd/user", - "/run/systemd/user", NULL }; + const char * const runtime_unit_path = "/run/systemd/user"; + const char * const data_unit_paths[] = { "/usr/local/lib/systemd/user", "/usr/local/share/systemd/user", @@ -83,7 +101,7 @@ static char** user_dirs( }; const char *home, *e; - _cleanup_free_ char *config_home = NULL, *data_home = NULL; + _cleanup_free_ char *config_home = NULL, *runtime_dir = NULL, *data_home = NULL; _cleanup_strv_free_ char **config_dirs = NULL, **data_dirs = NULL; char **r = NULL; @@ -99,6 +117,9 @@ static char** user_dirs( if (user_config_home(&config_home) < 0) goto fail; + if (user_runtime_dir(&runtime_dir) < 0) + goto fail; + home = getenv("HOME"); e = getenv("XDG_CONFIG_DIRS"); @@ -148,6 +169,13 @@ static char** user_dirs( if (strv_extend_strv(&r, (char**) config_unit_paths) < 0) goto fail; + if (runtime_dir) + if (strv_extend(&r, runtime_dir) < 0) + goto fail; + + if (strv_extend(&r, runtime_unit_path) < 0) + goto fail; + if (generator) if (strv_extend(&r, generator) < 0) goto fail; @@ -212,7 +240,7 @@ int lookup_paths_init( if (!p->unit_path || append) { /* Let's figure something out. */ - char **unit_path; + _cleanup_strv_free_ char **unit_path; int r; /* For the user units we include share/ in the search