From: Roy Marples Date: Wed, 30 May 2007 09:27:53 +0000 (+0000) Subject: We now have 6 hostname options, which should satisfy everyone. X-Git-Tag: v3.2.3~246 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83bf572a8e0a47d839d47be8f2f435ddfde30100;p=thirdparty%2Fdhcpcd.git We now have 6 hostname options, which should satisfy everyone. --- diff --git a/ChangeLog b/ChangeLog index 392f8963..97daba0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ --HH sets the hostname to the full dns name looked up if we need to. +We now have 6 hostname options, which should satisfy everyone. Fix arp compilation warning on GCC-4.2.0. Enable DHCP_INFORM support via the -s option again, moving DHCP_REQUEST to the -r option. This makes us more compatible with dhcpcd-1.x and 2.x. diff --git a/Makefile b/Makefile index b350b182..f77e4458 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 3.1.0_pre2 +VERSION = 3.1.0_pre4 CFLAGS ?= -O2 -pipe # Should work for both GNU make and BSD make diff --git a/configure.c b/configure.c index 96ef38d2..8cfb7ed2 100644 --- a/configure.c +++ b/configure.c @@ -496,7 +496,7 @@ int configure (const options_t *options, interface_t *iface, #endif /* Now we have made a resolv.conf we can obtain a hostname if we need it */ - if (options->dohostname && ! dhcp->hostname) { + if (options->dohostname && (! dhcp->hostname || options->dohostname > 3)) { union { struct sockaddr sa; struct sockaddr_in sin; @@ -525,26 +525,39 @@ int configure (const options_t *options, interface_t *iface, addr[0] = '\0'; logger (LOG_ERR, "malicious PTR record detected"); } else if (*addr) { - if (options->dohostname == 1) { - /* Strip out the domain if it matches */ - char *p = strchr (addr, '.'); - if (p) { - p++; - if (*p && dhcp->dnssearch) { - char *s = xstrdup (dhcp->dnssearch); - char *sp = s; - char *t; - - while ((t = strsep (&sp, " "))) - if (strcmp (t, p) == 0) { + char *p = strchr (addr, '.'); + if (p) { + switch (options->dohostname) { + case 1: /* -H */ + case 4: /* -HHHH */ + break; + case 2: /* -HH */ + case 5: /* -HHHHH */ + /* Strip out the domain if it matches */ + p++; + if (*p && dhcp->dnssearch) { + char *s = xstrdup (dhcp->dnssearch); + char *sp = s; + char *t; + + while ((t = strsep (&sp, " "))) + if (strcmp (t, p) == 0) { + *--p = '\0'; + break; + } + free (s); + } else if (dhcp->dnsdomain) { + if (strcmp (dhcp->dnsdomain, p) == 0) *--p = '\0'; - break; - } - free (s); - } else if (dhcp->dnsdomain) { - if (strcmp (dhcp->dnsdomain, p) == 0) - *--p = '\0'; - } + } + break; + case 3: /* -HHH */ + case 6: /* -HHHHHH */ + /* Just strip the domain */ + *p = '\0'; + break; + default: /* Too many H! */ + break; } } strlcpy (newhostname, addr, sizeof (newhostname)); diff --git a/dhcpcd.8 b/dhcpcd.8 index e3d5c183..eebf1875 100644 --- a/dhcpcd.8 +++ b/dhcpcd.8 @@ -196,9 +196,26 @@ By default will NOT set hostname of the host to the hostname option received from DHCP server unless the current hostname is blank, (none) or localhost. If no hostname is returned by the DHCP server then we attempt -to lookup the hostname via DNS. If we are given a DNS domain in the DHCP -message then we strip the matching part from the looked up hostname unless -told to by -HH. +to lookup the hostname via DNS. +More -H's control what we do with the FQDN returned by DNS. +.IP +.BI \-H +set hostname to the full FQDN +.br +.BI \-HH +strip the domain if it matches a given domain in our DHCP message +.br +.BI \-HHH +strip the domain regardless +.br +.BI \-HHHH +force hostname lookup even if given a hostname in our DHCP message +.br +.BI \-HHHHH +same as above, but strip the domain if it matches +.br +.BI \-HHHHHH +same as above, but strip the domain regardless .TP .BI \-F \ none | ptr | both Forces