]> Savannah Git Hosting - gnulib.git/commitdiff
readutmp, boot-time: Fix the result on runit and s6 init systems.
authorBruno Haible <bruno@clisp.org>
Sun, 20 Aug 2023 20:34:39 +0000 (22:34 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 20 Aug 2023 20:36:48 +0000 (22:36 +0200)
* lib/boot-time-aux.h (get_linux_boot_time_fallback): Try also
/var/lib/urandom/random-seed. Try /var/run/utmp last.

ChangeLog
lib/boot-time-aux.h

index 764176466ff73b2fb6d2304242c1f0d0bb5906a0..6575ee12b6301bd52f5d3d591184e15c4b4f28a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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
index e59a0fd03c7ce514d89553d34913a32c8e2d558c..e88e7a1e192d57ba4607e5951a0ed6e317bee084 100644 (file)
@@ -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++)
     {