+-HH sets the hostname to the full dns name looked up if we need to.
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.
#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) {
union {
struct sockaddr sa;
struct sockaddr_in sin;
freeaddrinfo (res);
addr[0] = '\0';
logger (LOG_ERR, "malicious PTR record detected");
- } else if (*addr)
+ } 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) {
+ *--p = '\0';
+ break;
+ }
+ free (s);
+ } else if (dhcp->dnsdomain) {
+ if (strcmp (dhcp->dnsdomain, p) == 0)
+ *--p = '\0';
+ }
+ }
+ }
strlcpy (newhostname, addr, sizeof (newhostname));
+ }
}
}
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.
+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.
.TP
.BI \-F \ none | ptr | both
Forces