core: allow disabling system time correction if rtc returns time far in the future
There might be (embedded) systems that get never updated (things like
e.g. entertainment systems of trains, for example) and where the adjustment of
the system clock (introduced by b10abe4bba) would
do the wrong thing even if the difference between the systemd build time and
the rtc is 15 years or more.
This patch allows disabling the adjustment by setting
'clock-valid-range-usec-max' meson option to 0 or to a negative value.
This commit is contained in:
committed by
Luca Boccassi
parent
34683dbdd0
commit
2306b4656a
@@ -153,7 +153,7 @@ int clock_apply_epoch(ClockChangeDirection *ret_attempted_change) {
|
||||
now_usec = now(CLOCK_REALTIME);
|
||||
if (now_usec < epoch_usec)
|
||||
*ret_attempted_change = CLOCK_CHANGE_FORWARD;
|
||||
else if (now_usec > usec_add(epoch_usec, CLOCK_VALID_RANGE_USEC_MAX))
|
||||
else if (CLOCK_VALID_RANGE_USEC_MAX > 0 && now_usec > usec_add(epoch_usec, CLOCK_VALID_RANGE_USEC_MAX))
|
||||
*ret_attempted_change = CLOCK_CHANGE_BACKWARD;
|
||||
else {
|
||||
*ret_attempted_change = CLOCK_CHANGE_NOOP;
|
||||
|
||||
Reference in New Issue
Block a user