]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix NIS, #define RESOLVCONF and send the parameter list with DISCOVER messages
authorRoy Marples <roy@marples.name>
Tue, 5 Dec 2006 09:38:10 +0000 (09:38 +0000)
committerRoy Marples <roy@marples.name>
Tue, 5 Dec 2006 09:38:10 +0000 (09:38 +0000)
ChangeLog
configure.c
dhcp.c
dhcpcd.c
pathnames.h

index c952b2e64cf641a01006db42917d56762966a513..e4276373b0dd2e37939b9e43afd60880eb31f6a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
-Send hostname/fqdn in DISCOVER and INFORM messages too.
+NIS setup (yp.conf / domainname) works again.
+Send hostname/fqdn and our parameter list in DISCOVER and INFORM messages too.
 Add more debug messages.
 Fix writing to resolv.conf when resolvconf not present.
 Include linux/if_addr.h for 2.6.19+ kernels, thanks to AlexExtreme.
index 98a167560c239a62ea9e08113d63672111929e12..3d3441ccc58c7b1bb44c3381ce44885221751f5d 100644 (file)
@@ -100,14 +100,13 @@ static int make_resolv (char *ifname, dhcp_t *dhcp)
 {
   FILE *f;
   struct stat buf;
-  char resolvconf[PATH_MAX];
+  char resolvconf[PATH_MAX] = {0};
   address_t *address;
 
-  memset (&buf, 0, sizeof (struct stat));
-  if (stat ("/sbin/resolvconf", &buf) == 0)
+  if (stat (RESOLVCONF, &buf) == 0)
     {
       logger (LOG_DEBUG, "sending DNS information to resolvconf");
-      snprintf (resolvconf, PATH_MAX, "/sbin/resolvconf -a %s", ifname);
+      snprintf (resolvconf, PATH_MAX, RESOLVCONF" -a %s", ifname);
       f = popen (resolvconf, "w");
 
       if (! f)
@@ -132,11 +131,8 @@ static int make_resolv (char *ifname, dhcp_t *dhcp)
       for (address = dhcp->dnsservers; address; address = address->next)
        fprintf (f, "nameserver %s\n", inet_ntoa (address->address));
 
-      if (buf.st_ino)
-       {
-         pclose (f);
-         logger (LOG_DEBUG, "resolvconf completed");
-       }
+      if (*resolvconf)
+       pclose (f);
       else
        fclose (f);
     }
@@ -152,14 +148,14 @@ static void restore_resolv(char *ifname)
 {
   struct stat buf;
 
-  if (stat ("/sbin/resolvconf", &buf) < 0)
+  if (stat (RESOLVCONF, &buf) < 0)
     return;
 
   logger (LOG_DEBUG, "removing information from resolvconf");
 
   char *argc[4];
 
-  argc[0] = "/sbin/resolvconf";
+  argc[0] = RESOLVCONF;
   argc[1] = "-d";
   argc[2] = ifname;
   argc[3] = NULL;
diff --git a/dhcp.c b/dhcp.c
index 599d813693a077300f6454bdcfc24763b94507a3..c765fe224261d3c224b8948ae2b489e3ebe4f6d3 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -153,36 +153,27 @@ size_t send_message (interface_t *iface, dhcp_t *dhcp,
       n_params = p;
       *p++ = 0;
 
-      /* If we don't request one item, then we get defaults back which
-        we don't want */
-      if (type == DHCP_DISCOVER)
-       {
-         *p++ = DHCP_DNSSERVER;
-       }
-      else
-       {
-         *p++ = DHCP_RENEWALTIME;
-         *p++ = DHCP_REBINDTIME;
-         *p++ = DHCP_NETMASK;
-         *p++ = DHCP_BROADCAST;
-         *p++ = DHCP_CSR;
-         /* RFC 3442 states classless static routes should be before routers
-          * and static routes as classless static routes override them both */
-         *p++ = DHCP_ROUTERS;
-         *p++ = DHCP_STATICROUTE;
-         *p++ = DHCP_HOSTNAME;
-         *p++ = DHCP_DNSSEARCH;
-         *p++ = DHCP_DNSDOMAIN;
-         *p++ = DHCP_DNSSERVER;
-         *p++ = DHCP_NISDOMAIN;
-         *p++ = DHCP_NISSERVER;
-         *p++ = DHCP_NTPSERVER;
-         /* These parameters were requested by dhcpcd-2.0 and earlier
-            but we never did anything with them */
-         /*    *p++ = DHCP_DEFAULTIPTTL;
-          *p++ = DHCP_MASKDISCOVERY;
-          *p++ = DHCP_ROUTERDISCOVERY; */
-       }
+      *p++ = DHCP_RENEWALTIME;
+      *p++ = DHCP_REBINDTIME;
+      *p++ = DHCP_NETMASK;
+      *p++ = DHCP_BROADCAST;
+      *p++ = DHCP_CSR;
+      /* RFC 3442 states classless static routes should be before routers
+       * and static routes as classless static routes override them both */
+      *p++ = DHCP_ROUTERS;
+      *p++ = DHCP_STATICROUTE;
+      *p++ = DHCP_HOSTNAME;
+      *p++ = DHCP_DNSSEARCH;
+      *p++ = DHCP_DNSDOMAIN;
+      *p++ = DHCP_DNSSERVER;
+      *p++ = DHCP_NISDOMAIN;
+      *p++ = DHCP_NISSERVER;
+      *p++ = DHCP_NTPSERVER;
+      /* These parameters were requested by dhcpcd-2.0 and earlier
+        but we never did anything with them */
+      /*    *p++ = DHCP_DEFAULTIPTTL;
+       *p++ = DHCP_MASKDISCOVERY;
+       *p++ = DHCP_ROUTERDISCOVERY; */
 
       *n_params = p - n_params - 1;
 
index 712622ade795fa29a404dd3ce872b7b281318987..10cd388bbc3afcd1db229b519ea6d3d403fcdf42 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -115,6 +115,7 @@ int main(int argc, char **argv)
 
   options.doarp = false;
   options.dodns = true;
+  options.donis = true;
   options.dontp = true;
   options.dogateway = true;
   options.timeout = DEFAULT_TIMEOUT;
index f4a1b14e4a07cbf39aa589b3105896093671da1a..d748948ae48477b25d3f6a7c744a7a35b96166e3 100644 (file)
@@ -24,6 +24,8 @@
 
 #define PACKAGE                        "dhcpcd"
 
+#define RESOLVCONF             "/sbin/resolvconf"
+
 #define ETCDIR                 "/etc"
 #define RESOLVFILE             ETCDIR "/resolv.conf"
 #define NISFILE                        ETCDIR "/yp.conf"