mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 18:45:07 -05:00
ntp: print warning 10 years before supported time ends
This commit is contained in:
13
ntp_core.c
13
ntp_core.c
@@ -262,6 +262,9 @@ do_size_checks(void)
|
|||||||
static void
|
static void
|
||||||
do_time_checks(void)
|
do_time_checks(void)
|
||||||
{
|
{
|
||||||
|
struct timeval now;
|
||||||
|
time_t warning_advance = 3600 * 24 * 365 * 10; /* 10 years */
|
||||||
|
|
||||||
#ifdef HAVE_LONG_TIME_T
|
#ifdef HAVE_LONG_TIME_T
|
||||||
/* Check that time before NTP_ERA_SPLIT underflows correctly */
|
/* Check that time before NTP_ERA_SPLIT underflows correctly */
|
||||||
|
|
||||||
@@ -278,6 +281,16 @@ do_time_checks(void)
|
|||||||
tv1.tv_sec + (1ULL << 32) - 1 == tv2.tv_sec;
|
tv1.tv_sec + (1ULL << 32) - 1 == tv2.tv_sec;
|
||||||
|
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&now);
|
||||||
|
if (tv2.tv_sec - now.tv_sec < warning_advance)
|
||||||
|
LOG(LOGS_WARN, LOGF_NtpCore, "Assumed NTP time ends at %s!",
|
||||||
|
UTI_TimeToLogForm(tv2.tv_sec));
|
||||||
|
#else
|
||||||
|
LCL_ReadRawTime(&now);
|
||||||
|
if (now.tv_sec > 0x7fffffff - warning_advance)
|
||||||
|
LOG(LOGS_WARN, LOGF_NtpCore, "System time ends at %s!",
|
||||||
|
UTI_TimeToLogForm(0x7fffffff));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user