From nobody@FreeBSD.org  Tue Mar 10 19:05:00 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id CFD4C10658B3
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Mar 2009 19:05:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id BC54A8FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Mar 2009 19:05:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n2AJ503X021862
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 Mar 2009 19:05:00 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n2AJ50qd021861;
	Tue, 10 Mar 2009 19:05:00 GMT
	(envelope-from nobody)
Message-Id: <200903101905.n2AJ50qd021861@www.freebsd.org>
Date: Tue, 10 Mar 2009 19:05:00 GMT
From: Josh Paetzel <jpaetzel@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ntpd_sync_on_start option in /etc/rc.conf misbehaves
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         132515
>Category:       conf
>Synopsis:       ntpd_sync_on_start option in /etc/rc.conf misbehaves
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jpaetzel
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 10 19:10:01 UTC 2009
>Closed-Date:    Tue Jun 18 06:47:46 UTC 2013
>Last-Modified:  Tue Jun 18 06:47:46 UTC 2013
>Originator:     Josh Paetzel
>Release:        6.4-RELEASE
>Organization:
Prometheus Research
>Environment:
FreeBSD virt.tcbug.org 6.4-RELEASE FreeBSD 6.4-RELEASE #0: Mon Dec 22 01:35:53 UTC 2008     jpaetzel@virt.tcbug.org:/usr/obj/usr/src/sys/VIRT  amd64
>Description:
Setting ntpd_sync_on_start="YES" in /etc/rc.conf is not a drop in replacement for the depricated ntpdate

In order to mimic ntpdate's functiomnality, ntpd needs to be started with the -q -x -g flags, which causes it to exit.

As the rc script stands, ntpd_sync_on_start="YES" only adds -g to ntpd's startup
>How-To-Repeat:
ntpd_enable="YES"
ntpd_sync_on_start="YES" in /etc/rc.conf

then slew your time way off

then reboot

ntpd will be started on boot, but won't have synced the time up correctly


>Fix:
As a very naive fix, and more of a proof of concept thing, I tried...

--- /etc/rc.d/ntpd      2008-11-28 11:54:08.000000000 -0600
+++ ntpd        2009-03-10 07:05:46.000000000 -0500
@@ -4,8 +4,7 @@
 #
 
 # PROVIDE: ntpd
-# REQUIRE: DAEMON ntpdate cleanvar devfs
-# BEFORE:  LOGIN
+# REQUIRE: mount_gbde
 # KEYWORD: nojail
 
 . /etc/rc.subr
@@ -23,7 +22,8 @@
        rc_flags="-c ${ntpd_config} ${ntpd_flags}"
 
        if checkyesno ntpd_sync_on_start; then
-               rc_flags="-g $rc_flags"
+               #rc_flags="-g $rc_flags"
+                ntpd -g -q -x
        fi
 
        if [ -z "$ntpd_chrootdir" ]; then


Ignore the REQUIRE changes, the problem and fix was verified on a stock 6.4, I just didn't have access to that box when I wrote this.



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->stas 
Responsible-Changed-By: stas 
Responsible-Changed-When: Tue Mar 10 19:17:34 UTC 2009 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132515 

From: Bruce Cran <bruce@cran.org.uk>
To: bug-followup@FreeBSD.org, jpaetzel@FreeBSD.org
Cc:  
Subject: Re: conf/132515: ntpd_sync_on_start option in /etc/rc.conf
 misbehaves
Date: Tue, 23 Nov 2010 11:42:15 +0000

 /usr/bin/sntp should be used if we want to set the clock as quickly as
 ntpdate.

From: Sahil Tandon <sahil@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc: jpaetzel@FreeBSD.org, stas@FreeBSD.org
Subject: Re: conf/132515: ntpd_sync_on_start option in /etc/rc.conf
 misbehaves
Date: Sun, 8 May 2011 12:25:40 -0400

 I cannot reproduced this problem on 7.4-RELEASE.  After manually setting
 the clock back by over 30 minutes, ntpd_sync_on_start works as
 documented upon reboot.  Has anyone been able to reproduce the problem
 on a suported (i.e. newer than 6.4) release?
 
 -- 
 Sahil Tandon <sahil@FreeBSD.org>
Responsible-Changed-From-To: stas->freebsd-ports-bugs 
Responsible-Changed-By: tabthorpe 
Responsible-Changed-When: Sat Nov 5 04:11:47 UTC 2011 
Responsible-Changed-Why:  
- back to the heap 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132515 
Responsible-Changed-From-To: freebsd-ports-bugs->stas 
Responsible-Changed-By: tabthorpe 
Responsible-Changed-When: Sat Nov 5 05:12:06 UTC 2011 
Responsible-Changed-Why:  
Fix assignment 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132515 
State-Changed-From-To: open->closed 
State-Changed-By: jpaetzel 
State-Changed-When: Tue Jun 18 06:47:00 UTC 2013 
State-Changed-Why:  
Long since irrelevent. 


Responsible-Changed-From-To: stas->jpaetzel 
Responsible-Changed-By: jpaetzel 
Responsible-Changed-When: Tue Jun 18 06:47:00 UTC 2013 
Responsible-Changed-Why:  
Long since irrelevent. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132515 
>Unformatted:
