From faf205de3ba9a11b0ba17682123d7f3fedc7da24 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Tue, 24 Sep 2019 09:16:49 +0200 Subject: [PATCH 1/3] man: alias names can't be used with enable command --- man/systemd.unit.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index d812108d3c..409cf9e2c0 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -137,10 +137,10 @@ a symlink, so when systemd is asked through D-Bus to load dbus-org.freedesktop.network1.service, it'll load systemd-networkd.service. Alias names may be used in commands like - enable, disable, start, stop, - status, and similar, and in all unit dependency directives, including - Wants=, Requires=, Before=, - After=. Aliases cannot be used with the preset command. + disable, start, stop, status, + and similar, and in all unit dependency directives, including Wants=, + Requires=, Before=, After=. Aliases cannot be + used with the preset command. Unit files may specify aliases through the Alias= directive in the [Install] section. When the unit is enabled, symlinks will be created for those names, and removed when the unit is From 56a4ce2417ff74f82a48e3a5c6e36edad8d4bc6c Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Tue, 24 Sep 2019 18:33:54 +0200 Subject: [PATCH 2/3] shared/install: fix error codes returned by install_context_apply() --- src/shared/install.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/install.c b/src/shared/install.c index 8f9cf4a2f4..0724dd96ee 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1897,7 +1897,7 @@ static int install_context_apply( q = install_info_traverse(scope, c, paths, i, flags, NULL); if (q < 0) { - unit_file_changes_add(changes, n_changes, r, i->name, NULL); + unit_file_changes_add(changes, n_changes, q, i->name, NULL); return q; } From 22683674716fd0e5b016ce5a7d8fd90df5f9f9e7 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Tue, 24 Sep 2019 18:54:15 +0200 Subject: [PATCH 3/3] shared/install: failing with -ELOOP can be due to the use of an alias in install_error() -ELOOP can happen also when enabling an alias name (which is admittedly useless since the unit it belongs to was already enabled) so let's mention this possibility when reporting the corresponding error. --- src/core/dbus-manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 035011e34f..98d2e828a3 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -1903,11 +1903,13 @@ static int install_error( case -ELOOP: r = sd_bus_error_setf(error, BUS_ERROR_UNIT_LINKED, - "Refusing to operate on linked unit file %s", changes[i].path); + "Refusing to operate on alias name or linked unit file: %s", + changes[i].path); goto found; case -ENOENT: - r = sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit file %s does not exist.", changes[i].path); + r = sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, + "Unit file %s does not exist.", changes[i].path); goto found; default: