For the first time during the current boot an NTP synchronization has been
acquired and the local system clock adjustment has been initiated.
+-- 7db73c8af0d94eeb822ae04323fe6ab6
+Subject: Initial clock bump
+Defined-By: systemd
+Support: %SUPPORT_URL%
+
+The system clock has been advanced based on a timestamp file on disk, in order
+to ensure it remains roughly monotonic – even across reboots – if an RTC is not
+available or is unreliable.
+
-- 3f7d5ef3e54f4302b4f0b143bb270cab
Subject: TPM PCR Extended
Defined-By: systemd
#define SD_MESSAGE_TIME_SYNC SD_ID128_MAKE(7c,8a,41,f3,7b,76,49,41,a0,e1,78,0b,1b,e2,f0,37)
#define SD_MESSAGE_TIME_SYNC_STR SD_ID128_MAKE_STR(7c,8a,41,f3,7b,76,49,41,a0,e1,78,0b,1b,e2,f0,37)
+#define SD_MESSAGE_TIME_BUMP SD_ID128_MAKE(7d,b7,3c,8a,f0,d9,4e,eb,82,2a,e0,43,23,fe,6a,b6)
+#define SD_MESSAGE_TIME_BUMP_STR SD_ID128_MAKE_STR(7d,b7,3c,8a,f0,d9,4e,eb,82,2a,e0,43,23,fe,6a,b6)
+
#define SD_MESSAGE_SHUTDOWN_SCHEDULED SD_ID128_MAKE(9e,70,66,27,9d,c8,40,3d,a7,9c,e4,b1,a6,90,64,b2)
#define SD_MESSAGE_SHUTDOWN_SCHEDULED_STR SD_ID128_MAKE_STR(9e,70,66,27,9d,c8,40,3d,a7,9c,e4,b1,a6,90,64,b2)
#include "sd-daemon.h"
#include "sd-event.h"
+#include "sd-messages.h"
#include "capability-util.h"
#include "clock-util.h"
settime:
ct = now(CLOCK_REALTIME);
- if (ct < min) {
- char date[FORMAT_TIMESTAMP_MAX];
-
- log_info("System clock time unset or jumped backwards, restoring from recorded timestamp: %s",
- format_timestamp(date, sizeof(date), min));
-
- if (clock_settime(CLOCK_REALTIME, TIMESPEC_STORE(min)) < 0)
- log_error_errno(errno, "Failed to restore system clock, ignoring: %m");
+ if (ct > min)
+ return 0;
+
+ /* Not that it matters much, but we actually restore the clock to n+1 here rather than n, simply
+ * because we read n as time previously already and we want to progress here, i.e. not report the
+ * same time again. */
+ if (clock_settime(CLOCK_REALTIME, TIMESPEC_STORE(min+1)) < 0) {
+ log_warning_errno(errno, "Failed to restore system clock, ignoring: %m");
+ return 0;
}
+ log_struct(LOG_INFO,
+ "MESSAGE_ID=" SD_MESSAGE_TIME_BUMP_STR,
+ "REALTIME_USEC=" USEC_FMT, min+1,
+ LOG_MESSAGE("System clock time unset or jumped backwards, restored from recorded timestamp: %s",
+ FORMAT_TIMESTAMP(min+1)));
return 0;
}