[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#862745: netcfg incorrectly defaults hostname to DHCPv6-provided NTP server address



Package: netcfg
Version: 1.141

netcfg uses a NTP server address from DHCPv6 as the default hostname (in the absence of a hostname explicitly provided via DHCP), due to a typo in autoconfig.c.

Patch attached.


Installation log excerpt:

netcfg[13450]: DEBUG: IPv6 stateless autoconfig requested
netcfg[13450]: DEBUG: nc_v6_interface_configured(eth0, scope global)
netcfg[13450]: DEBUG: Running ip addr show eth0 to look for address
netcfg[13450]: DEBUG: ip line: 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
netcfg[13450]: DEBUG: ip line: link/ether fa:ee:bd:a7:4c:0f brd ff:ff:ff:ff:ff:ff
netcfg[13450]: DEBUG: ip line: inet6 2001:630:212:252:f8ee:bdff:fea7:4c0f/64 scope global dynamic
netcfg[13450]: DEBUG: Configured address found
netcfg[13450]: DEBUG: ip line: valid_lft 2592000sec preferred_lft 604800sec
netcfg[13450]: DEBUG: ip line: inet6 fe80::f8ee:bdff:fea7:4c0f/64 scope link
netcfg[13450]: DEBUG: ip line: valid_lft forever preferred_lft forever
netcfg[13450]: DEBUG: Stateless DHCPv6 requested
netcfg[13450]: WARNING **: Started DHCPv6 client; PID is 13497
dhclient[13497]: Created duid \000\003\000\001\372\356\275\247L\017.
dhclient[13497]: XMT: Info-Request on eth0, interval 1080ms.
dhclient[13497]: RCV: Reply message on eth0 from fe80::8a5a:92ff:fecd:8da7.
netcfg[13450]: DEBUG: DHCPv6 line: nameserver[0] 2001:630:212:200::d:0
netcfg[13450]: DEBUG: DHCPv6 line: nameserver[1] 2001:630:212:200::d:1
netcfg[13450]: DEBUG: DHCPv6 line: nameserver[2] 2001:630:212:200::d:2
netcfg[13450]: DEBUG: DHCPv6 line: Domain search list[0] cl.cam.ac.uk.
netcfg[13450]: DEBUG: DHCPv6 line: NTP server[0] 2001:630:212:200::123:1a
netcfg[13450]: DEBUG: DHCPv6 line: NTP server[1] 2001:630:212:200::123:1b
netcfg[13450]: DEBUG: DHCPv6 line: NTP server[2] 2001:630:212:200::123:1c
netcfg[13450]: DEBUG: DHCPv6 line: end
netcfg[13450]: DEBUG: Trying IPv4 autoconfig as well
netcfg[13450]: WARNING **: Started DHCP client; PID is 13502
dhclient[13502]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 1 (xid=0xce07ab1b)
dhclient[13502]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 1 (xid=0xce07ab1b)
dhclient[13502]: DHCPREQUEST of 128.232.81.81 on eth0 to 255.255.255.255 port 67 (xid=0x1bab07ce)
dhclient[13502]: DHCPOFFER of 128.232.81.81 from 128.232.80.7
dhclient[13502]: DHCPACK of 128.232.81.81 from 128.232.80.7
dhclient[13502]: bound to 128.232.81.81 -- renewal in 1780 seconds.
netcfg[13450]: DEBUG: Reading NTP servers from DHCP info
netcfg[13450]: DEBUG: Read NTP server 128.232.0.9
netcfg[13450]: DEBUG: Read NTP server 128.232.0.8
netcfg[13450]: DEBUG: Read NTP server 128.232.0.7
netcfg[13450]: DEBUG: Read NTP server 128.232.96.152
netcfg[13450]: DEBUG: Reading nameservers from /etc/resolv.conf
netcfg[13450]: DEBUG: Read nameserver 128.232.1.1
netcfg[13450]: DEBUG: Read nameserver 128.232.1.2
netcfg[13450]: DEBUG: Read nameserver 128.232.1.3
netcfg[13450]: DEBUG: State is now 1
netcfg[13450]: DEBUG: State is now 2
netcfg[13450]: DEBUG: State is now 5
netcfg[13450]: DEBUG: Defaulting hostname to provided DHCP hostname

...and then the installer prompts me for a hostname with a pre-filled default of "2001:630:212:200::123:1b" (or if preseeded, blindly proceeds with the installed system's hostname set to that IPv6 address).
diff -Naur netcfg-1.141.orig/autoconfig.c netcfg-1.141/autoconfig.c
--- netcfg-1.141.orig/autoconfig.c      2012-10-02 02:02:23.000000000 +0100
+++ netcfg-1.141/autoconfig.c   2017-05-16 15:33:55.284092137 +0100
@@ -347,7 +347,7 @@
                        ns_idx++;
                } else if (!strncmp("NTP server[", l, 11) && ntp_idx < NETCFG_NTPSERVERS_MAX) {
                        p = strstr(l, "] ") + 2;
-                       strncpy(interface->ntp_servers[ns_idx++], p, sizeof(interface->ntp_servers[ntp_idx]));
+                       strncpy(interface->ntp_servers[ntp_idx], p, sizeof(interface->ntp_servers[ntp_idx]));
                        ntp_idx++;
                } else if (!strncmp("Domain search list[0] ", l, 21)) {
                        p = strstr(l, "] ") + 2;

Reply to: