]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We now have 6 hostname options, which should satisfy everyone.
authorRoy Marples <roy@marples.name>
Wed, 30 May 2007 09:27:53 +0000 (09:27 +0000)
committerRoy Marples <roy@marples.name>
Wed, 30 May 2007 09:27:53 +0000 (09:27 +0000)
ChangeLog
Makefile
configure.c
dhcpcd.8

index 392f8963dd62a24c74deb71d8096f1108a8a7516..97daba0bb9b80d4d69308de3e696142033e8148a 100644 (file)
--- 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.
index b350b182167e2e05c654372061adf8c2839d91c5..f77e4458fcdcfb32b272f41ab6e5d7ff899b06f2 100644 (file)
--- 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
index 96ef38d2105d4409baa121fcb5350a76682de1b1..8cfb7ed2aaed7d6b26da525963428f63c7f6e9d4 100644 (file)
@@ -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));
index e3d5c183f4908ff2e93104aadc67c7bb96e63197..eebf18753b2a4c72c9960e1745c03581a105d5de 100644 (file)
--- 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