When uuidd starts with --cont-clock enabled and reads a stale timestamp
from the state file, the continuous clock logic would apply a backwards
offset (default 2 hours), causing generated UUIDs to have incorrect
timestamps in the past.
Fix this by resetting last_clock_reg to the current time when the saved
timestamp is older than the current clock. This prevents the backwards
offset from being applied at service start.
[kzak@redhat.com: - fix comment, add commit message]
Fixes: https://github.com/util-linux/util-linux/issues/4018
Signed-off-by: Karel Zak <kzak@redhat.com>
rewind(state_f);
if (fscanf(state_f, "cont: %"SCNu64"\n", &last_clock_reg) != 1)
goto error;
+ /* don't use old timestamps, reset to current time */
+ if (last_clock_reg < clock_reg)
+ last_clock_reg = clock_reg;
} else
last_clock_reg = clock_reg;