From d2561cfdf772c621963e62b52cfbf57d6f75178d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 22 Sep 2017 14:46:09 +0200 Subject: 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. --- src/shared/install.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/shared/install.c') diff --git a/src/shared/install.c b/src/shared/install.c index 4141e0402f..e14a869321 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -885,6 +885,7 @@ static int find_symlinks( } static int find_symlinks_in_scope( + UnitFileScope scope, const LookupPaths *paths, UnitFileInstallInfo *i, bool match_name, @@ -916,6 +917,12 @@ static int find_symlinks_in_scope( return 1; } + /* look for globally enablement of user units */ + if (scope == UNIT_FILE_USER && path_is_user_config_dir(*p)) { + *state = UNIT_FILE_ENABLED; + return 1; + } + r = path_is_runtime(paths, *p, false); if (r < 0) return r; @@ -2646,7 +2653,7 @@ static int unit_file_lookup_state( /* Check if any of the Alias= symlinks have been created. * We ignore other aliases, and only check those that would * be created by systemctl enable for this unit. */ - r = find_symlinks_in_scope(paths, i, true, &state); + r = find_symlinks_in_scope(scope, paths, i, true, &state); if (r < 0) return r; if (r > 0) @@ -2654,7 +2661,7 @@ static int unit_file_lookup_state( /* Check if the file is known under other names. If it is, * it might be in use. Report that as UNIT_FILE_INDIRECT. */ - r = find_symlinks_in_scope(paths, i, false, &state); + r = find_symlinks_in_scope(scope, paths, i, false, &state); if (r < 0) return r; if (r > 0) -- cgit v1.2.1