]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: Don't match non-leader processes for utmp TTY determination (#38027)
authorLennart Poettering <lennart@poettering.net>
Thu, 3 Jul 2025 07:20:19 +0000 (09:20 +0200)
committerGitHub <noreply@github.com>
Thu, 3 Jul 2025 07:20:19 +0000 (09:20 +0200)
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.

1  2 
src/login/logind-utmp.c

index 26ebb35c64e40db2ff6d907255bd6c172902138b,2adfc082573ef0ff49e65500af7bc2100bff3b82..9d9ccebcc7bde28f9e2e81f83688e82903b06e97
@@@ -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