[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug#64937: "who" reports funny dates
From: |
Bruno Haible |
Subject: |
Re: bug#64937: "who" reports funny dates |
Date: |
Fri, 04 Aug 2023 15:28:53 +0200 |
Paul Eggert wrote:
> 0002-readutmp-go-back-to-simple-free.patch
When I run this on a Fedora Rawhide machine, I see that the ut_host
field's contents is now botched.
See: I added a printout of the ut_host field, surrounded by |...|.
Previously, I got
=======================================================================================
Here are the read_utmp results.
Flags: B = Boot, U = User Process
Termi‐ Flags
Time (GMT) User Device PID nation Exit B U
------------------- ------------------ ----------- ---------- ------ ---- - -
2023-07-30 09:25:47 bruno seat0 1593 0 0 X
||
2023-07-30 09:25:47 bruno tty2 1593 0 0 X
||
2023-07-31 22:59:16 reboot ~ 0 0 0 X
||
2023-08-01 15:19:25 other sshd pts/4 40513 0 0 X
|::1|
=======================================================================================
Now, I get:
=======================================================================================
Here are the read_utmp results.
Flags: B = Boot, U = User Process
Termi‐ Flags
Time (GMT) User Device PID nation Exit B U
------------------- ------------------ ----------- ---------- ------ ---- - -
2023-07-30 09:25:47 bruno seat0 1593 0 0 X
|sseat0|
2023-07-30 09:25:47 bruno tty2 1593 0 0 X
|ttty2|
2023-07-31 22:59:16 reboot ~ 0 0 0 X
|~~|
2023-08-01 15:19:25 other sshd pts/4 40513 0 0 X
|sshdsshd pts/4|
=======================================================================================
This shows that the unit test should better print the ut_host's value, even if
that makes the printout's width larger than 80 columns.
2023-08-04 Bruno Haible <bruno@clisp.org>
readutmp: In systemd mode, fix the ut_host contents (regr. yesterday).
* lib/readutmp.c (add_utmp): Fix ut_host contents.
* tests/test-readutmp.c (main): Show also the contents of the ut_host
field.
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 01c02ad36e..ac1c851e97 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -280,7 +280,7 @@ add_utmp (struct utmp_alloc a, int options,
ut->ut_user = p = memcpy (p - usersize, user, usersize);
ut->ut_id = p = memcpy (p - idsize, id, idsize);
ut->ut_line = p = memcpy (p - linesize, line, linesize);
- ut->ut_host = memcpy (p - hostsize, line, hostsize);
+ ut->ut_host = memcpy (p - hostsize, host, hostsize);
ut->ut_ts = ts;
ut->ut_pid = pid;
ut->ut_session = session;
diff --git a/tests/test-readutmp.c b/tests/test-readutmp.c
index 7afba18b87..a11e247bf5 100644
--- a/tests/test-readutmp.c
+++ b/tests/test-readutmp.c
@@ -57,8 +57,8 @@ main (int argc, char *argv[])
printf ("Flags: B = Boot, U = User Process\n");
printf ("\n");
printf ("
Termi‐ Flags\n");
- printf (" Time (GMT) User Device PID
nation Exit B U\n");
- printf ("------------------- ------------------ ----------- ----------
------ ---- - -\n");
+ printf (" Time (GMT) User Device PID
nation Exit B U Host\n");
+ printf ("------------------- ------------------ ----------- ----------
------ ---- - - ----\n");
/* What do the results look like?
* On Alpine Linux, Cygwin, Android, the output is empty.
@@ -111,6 +111,7 @@ main (int argc, char *argv[])
long pid = UT_PID (entry);
int termination = UT_EXIT_E_TERMINATION (entry);
int exit = UT_EXIT_E_EXIT (entry);
+ const char *host = entry->ut_host;
time_t tim = UT_TIME_MEMBER (entry);
struct tm *gmt = gmtime (&tim);
@@ -120,7 +121,7 @@ main (int argc, char *argv[])
== 0)
strcpy (timbuf, "---");
- printf ("%-19s %-18s %-11s %10ld %4d %3d %c %c\n",
+ printf ("%-19s %-18s %-11s %10ld %4d %3d %c %c %s\n",
timbuf,
user,
device,
@@ -128,7 +129,8 @@ main (int argc, char *argv[])
termination,
exit,
UT_TYPE_BOOT_TIME (entry) ? 'X' : ' ',
- UT_TYPE_USER_PROCESS (entry) ? 'X' : ' ');
+ UT_TYPE_USER_PROCESS (entry) ? 'X' : ' ',
+ host);
}
fflush (stdout);
- Re: bug#64937: "who" reports funny dates, Bruno Haible, 2023/08/01
- Message not available
- Re: bug#64937: "who" reports funny dates, Thorsten Kukuk, 2023/08/04
- Re: bug#64937: "who" reports funny dates, Paul Eggert, 2023/08/06
- Re: bug#64937: "who" reports funny dates, Paul Eggert, 2023/08/06
- Message not available
- Re: bug#64937: "who" reports funny dates, Thorsten Kukuk, 2023/08/06
- Re: bug#64937: "who" reports funny dates, Paul Eggert, 2023/08/06
- Message not available
- Re: bug#64937: "who" reports funny dates, Thorsten Kukuk, 2023/08/06
- Re: bug#64937: "who" reports funny dates, Paul Eggert, 2023/08/06
- Re: bug#64937: "who" reports funny dates, Bruno Haible, 2023/08/07