summaryrefslogtreecommitdiff
path: root/src/shared/install.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-09-22 14:46:09 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-09-22 18:40:26 +0200
commitd2561cfdf772c621963e62b52cfbf57d6f75178d (patch)
treeae983da05e0c2c8b421f86571866c7ba7aed4cd9 /src/shared/install.c
parentd9b4b48f3fee12293cc911929d1d92a01a5c69c9 (diff)
downloadsystemd-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/install.c')
-rw-r--r--src/shared/install.c11
1 files changed, 9 insertions, 2 deletions
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)