From 6aee1918ce18f22aa93b62e58f3151c82cc00eb0 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Fri, 8 Dec 2006 18:43:22 +0000 Subject: Call res_init() at the beginning of the poll, if the computer has res_search(). This is supposed to re-read /etc/resolv.conf in order to pick up changes made by dhcpcd, dhclient, pppd, openvpn or similar. To fix Debian Bug #389270 (DNS errors in daemon mode) and others. svn path=/branches/BRANCH_6-3/; revision=4986 --- fetchmail.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'fetchmail.c') diff --git a/fetchmail.c b/fetchmail.c index 443b1feb..6a33c3d7 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -45,6 +45,11 @@ #include "i18n.h" #include "lock.h" +/* need these (and sys/types.h) for res_init() */ +#include +#include +#include + #ifndef ENETUNREACH #define ENETUNREACH 128 /* Interactive doesn't know this */ #endif /* ENETUNREACH */ @@ -669,6 +674,22 @@ int main(int argc, char **argv) sethostent(TRUE); /* use TCP/IP for mailserver queries */ #endif /* HAVE_RES_SEARCH */ +#ifdef HAVE_RES_SEARCH + /* Boldly assume that we also have res_init() if we have + * res_search(), and call res_init() to re-read the resolv.conf + * file, so that we can pick up changes to that file that are + * written by dhpccd, dhclient, pppd, openvpn and similar. */ + + /* NOTE: This assumes that /etc/resolv.conf is written + * atomically (i. e. a temporary file is written, flushed and + * then renamed into place). To fix Debian Bug#389270. */ + + /* NOTE: If this leaks memory or doesn't re-read + * /etc/resolv.conf, we're in trouble. The res_init() interface + * is only lightly documented :-( */ + res_init(); +#endif + activecount = 0; batchcount = 0; for (ctl = querylist; ctl; ctl = ctl->next) -- cgit v1.2.3