From: Bruno Haible Date: Sun, 20 Aug 2023 20:34:39 +0000 (+0200) Subject: readutmp, boot-time: Fix the result on runit and s6 init systems. X-Git-Tag: v1.0~877 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=711d11496c4084f21e70542bb6be1966c0e73180;p=gnulib.git readutmp, boot-time: Fix the result on runit and s6 init systems. * lib/boot-time-aux.h (get_linux_boot_time_fallback): Try also /var/lib/urandom/random-seed. Try /var/run/utmp last. --- diff --git a/ChangeLog b/ChangeLog index 764176466f..6575ee12b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-08-20 Bruno Haible + + readutmp, boot-time: Fix the result on runit and s6 init systems. + * lib/boot-time-aux.h (get_linux_boot_time_fallback): Try also + /var/lib/urandom/random-seed. Try /var/run/utmp last. + 2023-08-20 Paul Eggert ldexp: fix INT_MIN infloop diff --git a/lib/boot-time-aux.h b/lib/boot-time-aux.h index e59a0fd03c..e88e7a1e19 100644 --- a/lib/boot-time-aux.h +++ b/lib/boot-time-aux.h @@ -86,15 +86,21 @@ get_linux_uptime (struct timespec *p_uptime) static int get_linux_boot_time_fallback (struct timespec *p_boot_time) { - /* On Alpine Linux, UTMP_FILE is not filled. It is always empty. - So, get the time stamp of a file that gets touched only during the - boot process. */ + /* On Devuan with the 'runit' init system and on Artix with the 's6' init + system, UTMP_FILE contains USER_PROCESS and other entries, but no + BOOT_TIME entry. + On Alpine Linux, UTMP_FILE is not filled. It is always empty. + So, in both cases, get the time stamp of a file that gets touched only + during the boot process. */ const char * const boot_touched_files[] = { "/var/lib/systemd/random-seed", /* seen on distros with systemd */ - "/var/run/utmp", /* seen on distros with OpenRC */ - "/var/lib/random-seed" /* seen on older distros */ + "/var/lib/urandom/random-seed", /* seen on Devuan with runit */ + "/var/lib/random-seed", /* seen on Artix with s6 */ + /* This must come last, since on several distros /var/run/utmp is + modified when a user logs in, i.e. long after boot. */ + "/var/run/utmp" /* seen on Alpine Linux with OpenRC */ }; for (idx_t i = 0; i < SIZEOF (boot_touched_files); i++) {