From 0c093a62ef875ca4448cb9b778a2d1d7f3aec4a0 Mon Sep 17 00:00:00 2001 From: Henry Tung Date: Tue, 23 Oct 2018 14:09:13 +0200 Subject: [PATCH] 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) --- src/login/logind-dbus.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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"; } -- 2.47.3