diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-31 15:17:52 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-05-31 22:30:08 +0200 |
commit | 51a2b575d751c257f2603f12fe9bb883014c37c1 (patch) | |
tree | ff43ebc29bbf6ed8de774f88ad4eb666a9b6168a | |
parent | e31355bbc14e6ee96162c56c5e625aafcf42f9ef (diff) | |
download | systemd-51a2b575d751c257f2603f12fe9bb883014c37c1.tar.gz |
logind: do not print wall messages to local pseudoterminals
Fixes #23520. Replaces #23555.
The problem started with cdf370626f08ed509a5dde9d5618eed29d625032 and
90b1ec03b2ce939f589239133a32f4429f2ad6a6 which together started printing the
wall message in more cases. The motivation for those change was reasonable, but
this clearly causes problems described in #23520: users are getting unexpected
wall messages. Xterm, urxvt, (anything using libutempter?), and tmux (in some
configurations), register local pty sessions in utmp.
So let's try to suppress the message for local pseudo-terminal logins. This
patch based on #23538, but instead of filtering just on /dev/pts, it uses the
.ut_addr_v6 to only filter out local entries.
-rw-r--r-- | src/login/logind-utmp.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index ccea8f968f..138c01e9b2 100644 --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@ -43,19 +43,17 @@ _const_ static usec_t when_wall(usec_t n, usec_t elapse) { } bool logind_wall_tty_filter(const char *tty, bool is_local, void *userdata) { - Manager *m = userdata; - const char *p; - - assert(m); + Manager *m = ASSERT_PTR(userdata); - if (!m->scheduled_shutdown_tty) - return true; - - p = path_startswith(tty, "/dev/"); + const char *p = path_startswith(tty, "/dev/"); if (!p) return true; - return !streq(p, m->scheduled_shutdown_tty); + /* Do not write to local pseudo-terminals */ + if (startswith(p, "pts/") && is_local) + return false; + + return !streq_ptr(p, m->scheduled_shutdown_tty); } static int warn_wall(Manager *m, usec_t n) { |