diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-09-22 14:46:09 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-09-22 18:40:26 +0200 |
commit | d2561cfdf772c621963e62b52cfbf57d6f75178d (patch) | |
tree | ae983da05e0c2c8b421f86571866c7ba7aed4cd9 /src/shared/path-lookup.c | |
parent | d9b4b48f3fee12293cc911929d1d92a01a5c69c9 (diff) | |
download | systemd-d2561cfdf772c621963e62b52cfbf57d6f75178d.tar.gz |
install: consider globally enabled units as "enabled" for the user
We would not consider symlinks in /etc/systemd/user/*.{wants,requires}/
towards the user unit being "enabled", because the symlinks were not
located in "config" paths. But this is confusing to users, since those units
are clearly enabled and will be started. So let's muddle the definition of
enablement a bit to include the paths only accessible to root when looking for
enabled user units.
Fixes #4432.
Diffstat (limited to 'src/shared/path-lookup.c')
-rw-r--r-- | src/shared/path-lookup.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index a289511be5..bf10acda94 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, |