From 51eeeb7bde2db84d2892eef4a8bf93896feeb985 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 31 Oct 2023 21:08:19 +0800 Subject: [PATCH] logind: return "no" if sleep operation is disabled According to org.freedesktop.login1: > If "na" is returned, the operation is not available because > hardware, kernel, or drivers do not support it. If "yes" is > returned, the operation is supported and the user may execute > the operation without further authentication. If "no" is returned, > the operation is available but the user is not allowed to execute > the operation. Therefore, we should return "no" if sleep is explicitly disabled, otherwise we return "na". --- src/login/logind-dbus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 6ad6ef912db..ec88c55a089 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2543,11 +2543,13 @@ static int method_can_shutdown_or_sleep( assert(a); if (a->sleep_operation >= 0) { - r = sleep_supported(a->sleep_operation); + SleepSupport support; + + r = sleep_supported_full(a->sleep_operation, &support); if (r < 0) return r; if (r == 0) - return sd_bus_reply_method_return(message, "s", "na"); + return sd_bus_reply_method_return(message, "s", support == SLEEP_DISABLED ? "no" : "na"); } r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID, &creds); -- 2.47.3