]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: fix logind bus call error handling in halt_main()
authorIvan Shapovalov <intelfx100@gmail.com>
Wed, 9 Sep 2015 13:04:35 +0000 (16:04 +0300)
committerIvan Shapovalov <intelfx100@gmail.com>
Thu, 10 Sep 2015 11:44:59 +0000 (14:44 +0300)
Handle -EOPNOTSUPP and -EINPROGRESS like in start_special().

src/systemctl/systemctl.c

index 22455b5475e6556116b7f5248be6ef6eec8ca109..bde3607e216c322e076ae8fc1cab21ea847dde27 100644 (file)
@@ -3048,8 +3048,12 @@ static int start_special(sd_bus *bus, char **args) {
                    ACTION_HIBERNATE,
                    ACTION_HYBRID_SLEEP)) {
                 r = reboot_with_logind(bus, a);
-                if (r >= 0 || IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
+                if (r >= 0)
                         return r;
+                if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
+                        /* requested operation is not supported or already in progress */
+                        return r;
+                /* on all other errors, try low-level operation */
         }
 
         r = start_unit(bus, args);
@@ -7378,6 +7382,10 @@ static int halt_main(sd_bus *bus) {
                         r = reboot_with_logind(bus, arg_action);
                         if (r >= 0)
                                 return r;
+                        if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
+                                /* requested operation is not supported or already in progress */
+                                return r;
+                        /* on all other errors, try low-level operation */
                 }
 
                 log_error("Must be root.");