From 281ec163e9faf05abe239938b857f5e1a06dd515 Mon Sep 17 00:00:00 2001 From: naddy <> Date: Wed, 14 Jan 2015 21:14:27 +0000 Subject: [PATCH] Switch drift file format to ppm for compatibility with the ntp.org daemon. Old drift files will be interpreted as a minuscule adjustment and ntpd will proceed to rediscover the drift, like starting from zero on a newly installed machine. ok deraadt@ --- src/usr.sbin/ntpd/ntpd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index 972849c8..9796c341 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.85 2015/01/13 14:52:47 bcook Exp $ */ +/* $OpenBSD: ntpd.c,v 1.86 2015/01/14 21:14:27 naddy Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -494,9 +494,10 @@ readfreq(void) if (adjfreq(NULL, ¤t) == -1) log_warn("adjfreq failed"); else if (current == 0) { - if (fscanf(fp, "%le", &d) == 1) + if (fscanf(fp, "%lf", &d) == 1) { + d /= 1e6; /* scale from ppm */ ntpd_adjfreq(d, 0); - else + } else log_warnx("can't read %s", DRIFTFILE); } fclose(fp); @@ -518,7 +519,7 @@ writefreq(double d) return 0; } - fprintf(fp, "%e\n", d); + fprintf(fp, "%.3f\n", d * 1e6); /* scale to ppm */ r = ferror(fp); if (fclose(fp) != 0 || r != 0) { if (warnonce) {