From: Henry Tung Date: Tue, 23 Oct 2018 12:09:13 +0000 (+0200) Subject: logind: fix determination of CanHibernate() and other calls X-Git-Tag: v240~306^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10806%2Fhead;p=thirdparty%2Fsystemd.git logind: fix determination of CanHibernate() and other calls 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) --- diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 26253eb6195..c0dafa03ef0 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -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"; }