bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] readutmp: work around glibc utmpx bug


From: Bruno Haible
Subject: Re: [PATCH] readutmp: work around glibc utmpx bug
Date: Mon, 31 Jul 2023 22:15:17 +0200

I wrote:
> * The test fails on OpenBSD 7.2, because the smallest time in the entries
>   is 1970-01-01.

With this patch, the unit test passes on OpenBSD.


2023-07-31  Bruno Haible  <bruno@clisp.org>

        readutmp: Fix test failure on OpenBSD.
        * lib/readutmp.c (desirable_utmp_entry): On OpenBSD, eliminate entirely
        empty entries.

diff --git a/lib/readutmp.c b/lib/readutmp.c
index 82dbe69506..6a5509054e 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -76,6 +76,12 @@ desirable_utmp_entry (STRUCT_UTMP const *ut, int options)
       && 0 < UT_PID (ut)
       && (kill (UT_PID (ut), 0) < 0 && errno == ESRCH))
     return false;
+# if defined __OpenBSD__ && !HAVE_UTMPX_H
+  /* Eliminate entirely empty entries.  */
+  if (UT_TIME_MEMBER (ut) == 0 && UT_USER (ut)[0] == '\0'
+      && ut->ut_line[0] == '\0' && ut->ut_host[0] == '\0')
+    return false;
+# endif
   return true;
 }
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]