From: Roy Marples Date: Tue, 5 Dec 2006 09:38:10 +0000 (+0000) Subject: Fix NIS, #define RESOLVCONF and send the parameter list with DISCOVER messages X-Git-Tag: v3.2.3~358 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91fe3f5a69f07d6d22b83d2890d5c90a85e8d256;p=thirdparty%2Fdhcpcd.git Fix NIS, #define RESOLVCONF and send the parameter list with DISCOVER messages --- diff --git a/ChangeLog b/ChangeLog index c952b2e6..e4276373 100644 --- 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. diff --git a/configure.c b/configure.c index 98a16756..3d3441cc 100644 --- a/configure.c +++ b/configure.c @@ -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 599d8136..c765fe22 100644 --- 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; diff --git a/dhcpcd.c b/dhcpcd.c index 712622ad..10cd388b 100644 --- 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; diff --git a/pathnames.h b/pathnames.h index f4a1b14e..d748948a 100644 --- a/pathnames.h +++ b/pathnames.h @@ -24,6 +24,8 @@ #define PACKAGE "dhcpcd" +#define RESOLVCONF "/sbin/resolvconf" + #define ETCDIR "/etc" #define RESOLVFILE ETCDIR "/resolv.conf" #define NISFILE ETCDIR "/yp.conf"