mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
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".
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user