Bug 295171 - syslogd logs confusing messages when trying to log to non-existing ttys
Summary: syslogd logs confusing messages when trying to log to non-existing ttys
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.4-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Dag-Erling Smørgrav
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-10 07:15 UTC by Andre Albsmeier
Modified: 2026-05-28 22:57 UTC (History)
3 users (show)

See Also:
des: mfc-stable15+
des: mfc-stable14+


Attachments
patch (409 bytes, patch)
2026-05-10 07:15 UTC, Andre Albsmeier
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Albsmeier 2026-05-10 07:15:07 UTC
Created attachment 270560 [details]
patch

When one of my NVMEs became to warm, smartd logged this fact using a priority which triggered syslogd to inform me via a message on the tty:

May 10 07:25:15 <daemon.crit> voyager smartd[2431]: Device: /dev/nvme0, Temperature 41 Celsius reached critical limit of 40 Celsius (Min/Max 16/47)

Additionally, this message appears each time:

May 10 07:25:15 voyager syslogd: /dev/:0: No such file or directory

This is because syslogd walks through getutxent() entries and finds one where ut_line is set to ":0" (which probably comes from my logon through xdm).

A possible fix might be to check if ut_line contains a colon (and silently ignore it in this case), see patch.

Another option would be not to complain in ttymsg_check() when stat()ing the tty failes (and return NULL) as ttystat() does it in w(1).
Comment 1 Andre Albsmeier 2026-05-10 07:16:06 UTC
Should have read "too warm", of course ;-)
Comment 2 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2026-05-15 16:16:06 UTC
https://reviews.freebsd.org/D57018
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-05-25 17:04:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=05e8f2bf0906875e666469e0338f922d1113d034

commit 05e8f2bf0906875e666469e0338f922d1113d034
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-25 16:51:23 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-25 16:52:15 +0000

    ttymsg: Overhaul

    * Instead of an error string, return the usual 0 or -1 and let the caller
      figure out what, if anything, to tell the user.

    * Avoid string manipulations by opening /dev first and using openat()
      with O_RESOLVE_BENEATH.

    * Add a boolean argument which, if false, causes ttymsg() to return
      without sending the message if the tty's group-writable bit is not
      set.  This saves programs that respect this setting (like syslogd(8))
      from having to check before calling ttymsg().

    * Update all callers.

    The observable effect of this change is minimal except for slightly
    different error messages when ttymsg() fails.  However, syslogd(8) will
    no longer print spurious error messages on the console after trying and
    failing to write a log message to an X11 session.

    PR:             295171
    MFC after:      1 week
    Reviewed by:    jfree, markj
    Differential Revision:  https://reviews.freebsd.org/D57018

 libexec/talkd/announce.c           |   3 +-
 usr.bin/wall/ttymsg.c              | 120 ++++++++++++++++++++-----------------
 usr.bin/wall/ttymsg.h              |   2 +-
 usr.bin/wall/wall.c                |   6 +-
 usr.sbin/syslogd/syslogd.c         |  47 ++++-----------
 usr.sbin/syslogd/syslogd_cap.c     |   2 +-
 usr.sbin/syslogd/syslogd_cap.h     |   8 +--
 usr.sbin/syslogd/syslogd_cap_log.c |  58 +++++++-----------
 8 files changed, 106 insertions(+), 140 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2026-05-28 08:03:54 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cf5cb2c231fc63d36287321261742b2c63e956f8

commit cf5cb2c231fc63d36287321261742b2c63e956f8
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-25 16:51:23 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-28 08:02:48 +0000

    ttymsg: Overhaul

    * Instead of an error string, return the usual 0 or -1 and let the caller
      figure out what, if anything, to tell the user.

    * Avoid string manipulations by opening /dev first and using openat()
      with O_RESOLVE_BENEATH.

    * Add a boolean argument which, if false, causes ttymsg() to return
      without sending the message if the tty's group-writable bit is not
      set.  This saves programs that respect this setting (like syslogd(8))
      from having to check before calling ttymsg().

    * Update all callers.

    The observable effect of this change is minimal except for slightly
    different error messages when ttymsg() fails.  However, syslogd(8) will
    no longer print spurious error messages on the console after trying and
    failing to write a log message to an X11 session.

    PR:             295171
    MFC after:      1 week
    Reviewed by:    jfree, markj
    Differential Revision:  https://reviews.freebsd.org/D57018

    (cherry picked from commit 05e8f2bf0906875e666469e0338f922d1113d034)

 libexec/talkd/announce.c           |   3 +-
 usr.bin/wall/ttymsg.c              | 120 ++++++++++++++++++++-----------------
 usr.bin/wall/ttymsg.h              |   2 +-
 usr.bin/wall/wall.c                |   6 +-
 usr.sbin/syslogd/syslogd.c         |  47 ++++-----------
 usr.sbin/syslogd/syslogd_cap.c     |   2 +-
 usr.sbin/syslogd/syslogd_cap.h     |   8 +--
 usr.sbin/syslogd/syslogd_cap_log.c |  58 +++++++-----------
 8 files changed, 106 insertions(+), 140 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-05-28 08:03:56 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3d6c7334c73ee459feb57dcd8bc350f5f6308b41

commit 3d6c7334c73ee459feb57dcd8bc350f5f6308b41
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-05-25 16:51:23 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-05-28 08:02:52 +0000

    ttymsg: Overhaul

    * Instead of an error string, return the usual 0 or -1 and let the caller
      figure out what, if anything, to tell the user.

    * Avoid string manipulations by opening /dev first and using openat()
      with O_RESOLVE_BENEATH.

    * Add a boolean argument which, if false, causes ttymsg() to return
      without sending the message if the tty's group-writable bit is not
      set.  This saves programs that respect this setting (like syslogd(8))
      from having to check before calling ttymsg().

    * Update all callers.

    The observable effect of this change is minimal except for slightly
    different error messages when ttymsg() fails.  However, syslogd(8) will
    no longer print spurious error messages on the console after trying and
    failing to write a log message to an X11 session.

    PR:             295171
    MFC after:      1 week
    Reviewed by:    jfree, markj
    Differential Revision:  https://reviews.freebsd.org/D57018

    (cherry picked from commit 05e8f2bf0906875e666469e0338f922d1113d034)

 libexec/talkd/announce.c   |   3 +-
 usr.bin/wall/ttymsg.c      | 118 ++++++++++++++++++++++++---------------------
 usr.bin/wall/ttymsg.h      |   2 +-
 usr.bin/wall/wall.c        |   6 +--
 usr.sbin/syslogd/syslogd.c |  48 ++++--------------
 5 files changed, 79 insertions(+), 98 deletions(-)