X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=blobdiff_plain;f=src%2Fshared%2Fpath-lookup.c;h=68c392e1c0edcc5f9fe1109620e49b1da84cd223;hp=0b067ddf01d9f5d8e0ef88ce08409792caa1dd54;hb=349cc4a507c4d84fcadf61f42159ea6412717896;hpb=a1f31f47152f30e2b6576efaf0027e4cb039c176 diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index 0b067ddf01d..68c392e1c0e 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -115,6 +115,21 @@ static int user_data_dir(char **ret, const char *suffix) { return 1; } +static const char* const user_data_unit_paths[] = { + "/usr/local/lib/systemd/user", + "/usr/local/share/systemd/user", + USER_DATA_UNIT_PATH, + "/usr/lib/systemd/user", + "/usr/share/systemd/user", + NULL +}; + +static const char* const user_config_unit_paths[] = { + USER_CONFIG_UNIT_PATH, + "/etc/systemd/user", + NULL +}; + static char** user_dirs( const char *persistent_config, const char *runtime_config, @@ -125,21 +140,6 @@ static char** user_dirs( const char *persistent_control, const char *runtime_control) { - const char * const config_unit_paths[] = { - USER_CONFIG_UNIT_PATH, - "/etc/systemd/user", - NULL - }; - - const char * const data_unit_paths[] = { - "/usr/local/lib/systemd/user", - "/usr/local/share/systemd/user", - USER_DATA_UNIT_PATH, - "/usr/lib/systemd/user", - "/usr/share/systemd/user", - NULL - }; - _cleanup_strv_free_ char **config_dirs = NULL, **data_dirs = NULL; _cleanup_free_ char *data_home = NULL; _cleanup_strv_free_ char **res = NULL; @@ -196,7 +196,7 @@ static char** user_dirs( if (strv_extend(&res, persistent_config) < 0) return NULL; - if (strv_extend_strv(&res, (char**) config_unit_paths, false) < 0) + if (strv_extend_strv(&res, (char**) user_config_unit_paths, false) < 0) return NULL; if (strv_extend(&res, runtime_config) < 0) @@ -211,7 +211,7 @@ static char** user_dirs( if (strv_extend_strv_concat(&res, data_dirs, "/systemd/user") < 0) return NULL; - if (strv_extend_strv(&res, (char**) data_unit_paths, false) < 0) + if (strv_extend_strv(&res, (char**) user_data_unit_paths, false) < 0) return NULL; if (strv_extend(&res, generator_late) < 0) @@ -226,6 +226,18 @@ static char** user_dirs( return tmp; } +bool path_is_user_data_dir(const char *path) { + assert(path); + + return strv_contains((char**) user_data_unit_paths, path); +} + +bool path_is_user_config_dir(const char *path) { + assert(path); + + return strv_contains((char**) user_config_unit_paths, path); +} + static int acquire_generator_dirs( UnitFileScope scope, const char *tempdir, @@ -564,7 +576,7 @@ int lookup_paths_init( "/usr/local/lib/systemd/system", SYSTEM_DATA_UNIT_PATH, "/usr/lib/systemd/system", -#ifdef HAVE_SPLIT_USR +#if HAVE_SPLIT_USR "/lib/systemd/system", #endif STRV_IFNOTNULL(generator_late), @@ -701,6 +713,7 @@ void lookup_paths_free(LookupPaths *p) { p->runtime_control = mfree(p->runtime_control); p->root_dir = mfree(p->root_dir); + p->temporary_dir = mfree(p->temporary_dir); } int lookup_paths_reduce(LookupPaths *p) {