]> 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)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 21 May 2024 22:51:10 +0000 (15:51 -0700)
* 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 099a2492714a2222325119d5031c4c498c2e22fb..0baff3aecce8f917da3b68c93864572f35093e46 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-21  Bruno Haible  <bruno@clisp.org>
 
        trim tests: Avoid test failure on Solaris 11 OmniOS.
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;