+2023-08-20 Bruno Haible <bruno@clisp.org>
+
+ 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 <eggert@cs.ucla.edu>
ldexp: fix INT_MIN infloop
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++)
{