From: Paul Eggert Date: Thu, 3 Aug 2023 23:01:52 +0000 (-0700) Subject: readutmp: systemd supports only UTMP_FILE X-Git-Tag: v1.0~968 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9765d190a95f379c1b690ccbf6f3cb1a62f1c803;p=gnulib.git readutmp: systemd supports only UTMP_FILE * lib/readutmp.c (read_utmp): Fail if not UTMP_FILE. * m4/systemd.m4 (gl_SYSTEMD_CHOICE): Default to no for now, since yes means "who /var/log/wtmp" stops working. --- diff --git a/ChangeLog b/ChangeLog index 133f49df97..8730fd9bc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2023-08-03 Paul Eggert + readutmp: systemd supports only UTMP_FILE + * lib/readutmp.c (read_utmp): Fail if not UTMP_FILE. + * m4/systemd.m4 (gl_SYSTEMD_CHOICE): Default to no for now, + since yes means "who /var/log/wtmp" stops working. + readutmp: switch new struct to struct timespec * lib/readutmp.c (get_boot_time_uncached, get_boot_time) (add_utmp, read_utmp): diff --git a/lib/readutmp.c b/lib/readutmp.c index 113382c636..c692b3854d 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -305,6 +305,13 @@ int read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { + /* The current implementation can imitate only UTMP_FILE. */ + if (strcmp (file, UTMP_FILE) != 0) + { + errno = ENOTSUP; + return -1; + } + /* Fill entries, simulating what a utmp file would contain. */ struct utmp_alloc a = {0}; diff --git a/m4/systemd.m4 b/m4/systemd.m4 index 0c919385b2..c54e2fb47f 100644 --- a/m4/systemd.m4 +++ b/m4/systemd.m4 @@ -1,4 +1,4 @@ -# systemd.m4 serial 1 +# systemd.m4 serial 2 dnl Copyright (C) 2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,9 +10,9 @@ AC_DEFUN([gl_SYSTEMD_CHOICE], [ AC_MSG_CHECKING([whether to use systemd APIs]) AC_ARG_ENABLE([systemd], - [ --disable-systemd do not use systemd APIs], + [ --enable-systemd use systemd APIs], [SYSTEMD_CHOICE="$enableval"], - [SYSTEMD_CHOICE=yes]) + [SYSTEMD_CHOICE=no]) AC_MSG_RESULT([$SYSTEMD_CHOICE]) AC_SUBST([SYSTEMD_CHOICE]) ])