+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.
+
2023-08-04 Bruno Haible <bruno@clisp.org>
readutmp: Ensure multithread-safety.
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;
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.
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);
== 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,
termination,
exit,
UT_TYPE_BOOT_TIME (entry) ? 'X' : ' ',
- UT_TYPE_USER_PROCESS (entry) ? 'X' : ' ');
+ UT_TYPE_USER_PROCESS (entry) ? 'X' : ' ',
+ host);
}
fflush (stdout);