core/manager: check the existance of the special units (#7433)

In the user mode, not all special units exist.
So, we need to check whether the units exist or not before operate
something to the units.
Such the check was mistakenly dropped by e68537f0ba.

Fixes #7426.
This commit is contained in:
Yu Watanabe 2017-11-23 21:25:56 +09:00 committed by Lennart Poettering
parent f75707dbcb
commit 706424c2e2

View file

@ -3543,16 +3543,16 @@ ManagerState manager_state(Manager *m) {
/* Is the special shutdown target active or queued? If so, we are in shutdown state */
u = manager_get_unit(m, SPECIAL_SHUTDOWN_TARGET);
if (unit_active_or_pending(u))
if (u && unit_active_or_pending(u))
return MANAGER_STOPPING;
/* Are the rescue or emergency targets active or queued? If so we are in maintenance state */
u = manager_get_unit(m, SPECIAL_RESCUE_TARGET);
if (unit_active_or_pending(u))
if (u && unit_active_or_pending(u))
return MANAGER_MAINTENANCE;
u = manager_get_unit(m, SPECIAL_EMERGENCY_TARGET);
if (unit_active_or_pending(u))
if (u && unit_active_or_pending(u))
return MANAGER_MAINTENANCE;
/* Are there any failed units? If so, we are in degraded mode */