From nobody@FreeBSD.org  Sun Feb  7 10:33:21 2010
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 70B161065670
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Feb 2010 10:33:21 +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 634148FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Feb 2010 10:33:21 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o17AXKHr022077
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 7 Feb 2010 10:33:20 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o17AXKUa022076;
	Sun, 7 Feb 2010 10:33:20 GMT
	(envelope-from nobody)
Message-Id: <201002071033.o17AXKUa022076@www.freebsd.org>
Date: Sun, 7 Feb 2010 10:33:20 GMT
From: Erik Norgaard <norgaard@locolomo.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ntpdate support for ntp-servers supplied by dhcp [PATCH]
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143637
>Category:       conf
>Synopsis:       [patch] ntpdate(8) support for ntp-servers supplied by dhcp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 07 10:40:00 UTC 2010
>Closed-Date:    
>Last-Modified:  Sun Feb 07 13:11:32 UTC 2010
>Originator:     Erik Norgaard
>Release:        FreeBSD 8.0-STABLE
>Organization:
none
>Environment:
FreeBSD alpha.locolomo.org 8.0-STABLE FreeBSD 8.0-STABLE #0: Mon Feb  1 09:30:59 CET 2010     norgaard@alpha.locolomo.org:/usr/local/obj/usr/local/src/sys/GENERIC  i386

>Description:
The rc script, /etc/rc.d/ntpdate does not support configuring ntp
servers with the dhcp option ntp-servers. When the option ntp-servers
is configured in dhcpd.conf, this is supplied to the client and stored
in the kernel environment, dhcp.ntp-servers. 

The patch set ntpdate_hosts if not set in rc.conf or ntp.conf using the
dhcp option.
>How-To-Repeat:

>Fix:
Apply the supplied patch

Patch attached with submission follows:

--- /etc/rc.d/ntpdate.old	2010-02-07 10:37:55.000000000 +0100
+++ /etc/rc.d/ntpdate	2010-02-07 11:27:06.000000000 +0100
@@ -22,8 +22,12 @@
 			/^(server|peer)/            {print $2}
 		' < ${ntpdate_config}`
 	fi
+	if [ -z "$ntpdate_hosts" -a \
+		-n "`/bin/kenv dhcp.ntp-servers 2> /dev/null`" ]; then
+		ntpdate_hosts=`/bin/kenv dhcp.ntp-servers | sed 's/,/ /g'`
+	fi
 	if [ -n "$ntpdate_hosts" -o -n "$rc_flags" ]; then
-		echo "Setting date via ntp."
+		echo "Setting date via ntp: $ntpdate_hosts"
 		${ntpdate_program:-ntpdate} $rc_flags $ntpdate_hosts
 	fi
 }


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Feb 7 13:09:53 UTC 2010 
Responsible-Changed-Why:  
Patch against /etc/rc.d/ntpdate. 

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