From: Mike Yuan Date: Tue, 31 Oct 2023 13:08:19 +0000 (+0800) Subject: logind: return "no" if sleep operation is disabled X-Git-Tag: v255-rc3~47^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51eeeb7bde2db84d2892eef4a8bf93896feeb985;p=thirdparty%2Fsystemd.git 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". --- 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);