From: Yu Watanabe Date: Thu, 23 Nov 2017 12:25:56 +0000 (+0900) Subject: core/manager: check the existance of the special units (#7433) X-Git-Tag: v236~143 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=706424c2e2334568647f7a2ea3ba670f7db51c0e;p=thirdparty%2Fsystemd.git 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 e68537f0ba1a4433ecdf58e609b1701ed7091abc. Fixes #7426. --- diff --git a/src/core/manager.c b/src/core/manager.c index 33d7aa1cbbf..0e21e14becc 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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 */