From: Zbigniew Jędrzejewski-Szmek Date: Tue, 31 May 2022 13:17:52 +0000 (+0200) Subject: logind: do not print wall messages to local pseudoterminals X-Git-Tag: v252-rc1~887^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51a2b575d751c257f2603f12fe9bb883014c37c1;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index ccea8f968f9..138c01e9b27 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) {