]> git.ipfire.org Git - thirdparty/systemd.git/commit
systemctl: load unit if needed in "systemctl is-active"
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Jan 2018 14:14:25 +0000 (15:14 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Jan 2018 14:19:13 +0000 (15:19 +0100)
commit3d083b2245b0b8e52f2d8ccc3e55246f41f1f544
tree1677c129ae3144a76b8721a11081db6d61800c37
parent16c73c765da70619b40709f0c52a868b77d2c035
systemctl: load unit if needed in "systemctl is-active"

Previously, we'd explicitly use "GetUnit()" on the server side to
convert a unit name into a bus path, as that function will return an
error if the unit is not currently loaded. If we'd convert the path on
the client side, and access the unit this way directly the unit would be
loaded automatically in the background.

The old logic was done in order to minimize the effect of "is-active" on
the system, i.e. that a monoitoring command does not itself alter the
state of the system.

however, this is problematic as this can lead to confusing results if
the queried unit name is an alias that currently is not loaded: we'd
claim the unit wasn't active even though this isn't strictly true: the
unit the name is an alias for might be.

Hence, let's simplify the code, and accept that we might end up loading
a unit briefly here, and let's make "systemctl is-active" skip the
GetUnit() thing and calculate the unit path right away.

Fixes: #7875
src/systemctl/systemctl.c