]> Savannah Git Hosting - gnulib.git/commit
readutmp: For year-2038 safety on Linux/{x86,arm}, use systemd APIs.
authorBruno Haible <bruno@clisp.org>
Tue, 1 Aug 2023 19:44:07 +0000 (21:44 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 1 Aug 2023 19:44:07 +0000 (21:44 +0200)
commit0b71ff37a7cb0ce546975796f9366eee25be5fb7
tree9e64866a3d3ddea97a888e7733d70b979a49cfed
parent11054898ce29079b2581977c94e26529342fb001
readutmp: For year-2038 safety on Linux/{x86,arm}, use systemd APIs.

Suggested by Thorsten Kukuk <kukuk@suse.com> in
<https://www.thkukuk.de/blog/Y2038_glibc_utmp_64bit/> and
<https://github.com/thkukuk/utmpx/blob/main/utmp-to-logind.md>.

* m4/systemd.m4: New file.
* m4/readutmp.m4 (gl_READUTMP): Require gl_SYSTEMD_CHOICE. Set
READUTMP_LIB. Conditionally define READUTMP_USE_SYSTEMD.
* lib/readutmp.h: For READUTMP_USE_SYSTEMD, include <sys/time.h> and
<utmpx.h>.
(struct gl_utmp): New type.
(UTMP_STRUCT_NAME, UT_TIME_MEMBER, UT_EXIT_E_TERMINATION,
UT_EXIT_E_EXIT, UT_USER, HAVE_STRUCT_XTMP_UT_EXIT,
HAVE_STRUCT_XTMP_UT_ID, HAVE_STRUCT_XTMP_UT_PID): Define differently for
READUTMP_USE_SYSTEMD.
(UT_USER_SIZE): Don't define for READUTMP_USE_SYSTEMD.
(UT_TYPE_EQ, UT_TYPE_NOT_DEFINED, READ_UTMP_SUPPORTED): Define also for
READUTMP_USE_SYSTEMD.
(free_utmp): New declaration.
* lib/readutmp.c: Add new includes for READUTMP_USE_SYSTEMD.
(extract_trimmed_name): Adapt to READUTMP_USE_SYSTEMD.
(get_boot_time_uncached, get_boot_time, guess_pty_name): New functions.
(read_utmp): New implementation for READUTMP_USE_SYSTEMD.
(free_utmp): New function.
* tests/test-readutmp.c (main): At the end, invoke free_utmp.
* modules/readutmp (Files): Add m4/systemd.m4.
(Link): New section.
* modules/readutmp-tests (Makefile.am): Link test-readutmp with
READUTMP_LIB.
* NEWS: Mention the free_utmp function and the READUTMP_LIB link
requirement.
ChangeLog
NEWS
lib/readutmp.c
lib/readutmp.h
m4/readutmp.m4
m4/systemd.m4 [new file with mode: 0644]
modules/readutmp
modules/readutmp-tests
tests/test-readutmp.c