]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/manager: check the existance of the special units (#7433)
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Nov 2017 12:25:56 +0000 (21:25 +0900)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Nov 2017 12:25:56 +0000 (13:25 +0100)
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.

src/core/manager.c

index 33d7aa1cbbfb83de931589b9f4c917cbb7637608..0e21e14becc1660f44663a0e26c87de9d38f3b35 100644 (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 */