From 40598298edc5b6c9db45dd6f5399c8469e5e161d Mon Sep 17 00:00:00 2001 From: otto <> Date: Thu, 22 Nov 2007 10:22:30 +0000 Subject: [PATCH] if the drift file is missing, reset adjfreq to zero; iirc diff from Glaser from a long time ago. ok ckuethe@ --- src/usr.sbin/ntpd/ntpd.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index 469bdb48..be6fc793 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.52 2007/09/13 20:34:12 jmc Exp $ */ +/* $OpenBSD: ntpd.c,v 1.53 2007/11/22 10:22:30 otto Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -431,20 +431,22 @@ readfreq(void) int64_t current; double d; - /* if we're adjusting frequency already, don't override */ - if (adjfreq(NULL, ¤t) == -1) { - log_warn("adjfreq failed"); - return; - } - if (current != 0) - return; - fp = fopen(DRIFTFILE, "r"); - if (fp == NULL) + if (fp == NULL) { + /* if the drift file has been deleted by the user, reset */ + current = 0; + if (adjfreq(¤t, NULL) == -1) + log_warn("adjfreq reset failed"); return; + } - if (fscanf(fp, "%le", &d) == 1) - ntpd_adjfreq(d, 0); + /* if we're adjusting frequency already, don't override */ + if (adjfreq(NULL, ¤t) == -1) + log_warn("adjfreq failed"); + else if (current == 0) { + if (fscanf(fp, "%le", &d) == 1) + ntpd_adjfreq(d, 0); + } fclose(fp); }