On 30/07/2023 14:21, Bruno Haible wrote:
Paul Eggert wrote:
+static void
+copy_utmp_entry (STRUCT_UTMP *dst, STRUCT_UTMP *src)
+{
+#if __GLIBC__ && _TIME_BITS == 64
+ /* Convert from external form in SRC to internal form in DST.
+ It is OK to convert now, rather than earlier, before
+ desirable_utmp_entry was invoked, because desirable_utmp_entry
+ inspects only the leading prefix of the entry, which is the
+ same in both external and internal forms. */
This code needs a unit test, if it wants to be future-proof. I'm
therefore adding one, and a few comment tweaks (as the existing
comments did not make everything 100% clear).
A small issue with the readutmp test is it fails on systems with an uptime >= 5
years.
cfarm135 is such a system currently, and the test fails like:
FAIL: test-readutmp
===================
Here are the read_utmp results.
Flags: B = Boot, U = User Process
Time (GMT) User Device PID nation Exit B U
Host
------------------- ------------------ ----------- ---------- ------ ---- - -
----
2019-10-01 22:30:08 runlevel ~ 51 0 0
4.18.0-80.7.2.el7.ppc64le
2019-10-01 23:08:29 pts/0 23591 0 0
2019-10-02 15:29:19 LOGIN hvc0 45770 0 0
2019-10-02 22:29:16 reboot ~ 0 0 0 X
4.18.0-80.7.2.el7.ppc64le
2019-10-02 22:29:26 LOGIN tty1 6300 0 0
...
2025-01-14 17:49:50 pixelbeat pts/2 77796 0 0 X
86.44.211.146
test-readutmp.c:146: assertion 'first >= now - 157680000' failed
FAIL test-readutmp (exit status: 134)
cheers,
Pádraig