]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: do TTY idle logic only for sessions marked as "tty"
authorLennart Poettering <lennart@poettering.net>
Wed, 29 Nov 2023 10:09:20 +0000 (11:09 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 4 Jan 2024 14:40:27 +0000 (15:40 +0100)
Otherwise things might be weird, because background sessions might
become "idle", wich doesn#t really make much sense.

This shouldn't change much in 99% of the cases, but slightly corrects
behaviour as it ensures only "primary"/"foreground" sessions get the
idle logic, i.e. where a user exists that could actually make it
non-idle.

src/login/logind-session.c

index cdd299e0064933c1d171ca36c3fa2f16aa684cc7..c49a43133c1483f2011b995f5e359bfaea7c2b29 100644 (file)
@@ -1107,19 +1107,21 @@ int session_get_idle_hint(Session *s, dual_timestamp *t) {
                 return s->idle_hint;
         }
 
-        /* For sessions with an explicitly configured tty, let's check its atime */
-        if (s->tty) {
-                r = get_tty_atime(s->tty, &atime);
-                if (r >= 0)
-                        goto found_atime;
-        }
+        if (s->type == SESSION_TTY) {
+                /* For sessions with an explicitly configured tty, let's check its atime */
+                if (s->tty) {
+                        r = get_tty_atime(s->tty, &atime);
+                        if (r >= 0)
+                                goto found_atime;
+                }
 
-        /* For sessions with a leader but no explicitly configured tty, let's check the controlling tty of
-         * the leader */
-        if (pidref_is_set(&s->leader)) {
-                r = get_process_ctty_atime(s->leader.pid, &atime);
-                if (r >= 0)
-                        goto found_atime;
+                /* For sessions with a leader but no explicitly configured tty, let's check the controlling tty of
+                 * the leader */
+                if (pidref_is_set(&s->leader)) {
+                        r = get_process_ctty_atime(s->leader.pid, &atime);
+                        if (r >= 0)
+                                goto found_atime;
+                }
         }
 
         if (t)