]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: fix determination of CanHibernate() and other calls 10806/head
authorHenry Tung <htung@palantir.com>
Tue, 23 Oct 2018 12:09:13 +0000 (14:09 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2018 14:52:22 +0000 (15:52 +0100)
As suggest here:

https://github.com/systemd/systemd/issues/10250#issuecomment-426788301

Fixes: #10250
(This suggested patch has been converted into a proper commit by me,
Lennart, with attribution to the original author, @henryptung)

src/login/logind-dbus.c

index 26253eb6195023ab4da3634b8caf5430b0fdca6d..c0dafa03ef0def1e74b451acbb5fd36f470fbaf4 100644 (file)
@@ -2267,11 +2267,13 @@ static int method_can_shutdown_or_sleep(
                 if (r < 0)
                         return r;
 
-                if (r > 0 && !result)
-                        result = "yes";
-                else if (challenge && (!result || streq(result, "yes")))
-                        result = "challenge";
-                else
+                if (r > 0) {
+                        if (!result)
+                                result = "yes";
+                } else if (challenge) {
+                        if (!result || streq(result, "yes"))
+                                result = "challenge";
+                } else
                         result = "no";
         }