From: Lennart Poettering Date: Thu, 3 Jul 2025 07:20:19 +0000 (+0200) Subject: logind: Don't match non-leader processes for utmp TTY determination (#38027) X-Git-Tag: v258-rc1~198 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ba595030704878462603453bcfcf9f54e235522;p=thirdparty%2Fsystemd.git logind: Don't match non-leader processes for utmp TTY determination (#38027) This ensures we don't erroneously assign pseudoterminals created by terminal emulators that use utempter to register themselves in utmp when run under a GUI session that doesn't have a TTY assigned. --- 7ba595030704878462603453bcfcf9f54e235522 diff --cc src/login/logind-utmp.c index 26ebb35c64e,2adfc082573..9d9ccebcc7b --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@@ -56,12 -56,9 +56,12 @@@ int manager_read_utmp(Manager *m) if (isempty(t)) continue; - if (manager_get_session_by_pidref(m, &PIDREF_MAKE_FROM_PID(u->ut_pid), &s) <= 0) + if (manager_get_session_by_leader(m, &PIDREF_MAKE_FROM_PID(u->ut_pid), &s) <= 0) continue; + if (s->type != SESSION_TTY) + continue; + if (s->tty_validity == TTY_FROM_UTMP && !streq_ptr(s->tty, t)) { /* This may happen on multiplexed SSH connection (i.e. 'SSH connection sharing'). In * this case PAM and utmp sessions don't match. In such a case let's invalidate the TTY