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

Bug#544513: dhcp returned hostname take precedence on netcfg/get_hostname



Package: netcfg
Version: 1.51

If the parameter netcfg/get_hostname is set in syslinux or in the
preseed it could be ignore if the DHCP request return a hostname
value.
This is a very surprising behavior for me, the netcfg package should
respect the user input rather than the relic of the previous machine
hostname in the DHCP.
If this behavior wanted, could we introduce a parameter like
netcfg/use_hostname ?

I made a pacth on the 1.47 but that could apply on 1.51.

Thanks,
  Thomas Sondag

diff -Nru ./dhcp.c ../netcfg-1.47ep1/dhcp.c
--- ./dhcp.c	2008-09-16 10:57:59.000000000 +0000
+++ ../netcfg-1.47ep1/dhcp.c	2009-05-05 14:20:56.000000000 +0000
@@ -304,6 +304,8 @@
 int netcfg_activate_dhcp (struct debconfclient *client)
 {
     char* dhostname = NULL;
+    netcfg_get_hostname (client, "netcfg/get_hostname", &dhostname, 0);
+
     enum { START, POLL, ASK_OPTIONS, DHCP_HOSTNAME, HOSTNAME, DOMAIN,
HOSTNAME_SANS_NETWORK } state = START;

     kill_dhcp_client();
@@ -388,21 +390,21 @@
                 }

                 /*
-                 * 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
+                 * Default to the the requested DHCP hostname, if any,
+                 * otherwise to the  hostname returned via DHCP
+		 * otherwise to the hostname found in DNS for the IP address
                  * of the interface
                  */
-                if (gethostname(buf, sizeof(buf)) == 0
+		if (dhostname) {
+                    debconf_set(client, "netcfg/get_hostname", dhostname);
+		}



Reply to: