From 08180821e67144b19cd1f7a0ff167ec753be178e Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 31 Jul 2023 22:12:51 +0200 Subject: [PATCH] readutmp: Fix test failure on OpenBSD. * lib/readutmp.c (desirable_utmp_entry): On OpenBSD, eliminate entirely empty entries. --- ChangeLog | 6 ++++++ lib/readutmp.c | 6 ++++++ 2 files changed, 12 insertions(+) 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; } -- 2.39.5