]> Savannah Git Hosting - gnulib.git/commitdiff
boot-time: port to Alpine 3.20.0_rc2
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 21 May 2024 22:49:40 +0000 (15:49 -0700)
committerBruno Haible <bruno@clisp.org>
Wed, 22 May 2024 08:55:15 +0000 (10:55 +0200)
* lib/boot-time-aux.h (get_openbsd_boot_time):
Port to Alpine Linux, which had bogus timestamps on /var/run/utmp.

ChangeLog
lib/boot-time-aux.h

index dd5dd8c2a2620eb1274313f60f907d21699e505e..2c0e56722f283339fb60deedabf2cc8af98f98c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-21  Paul Eggert  <eggert@cs.ucla.edu>
+
+       boot-time: port to Alpine 3.20.0_rc2
+       * lib/boot-time-aux.h (get_openbsd_boot_time):
+       Port to Alpine Linux, which had bogus timestamps on /var/run/utmp.
+
 2024-05-20  Bruno Haible  <bruno@clisp.org>
 
        vasnprintf: Don't abort for pseudo-denormal arguments on macOS 12.
index 7f8c5405e4c09e03b0c926734c8439298014043c..b1add3023912afa289ee664d99f12f59a9191c49 100644 (file)
@@ -108,8 +108,16 @@ get_linux_boot_time_fallback (struct timespec *p_boot_time)
       struct stat statbuf;
       if (stat (filename, &statbuf) >= 0)
         {
-          *p_boot_time = get_stat_mtime (&statbuf);
-          return 0;
+          struct timespec boot_time = get_stat_mtime (&statbuf);
+          /* On Alpine 3.20.0_rc2 /var/run/utmp was observed with bogus
+             timestamps of ~10 s.  Reject timestamps before
+             2005-07-25 23:34:15 UTC (1122334455), as neither Alpine
+             nor Devuan existed then.  */
+          if (boot_time.tv_sec >= 1122334455)
+            {
+              *p_boot_time = boot_time;
+              return 0;
+            }
         }
     }
   return -1;