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

Bug#682342: (forw) Bug#682342: a fix for dhcp search path issues'



On Wed, May 22, 2013 at 07:03:37AM +0200, Christian PERRIER wrote:
> Phil, you've been one of the most active ppl on netcfg. Care to comment?
> 
> ----- Forwarded message from Sean Noonan <Sean.Noonan@twosigma.com> -----
> 
> Date: Tue, 21 May 2013 18:28:09 +0000
> From: Sean Noonan <Sean.Noonan@twosigma.com>
> To: "'682342@bugs.debian.org'" <682342@bugs.debian.org>
> Subject: Bug#682342: a fix for dhcp search path issues
> Reply-To: Sean Noonan <Sean.Noonan@twosigma.com>, 682342@bugs.debian.org
> X-Mailing-List: <debian-boot@lists.debian.org> archive/latest/173316
> X-CRM114-Status: Good  ( pR: 30.0127 )
> 
> We recently ran into this problem.  The expedient way to fix it is to replace the netcfg binary in the initrd with one compiled using the following patch.
> 
> --- dhcp.c             2013-01-13 08:23:24.000000000 -0500
> +++ ../dhcp.c      2013-05-21 14:25:55.613957486 -0400
> @@ -591,7 +591,7 @@
>                          preseed_hostname_from_fqdn(client, buf);
>                  }
> -                if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, 1)) {
> +                if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, !have_domain)) {
>                      /*
>                       * Going back to POLL wouldn't make much sense.
>                       * However, it does make sense to go to the retry
> 
> ----- End forwarded message -----

I think this patch is incomplete and still needs to strip the domain
off the hostname to preserve behavior if an FQDN is passed in with the
hostname. That way the domain name passed by DHCP will override the
domain part of the hostname.

New possible (untested) patch attached.

Kind regards
Philipp Kern
diff --git a/dhcp.c b/dhcp.c
index aa37bd0..d694f67 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -591,7 +591,7 @@ int netcfg_activate_dhcp (struct debconfclient *client, struct netcfg_interface
                         preseed_hostname_from_fqdn(client, buf);
                 }
 
-                if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, 1)) {
+                if (netcfg_get_hostname (client, "netcfg/get_hostname", hostname, !have_domain)) {
                     /*
                      * Going back to POLL wouldn't make much sense.
                      * However, it does make sense to go to the retry
diff --git a/netcfg-common.c b/netcfg-common.c
index 4445d12..9abf32e 100644
--- a/netcfg-common.c
+++ b/netcfg-common.c
@@ -1043,14 +1043,24 @@ int netcfg_get_hostname(struct debconfclient *client, char *template, char *host
             continue;
         }
 
-        if (accept_domain && (s = strchr(hostname, '.'))) {
-            di_info("Detected we have an FQDN; splitting and setting domain");
-            if (s[1] == '\0') { /* "somehostname." <- . should be ignored */
+        if (s = strchr(hostname, '.')) {
+            di_info("Detected an FQDN in hostname");
+            if (s[1] == '\0') {
+                /* "somehostname." <- . should be ignored */
                 *s = '\0';
-            } else { /* assume we have a valid domain name given */
-                strncpy(domain, s + 1, MAXHOSTNAMELEN);
-                debconf_set(client, "netcfg/get_domain", domain);
-                have_domain = 1;
+                di_info("Stripped trailing dot from hostname");
+            } else {
+                /* assume that the domain is valid and copy it if
+                 * accept_domain is set; just use the hostname if
+                 * it is unset
+                 */
+                if (accept_domain) {
+                    strncpy(domain, s + 1, MAXHOSTNAMELEN);
+					di_info("Setting domain to %s", domain);
+                    debconf_set(client, "netcfg/get_domain", domain);
+                    have_domain = 1;
+                }
+                /* strip the domain from the hostname */
                 *s = '\0';
             }
         }

Attachment: signature.asc
Description: Digital signature


Reply to: