Hi all,

On Wed, Dec 03, 2025 at 11:27:35AM +0100, Erik Auerswald wrote:
> On Wed, Dec 03, 2025 at 09:55:07AM +0100, Valentin Haudiquet wrote:
> > On Wed, 3 Dec 2025 at 09:45, Valentin Haudiquet
> > <[email protected]> wrote:
> > >
> > > I just tested that release candidate and the syslogd.sh test is a PASS
> > > locally, on my machine.
> > 
> > Ah, nevermind. I forgot to enable libsystemd.
> > 
> > With libsystemd enabled, the test still fails...
> 
> Thanks for testing!
> 
> I'll add the ttymsg.c patch together with a hopefully helpful comment
> and a NEWS entry soonish.

I have just pushed the attached patch.

Cheers,
Erik
commit 0c9d12e0dacf0a5c808f2283de18a0cc51508f6d
Author: Erik Auerswald <[email protected]>
Date:   2025-12-03 21:24:22 +0100

    syslod, talkd: GNU/Linux w/o utmp compatibility
    
    Some newer GNU/Linux systems no longer have a "utmp" file.
    This file is used by both syslogd and talkd to find the
    TTY device files of active user sessions in order to send
    messages to specific or all users.
    
    Gnulib can emulate a utmp file via the read_utmp() function
    from the readutmp module.  This emulation is activated by
    defining "READUTMP_USE_SYSTEMD", triggered via configure's
    "--enable-systemd" option on systems without utmp and with
    systemd.
    
    But, this emulation reports non-existing TTY device files
    for active user sessions.  Attempting to send a message to a
    non-existing TTY produces an error, but that is normal behavior
    for such a system.  Thus, ignore this error on such systems,
    but not others.
    
    * NEWS.md: Mention enhancement.
    * libinetutils/ttymsg.c (inetutils_ttymsg): Ignore errors for
      non-existings TTY files reported in emulated utmp entries.

diff --git a/NEWS.md b/NEWS.md
index 0699fb70..1a8d8cf3 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -16,6 +16,12 @@ Thanks to Benjamin Cathelineau, see
 
 ** Fix codespell typos.
 
+** syslogd, talkd: Better compatibility with utmp-less GNU/Linux systems
+when configuring with --enable-systemd.
+Thanks to Valentin Haudiquet for reporting the issue and testing possible
+solutions.  For more info, see the thread starting at
+<https://lists.gnu.org/archive/html/bug-inetutils/2025-11/msg00000.html>.
+
 # Noteworthy changes in release 2.6 (2025-02-21) [stable]
 
 ** The release tarball is now reproducible.
diff --git a/libinetutils/ttymsg.c b/libinetutils/ttymsg.c
index 74d73167..9d7db630 100644
--- a/libinetutils/ttymsg.c
+++ b/libinetutils/ttymsg.c
@@ -109,6 +109,17 @@ inetutils_ttymsg (struct iovec *iov, int iovcnt, char *line, int tmout)
     {
       if (errno == EBUSY || errno == EACCES)
 	return (NULL);
+#ifdef READUTMP_USE_SYSTEMD
+      /*
+       * GNU/Linux systems without utmp file but with utmp emulation
+       * provided via Gnulib's read_utmp() function regularly return
+       * non-existing TTYs for some active user sessions.  This is a
+       * limitation of the utmp emulation.  Thus ignore this error on
+       * such systems, but not others.
+       */
+      if (errno == ENOENT)
+	return (NULL);
+#endif
       snprintf (errbuf, sizeof (errbuf), "%s: %s", device, strerror (errno));
       free (device);
       return errbuf;

Reply via email to