From 114400dfb37f5e34985060b925fbaed7a9f01ac8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 9 Feb 2016 20:28:58 +0100 Subject: core: change internal error code for masked units from EBADR to ESHUTDOWN This commit changes the mapping of the BUS_ERROR_UNIT_MASKED error to ESHUTDOWN. This error is used whenever the transaction engine is asked to operate on a masked unit. ESHUTDOWN is what is used for the similar case when the unit file enable/disable logic hits a masked unit file, hence is a natural candidate to be used here too. Background: before this patch both "job type not applicable" and "unit masked" where mapped to EBADR, which transaction_add_job_and_dependencies() then checked for. It actually wanted to check exclusively for the former error condition, not the latter but due to the same mapping this failed to work. This patch semi-undoes an accidental change made in caffa4ef700fdd0eadd6c0b2ef9925611672a1bc, however restores the error number to ESHUTDOWN instead of the original ENOSYS (for the reasons indicated above). To make this easier to grok for the future, I added comments to explaining which error conditions are checked for. Fixes: #2315 --- src/core/transaction.c | 14 +++++++------- src/libsystemd/sd-bus/bus-common-errors.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/transaction.c b/src/core/transaction.c index 0d53e4bac0..099df4f3f7 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -912,7 +912,7 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e); if (r < 0) { - if (r != -EBADR) + if (r != -EBADR) /* job type not applicable */ goto fail; sd_bus_error_free(e); @@ -922,7 +922,7 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_BINDS_TO], i) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e); if (r < 0) { - if (r != -EBADR) + if (r != -EBADR) /* job type not applicable */ goto fail; sd_bus_error_free(e); @@ -932,9 +932,9 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) { r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, ignore_order, e); if (r < 0) { - /* unit masked and unit not found are not considered as errors. */ + /* unit masked, job type not applicable and unit not found are not considered as errors. */ log_unit_full(dep, - r == -EBADR || r == -ENOENT ? LOG_DEBUG : LOG_WARNING, + r == -ESHUTDOWN || r == -EBADR || r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r, "Cannot add dependency job, ignoring: %s", bus_error_message(e, r)); sd_bus_error_free(e); @@ -944,7 +944,7 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE], i) { r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, false, false, ignore_order, e); if (r < 0) { - if (r != -EBADR) + if (r != -EBADR) /* job type not applicable */ goto fail; sd_bus_error_free(e); @@ -954,7 +954,7 @@ int transaction_add_job_and_dependencies( SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTS], i) { r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, true, false, ignore_order, e); if (r < 0) { - if (r != -EBADR) + if (r != -EBADR) /* job type not applicable */ goto fail; sd_bus_error_free(e); @@ -999,7 +999,7 @@ int transaction_add_job_and_dependencies( r = transaction_add_job_and_dependencies(tr, nt, dep, ret, true, false, false, ignore_order, e); if (r < 0) { - if (r != -EBADR) + if (r != -EBADR) /* job type not applicable */ goto fail; sd_bus_error_free(e); diff --git a/src/libsystemd/sd-bus/bus-common-errors.c b/src/libsystemd/sd-bus/bus-common-errors.c index e344b3b77b..9bea1d479c 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.c +++ b/src/libsystemd/sd-bus/bus-common-errors.c @@ -39,7 +39,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = { SD_BUS_ERROR_MAP(BUS_ERROR_TRANSACTION_JOBS_CONFLICTING, EDEADLK), SD_BUS_ERROR_MAP(BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, EDEADLK), SD_BUS_ERROR_MAP(BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE, EDEADLK), - SD_BUS_ERROR_MAP(BUS_ERROR_UNIT_MASKED, EBADR), + SD_BUS_ERROR_MAP(BUS_ERROR_UNIT_MASKED, ESHUTDOWN), SD_BUS_ERROR_MAP(BUS_ERROR_JOB_TYPE_NOT_APPLICABLE, EBADR), SD_BUS_ERROR_MAP(BUS_ERROR_NO_ISOLATION, EPERM), SD_BUS_ERROR_MAP(BUS_ERROR_SHUTTING_DOWN, ECANCELED), -- cgit v1.2.3-54-g00ecf From 8222cf91451e64095c29b2918d2bb5b394c17800 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 9 Feb 2016 20:34:27 +0100 Subject: units: downgrade dependency on /tmp in basic.target to Wants= Now that requiring of a masked unit results in failure again, downgrade the dependency on /tmp to Wants= again, so that our suggested way to disable /tmp-on-tmpfs by masking doesn't result in a failing boot. References: #2315 --- units/basic.target | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/units/basic.target b/units/basic.target index e0e1e604f8..7f1f829c36 100644 --- a/units/basic.target +++ b/units/basic.target @@ -10,8 +10,10 @@ Description=Basic System Documentation=man:systemd.special(7) Requires=sysinit.target Wants=sockets.target timers.target paths.target slices.target -After=sysinit.target sockets.target paths.target slices.target +After=sysinit.target sockets.target paths.target slices.target tmp.mount -# We support /var, /tmp, /var/tmp, being on NFS, but we don't pull in -# remote-fs.target by default, hence explicitly pull /var in here. -RequiresMountsFor=/var /tmp /var/tmp +# We support /var, /tmp, /var/tmp, being on NFS, but we don't pull in remote-fs.target by default, hence pull them in +# explicitly here. Note that we require /var and /var/tmp, but only add a Wants= type dependency on /tmp, as we support +# that unit being masked, and this should not be considered an error. +RequiresMountsFor=/var /var/tmp +Wants=tmp.mount -- cgit v1.2.3-54-g00ecf From a0956ed01f8794b677efe17a87aed3cad8c265d5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 9 Feb 2016 20:39:43 +0100 Subject: man: link resolved bus API documentation from its man page This is similar how we already do it for logind or machined. --- man/systemd-resolved.service.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/man/systemd-resolved.service.xml b/man/systemd-resolved.service.xml index 4e144b5c98..1b63afdded 100644 --- a/man/systemd-resolved.service.xml +++ b/man/systemd-resolved.service.xml @@ -135,6 +135,10 @@ Note that /run/systemd/resolve/resolv.conf should not be used directly by applications, but only through a symlink from /etc/resolv.conf. + + See the resolved D-Bus API + Documentation for information about the APIs systemd-resolved provides. + -- cgit v1.2.3-54-g00ecf From b21d2f8117e41753aeeb384dfafa92ee97a6c7b8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 9 Feb 2016 20:47:45 +0100 Subject: core: clarify which unit file is masked in error message After all, the masked unit file error might be returned when enqueuing a unit that is not masked but requires a masked unit. In this case it should really be clear which unit is meant here. --- src/core/dbus-unit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index d7929e5566..7b0ae03228 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -1266,10 +1266,10 @@ int bus_unit_check_load_state(Unit *u, sd_bus_error *error) { * possible. Note that in the case of UNIT_MASKED, load_error * is not set. */ if (u->load_state == UNIT_MASKED) - return sd_bus_error_setf(error, BUS_ERROR_UNIT_MASKED, "Unit is masked."); + return sd_bus_error_setf(error, BUS_ERROR_UNIT_MASKED, "Unit %s is masked.", u->id); if (u->load_state == UNIT_NOT_FOUND) - return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit not found."); + return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not found.", u->id); - return sd_bus_error_set_errnof(error, u->load_error, "Unit is not loaded properly: %m."); + return sd_bus_error_set_errnof(error, u->load_error, "Unit %s is not loaded properly: %m.", u->id); } -- cgit v1.2.3-54-g00ecf