summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shared/install.c7
-rw-r--r--src/systemctl/systemctl.c9
-rw-r--r--src/test/test-install-root.c2
3 files changed, 12 insertions, 6 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index febe33ed7b..71012eafb4 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1466,8 +1466,10 @@ static int install_info_symlink_link(
assert(i->path);
r = in_search_path(paths, i->path);
- if (r != 0)
+ if (r < 0)
return r;
+ if (r > 0)
+ return 0;
path = strjoin(config_path, "/", i->name, NULL);
if (!path)
@@ -1506,7 +1508,8 @@ static int install_info_apply(
r = q;
q = install_info_symlink_link(i, paths, config_path, force, changes, n_changes);
- if (r == 0)
+ /* Do not count links to the unit file towards the "carries_install_info" count */
+ if (r == 0 && q < 0)
r = q;
return r;
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index cfdc851a6d..115c00ea9c 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5527,15 +5527,18 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
}
if (carries_install_info == 0)
- log_warning("The unit files have no [Install] section. They are not meant to be enabled\n"
- "using systemctl.\n"
+ log_warning("The unit files have no installation config (WantedBy, RequiredBy, Also, Alias\n"
+ "settings in the [Install] section, and DefaultInstance for template units).\n"
+ "This means they are not meant to be enabled using systemctl.\n"
"Possible reasons for having this kind of units are:\n"
"1) A unit may be statically enabled by being symlinked from another unit's\n"
" .wants/ or .requires/ directory.\n"
"2) A unit's purpose may be to act as a helper for some other unit which has\n"
" a requirement dependency on it.\n"
"3) A unit may be started when needed via activation (socket, path, timer,\n"
- " D-Bus, udev, scripted systemctl call, ...).\n");
+ " D-Bus, udev, scripted systemctl call, ...).\n"
+ "4) In case of template units, the unit is meant to be enabled with some\n"
+ " instance name specified.");
if (arg_now && n_changes > 0 && STR_IN_SET(argv[0], "enable", "disable", "mask")) {
char *new_args[n_changes + 2];
diff --git a/src/test/test-install-root.c b/src/test/test-install-root.c
index 998c345a1a..2d73c9743b 100644
--- a/src/test/test-install-root.c
+++ b/src/test/test-install-root.c
@@ -107,7 +107,7 @@ static void test_basic_mask_and_enable(const char *root) {
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "d.service", &state) >= 0 && state == UNIT_FILE_ENABLED);
/* Enabling it again should succeed but be a NOP */
- assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) == 1);
+ assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) >= 0);
assert_se(n_changes == 0);
unit_file_changes_free(changes, n_changes);
changes = NULL; n_changes = 0;