From: Bruno Haible Date: Sun, 30 Jul 2023 14:30:08 +0000 (+0200) Subject: uptime: output correct user count on OpenBSD X-Git-Tag: v9.4~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a102826245505986bf336b87e081f1fdb44469d8;p=thirdparty%2Fcoreutils.git uptime: output correct user count on OpenBSD * src/uptime.c (print_uptime, uptime): Always call read_utmp and count the result. * NEWS: Mention the fix (text by Bruno Haible). --- diff --git a/NEWS b/NEWS index 92e591ee2e..41205fa885 100644 --- a/NEWS +++ b/NEWS @@ -46,6 +46,9 @@ GNU coreutils NEWS -*- outline -*- 'pr --length=1 --double-space' no longer enters an infinite loop. [This bug was present in "the beginning".] + 'uptime' no longer incorrectly prints "0 users" on OpenBSD. + [bug introduced in coreutils-9.2] + 'wc -l' and 'cksum' no longer crash with an "Illegal instruction" error on x86 Linux kernels that disable XSAVE YMM. This was seen on Xen VMs. [bug introduced in coreutils-9.0] diff --git a/src/uptime.c b/src/uptime.c index bc31026c0e..b9d5e3c02f 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -100,7 +100,6 @@ print_uptime (size_t n, const STRUCT_UTMP *this) } #endif -#if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE /* Loop through all the utmp entries we just read and count up the valid ones, also in the process possibly gleaning boottime. */ while (n--) @@ -110,10 +109,6 @@ print_uptime (size_t n, const STRUCT_UTMP *this) boot_time = UT_TIME_MEMBER (this); ++this; } -#else - (void) n; - (void) this; -#endif time_now = time (nullptr); #if defined HAVE_PROC_UPTIME @@ -177,10 +172,8 @@ uptime (char const *filename, int options) size_t n_users; STRUCT_UTMP *utmp_buf = nullptr; -#if HAVE_STRUCT_UTMP_UT_TYPE || HAVE_STRUCT_UTMPX_UT_TYPE if (read_utmp (filename, &n_users, &utmp_buf, options) != 0) error (EXIT_FAILURE, errno, "%s", quotef (filename)); -#endif print_uptime (n_users, utmp_buf);