Skip to content

Commit

Permalink
logind: do TTY idle logic only for sessions marked as "tty"
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 20604ff)

Related: RHEL-20757
  • Loading branch information
poettering authored and msekletar committed Jan 5, 2024
1 parent eadfad2 commit 97341f4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/login/logind-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,19 +1029,20 @@ 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 (pid_is_valid(s->leader)) {
r = get_process_ctty_atime(s->leader, &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 (pid_is_valid(s->leader)) {
r = get_process_ctty_atime(s->leader, &atime);
if (r >= 0)
goto found_atime;
}

if (t)
Expand Down

0 comments on commit 97341f4

Please sign in to comment.