X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fpath-lookup.c;h=051f1a4835c4ae99c90a0de6f34e62498f14306a;hb=978553ce5e85a57a203be8256e59f304c8c46f3d;hp=d7ed6e9e3c2cdaeadd407ab679090dc95a53ab60;hpb=4d5dec2389d8e6ce78b45d3058220888f4a93db7;p=elogind.git diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index d7ed6e9e3..051f1a483 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -162,18 +162,18 @@ static char** user_dirs( if (strv_extend(&r, config_home) < 0) goto fail; - if (runtime_dir) - if (strv_extend(&r, runtime_dir) < 0) + if (!strv_isempty(config_dirs)) + if (strv_extend_strv_concat(&r, config_dirs, "/systemd/user") < 0) goto fail; - if (strv_extend(&r, runtime_unit_path) < 0) + if (strv_extend_strv(&r, (char**) config_unit_paths) < 0) goto fail; - if (!strv_isempty(config_dirs)) - if (strv_extend_strv_concat(&r, config_dirs, "/systemd/user") < 0) + if (runtime_dir) + if (strv_extend(&r, runtime_dir) < 0) goto fail; - if (strv_extend_strv(&r, (char**) config_unit_paths) < 0) + if (strv_extend(&r, runtime_unit_path) < 0) goto fail; if (generator) @@ -398,3 +398,19 @@ void lookup_paths_free(LookupPaths *p) { p->sysvinit_path = p->sysvrcnd_path = NULL; #endif } + +int lookup_paths_init_from_scope(LookupPaths *paths, + UnitFileScope scope, + const char *root_dir) { + assert(paths); + assert(scope >= 0); + assert(scope < _UNIT_FILE_SCOPE_MAX); + + zero(*paths); + + return lookup_paths_init(paths, + scope == UNIT_FILE_SYSTEM ? SYSTEMD_SYSTEM : SYSTEMD_USER, + scope == UNIT_FILE_USER, + root_dir, + NULL, NULL, NULL); +}