From: Bruno Haible Date: Mon, 31 Jul 2023 20:12:51 +0000 (+0200) Subject: readutmp: Fix test failure on OpenBSD. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=08180821e67144b19cd1f7a0ff167ec753be178e;p=gnulib.git readutmp: Fix test failure on OpenBSD. * lib/readutmp.c (desirable_utmp_entry): On OpenBSD, eliminate entirely empty entries. --- diff --git a/ChangeLog b/ChangeLog index 526f6b8cbc..c2521c302e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-07-31 Bruno Haible + + readutmp: Fix test failure on OpenBSD. + * lib/readutmp.c (desirable_utmp_entry): On OpenBSD, eliminate entirely + empty entries. + 2023-07-30 Bruno Haible readutmp: Improve comments. Fix module description. diff --git a/lib/readutmp.c b/lib/readutmp.c index acffe1000e..b357ac27ad 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -74,6 +74,12 @@ desirable_utmp_entry (STRUCT_UTMP const *u, int options) && 0 < UT_PID (u) && (kill (UT_PID (u), 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; }