Mercurial > hg > dhcpcd
changeset 13:6288393e4e1f draft
Fix writing to /etc/resolv.conf when resolvconf not present and add more debug statements
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 04 Dec 2006 14:08:44 +0000 |
| parents | 8abfec17fbd6 |
| children | 69389473e116 |
| files | ChangeLog client.c configure.c |
| diffstat | 3 files changed, 19 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Dec 04 12:56:30 2006 +0000 +++ b/ChangeLog Mon Dec 04 14:08:44 2006 +0000 @@ -1,3 +1,5 @@ +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. dhcpcd-3.0.2
--- a/client.c Mon Dec 04 12:56:30 2006 +0000 +++ b/client.c Mon Dec 04 14:08:44 2006 +0000 @@ -82,9 +82,10 @@ static int daemonise (char *pidfile) { + logger (LOG_DEBUG, "forking to background"); if (daemon (0, 0) < 0) { - logger (LOG_ERR, "unable to daemonise: %s", strerror (errno)); + logger (LOG_ERR, "daemon: %s", strerror (errno)); return -1; }
--- a/configure.c Mon Dec 04 12:56:30 2006 +0000 +++ b/configure.c Mon Dec 04 14:08:44 2006 +0000 @@ -96,13 +96,14 @@ logger (LOG_ERR, "fork: %s", strerror (errno)); } -static int make_resolv (char *ifname, dhcp_t *dhcp, int wait) +static int make_resolv (char *ifname, dhcp_t *dhcp) { FILE *f; struct stat buf; char resolvconf[PATH_MAX]; address_t *address; + memset (&resolvconf, 0, sizeof (resolvconf)); if (stat ("/sbin/resolvconf", &buf) == 0) { logger (LOG_DEBUG, "sending DNS information to resolvconf"); @@ -114,6 +115,7 @@ } else { + logger (LOG_DEBUG, "writing "RESOLVFILE); if (! (f = fopen(RESOLVFILE, "w"))) logger (LOG_ERR, "fopen `%s': %s", RESOLVFILE, strerror (errno)); } @@ -185,6 +187,7 @@ address_t *address; char *a; + logger (LOG_DEBUG, "writing "NTPFILE); if (! (f = fopen(NTPFILE, "w"))) { logger (LOG_ERR, "fopen `%s': %s", NTPFILE, strerror (errno)); @@ -213,6 +216,7 @@ address_t *address; char prefix[256] = {0}; + logger (LOG_DEBUG, "writing "NISFILE); if (! (f = fopen(NISFILE, "w"))) { logger (LOG_ERR, "fopen `%s': %s", NISFILE, strerror (errno)); @@ -246,6 +250,7 @@ route_t *route; address_t *address; + logger (LOG_DEBUG, "writing %s", iface->infofile); if ((f = fopen (iface->infofile, "w")) == NULL) { logger (LOG_ERR, "fopen `%s': %s", iface->infofile, strerror (errno)); @@ -483,7 +488,9 @@ } if (options->dodns && dhcp->dnsservers) - make_resolv(iface->name, dhcp, (options->dohostname && !dhcp->hostname)); + make_resolv(iface->name, dhcp); + else + logger (LOG_DEBUG, "no dns information to write"); if (options->dontp && dhcp->ntpservers) make_ntp(iface->name, dhcp); @@ -492,7 +499,7 @@ make_nis(iface->name, dhcp); /* Now we have made a resolv.conf we can obtain a hostname if we need one */ - if (options->dohostname && !dhcp->hostname) + if (options->dohostname && ! dhcp->hostname) { he = gethostbyaddr (inet_ntoa (dhcp->address), sizeof (struct in_addr), AF_INET); @@ -509,14 +516,16 @@ gethostname (curhostname, sizeof (curhostname)); - if (options->dohostname || !strlen (curhostname) - || !strcmp (curhostname, "(none)") || !strcmp (curhostname, "localhost")) + if (options->dohostname + || strlen (curhostname) == 0 + || strcmp (curhostname, "(none)") == 0 + || strcmp (curhostname, "localhost") == 0) { if (dhcp->hostname) strcpy ((char *) newhostname, dhcp->hostname); sethostname ((char *) newhostname, strlen ((char *) newhostname)); - logger (LOG_INFO, "setting hostname to %s", newhostname); + logger (LOG_INFO, "setting hostname to `%s'", newhostname); } write_info (iface, dhcp);
