* lib/boot-time-aux.h (get_openbsd_boot_time):
Port to Alpine Linux, which had bogus timestamps on /var/run/utmp.
---
 ChangeLog           |  6 ++++++
 lib/boot-time-aux.h | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 099a249271..0baff3aecc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-21  Paul Eggert  <egg...@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  <br...@clisp.org>
 
        trim tests: Avoid test failure on Solaris 11 OmniOS.
diff --git a/lib/boot-time-aux.h b/lib/boot-time-aux.h
index 7f8c5405e4..b1add30239 100644
--- a/lib/boot-time-aux.h
+++ b/lib/boot-time-aux.h
@@ -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;
-- 
2.45.1


Reply via email to