Bug#447071: patches
tags 447071 + patch
thanks
--
dann frazier
Index: debian/clock-setup.postinst
===================================================================
--- debian/clock-setup.postinst (revision 49799)
+++ debian/clock-setup.postinst (working copy)
@@ -13,6 +13,12 @@
fi
db_get clock-setup/ntp
if [ "$RET" = true ]; then
+ db_get netcfg/dhcp_ntp_servers
+ if [ -n "$RET" ]; then
+ # If DHCP provides multiple servers, ignore all but the first
+ dhcp_ntp=`echo $RET | cut -d' ' -f1`
+ db_set clock-setup/ntp-server "$dhcp_ntp"
+ fi
db_input low clock-setup/ntp-server || true
if ! db_go; then
exit 10
Index: debian/netcfg-dhcp.templates
===================================================================
--- debian/netcfg-dhcp.templates (revision 49779)
+++ debian/netcfg-dhcp.templates (working copy)
@@ -68,3 +68,8 @@
Description: for internal use; can be preseeded
Timeout for trying DHCP
Default: 15
+
+Template: netcfg/dhcp_ntp_servers
+Type: text
+Description: for internal use
+ NTP servers provided by DHCP
Index: dhclient-script
===================================================================
--- dhclient-script (revision 49779)
+++ dhclient-script (working copy)
@@ -89,6 +89,10 @@
# Get the domain name into a file suitable for netcfg to read.
echo -n "$new_domain_name" > /tmp/domain_name
+ if [ -n "$new_ntp_servers" ]; then
+ echo -n "$new_ntp_servers" > /tmp/dhcp-ntp-servers
+ fi
+
;;
EXPIRE|FAIL|RELEASE|STOP)
Index: netcfg.h
===================================================================
--- netcfg.h (revision 49779)
+++ netcfg.h (working copy)
@@ -9,6 +9,7 @@
#define DHCLIENT_CONF "/etc/dhclient.conf"
#define DHCLIENT3_CONF "/etc/dhcp3/dhclient.conf"
#define DOMAIN_FILE "/tmp/domain_name"
+#define NTP_SERVER_FILE "/tmp/dhcp-ntp-servers"
#define DEVNAMES "/etc/network/devnames"
#define DEVHOTPLUG "/etc/network/devhotplug"
Index: dhcp.c
===================================================================
--- dhcp.c (revision 49779)
+++ dhcp.c (working copy)
@@ -21,6 +21,10 @@
#include <time.h>
#include <netdb.h>
+#define DHCLIENT_REQUEST_DEFAULTS \
+ "subnet-mask, broadcast-address, time-offset, routers, domain-name, \
+ domain-name-servers, host-name"
+#define DHCLIENT_REQUEST_EXTRAS "ntp-servers"
static int dhcp_exit_status = 1;
static pid_t dhcp_pid = -1;
@@ -142,6 +146,8 @@
if ((dc = file_open(DHCLIENT_CONF, "w"))) {
fprintf(dc, "send dhcp-class-identifier \"d-i\";\n" );
+ fprintf(dc, "request " DHCLIENT_REQUEST_DEFAULTS", " \
+ DHCLIENT_REQUEST_EXTRAS";\n" );
if (dhostname) {
fprintf(dc, "send host-name \"%s\";\n", dhostname);
}
@@ -156,6 +162,8 @@
if ((dc = file_open(DHCLIENT3_CONF, "w"))) {
fprintf(dc, "send vendor-class-identifier \"d-i\";\n" );
+ fprintf(dc, "request " DHCLIENT_REQUEST_DEFAULTS", " \
+ DHCLIENT_REQUEST_EXTRAS";\n" );
if (dhostname) {
fprintf(dc, "send host-name \"%s\";\n", dhostname);
}
@@ -365,6 +373,22 @@
}
/*
+ * Record any ntp server information from DHCP for later
+ * verification and use by clock-setup
+ */
+ if ((d = fopen(NTP_SERVER_FILE, "r")) != NULL) {
+ char ntpservers[_UTSNAME_LENGTH + 1] = { 0 };
+ fgets(ntpservers, _UTSNAME_LENGTH, d);
+ fclose(d);
+ unlink(NTP_SERVER_FILE);
+
+ if (!empty_str(ntpservers)) {
+ debconf_set(client, "netcfg/dhcp_ntp_servers",
+ ntpservers);
+ }
+ }
+
+ /*
* Default to the hostname returned via DHCP, if any,
* otherwise to the requested DHCP hostname
* otherwise to the hostname found in DNS for the IP address
Reply to: