summaryrefslogtreecommitdiff
path: root/src/login/logind-session-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-01-06 20:13:16 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-01-14 16:11:39 +0100
commitbe2bb14f00441d9e4a26f94834518db3829e83ed (patch)
treee8e8c31925324d8d59e0fb53098e0a980cdfbee1 /src/login/logind-session-dbus.c
parent952805a9e32e418aa8c76919a671705c84b96edf (diff)
downloadsystemd-be2bb14f00441d9e4a26f94834518db3829e83ed.tar.gz
logind: refuse overriding idle hint on tty sessions
Previously we'd allow marking TTY sessions as idle, but when the user tried to unmark it as idle again it we'd just revert to automatic TTY atime idle detection, thus making it impossible to mark the session as non-idle, unless its TTY is atime-touched all the time. But of course, marking a session as idle is pretty much fatal if you never can mark it as non-idle again. This change is triggred by bug reports such as this: https://github.com/systemd/systemd/issues/14053 With this patch we will now output a clean, clear error message if a client tries to manipulate the idle state of a non-graphical session. This means we now have clear rules: "manual" idle logic for graphical sessions, and TTY based ones for all others that have a TTY of some form. I considered allowing the idle state to be overriden both ways for tty sessions but that's problematic: for sessions that are temporarily upgraded from tty to graphical and thus suddenly want to manage their own idle state we'd need to a way to detect when the upgrade goes away and thus we should revert to old behaviour. Without reverting to the previous TTY idle auto-magic we'd otherwise be stuck in an eternally idle or eternally non-idle state, with really bad effects in case auto-suspend is used. Thus, let's instead generate a proper error message, saying clearly we don't support it. (Also includes some other fixes and clean-ups in related code) Closes: #14053
Diffstat (limited to 'src/login/logind-session-dbus.c')
-rw-r--r--src/login/logind-session-dbus.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index 8f13edafb0..32a64fff0c 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -249,7 +249,11 @@ static int method_set_idle_hint(sd_bus_message *message, void *userdata, sd_bus_
if (uid != 0 && uid != s->user->uid)
return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Only owner of session may set idle hint");
- session_set_idle_hint(s, b);
+ r = session_set_idle_hint(s, b);
+ if (r == -ENOTTY)
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Idle hint control is not supported on non-graphical sessions.");
+ if (r < 0)
+ return r;
return sd_bus_reply_method_return(message, NULL);
}