bug-coreutils
[Top][All Lists]
Advanced

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

bug#64954: GNU 'uptime' on OpenBSD always prints "0 users"


From: Bruno Haible
Subject: bug#64954: GNU 'uptime' on OpenBSD always prints "0 users"
Date: Sun, 30 Jul 2023 16:44:25 +0200

Hi,

GNU coreutils-9.3 'uptime', on OpenBSD 7.2, prints

 16:24:53  up 14 days 13:33,  0 users,  load average: 0.04, 0.44, 0.59

whereas the OpenBSD /usr/bin/uptime prints

 4:24PM  up 14 days, 13:33, 1 user, load averages: 0.04, 0.44, 0.59

The utmp file contain these entries:

    Time (GMT)           User          PID     Term Exit Boot User Process
------------------- --------------- ---------- ---- ---- ---- ------------
1970-01-01 00:00:00                          0   0    0            
1970-01-01 00:00:00                          0   0    0            
2023-07-16 00:52:00 bruno                    0   0    0            

The readutmp.h code, in particular the IS_USER_PROCESS macro, works fine.
(UT_TYPE_USER_PROCESS (U) expands to 0, and UT_TYPE_NOT_DEFINED expands to 1.)

The problem is that the readutmp code is entirely disabled on this platform.
Which is not appropriate.

When I revert the coreutils commit 2984e47c789ebc39f55a3b1cb20b943de88eeedc,
the coreutils 'uptime' program prints "1 user", as expected.

The rationale of that commit was wrong:
"Following gnulib commit 9041103 HAVE_UTMP_H will always be defined."
No, what that gnulib commit did is to create an <utmp.h> replacement
if the package imports the 'login_tty' module. But the HAVE_UTMP_H
is *still* only defined if the platform provides it.
Proof: On FreeBSD 13.2, which does not have <utmp.h> (it has <utmpx.h>
instead), configuring coreutils-9.3 produces the attached config.h,
which has

#define HAVE_UTMPX_H 1
/* #undef HAVE_UTMP_H */

So, find attached the fix of the bug.

Attachment: freebsd-13.2-config.h
Description: Text Data

Attachment: 0001-uptime-Print-the-correct-number-of-users-on-OpenBSD.patch
Description: Text Data


reply via email to

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