Could someone experiencing or able to reproduce this bug please try the attached patch and see if it resolves the problem? On my SuSE 10.0 system with libc 2.3.5, it seems to work OK, but I cannot reproduce the original problem on my system, so I need external testers.
Apparently the problem can be reproduced on systems where /etc/resolv.conf is a dummy (for instance, on systems with just a modem) when fetchmail is started. -- Matthias Andree
Index: NEWS =================================================================== --- NEWS (revision 4981) +++ NEWS (working copy) @@ -79,6 +79,11 @@ * RPOP: The password is now shrouded in the local logs. * Robustness: If a stale lockfile cannot be deleted, truncate it to avoid trouble later if the PID is recycled by a non-fetchmail process. +* On systems that have res_search(), assume we also have res_init() and call it + in order to make libc or libresolv reread the resolver configuration. This is + important when fetchmail is in daemon mode and /etc/resolv.conf is changed + later by dhcpcd, dhclient, pppd, openvpn or other ip-up/ipchange scripts. + Should fix Debian Bug#389270. # TRANSLATIONS: * New en_GB (British English) translation by David Lodge. Index: fm_getaddrinfo.c =================================================================== --- fm_getaddrinfo.c (revision 4971) +++ fm_getaddrinfo.c (working copy) @@ -2,13 +2,17 @@ #include "fetchmail.h" #include "i18n.h" +#include <resolv.h> #include <signal.h> #include <errno.h> #include <string.h> -/** This is a getaddrinfo() replacement that blocks SIGALRM, - * to avoid issues with non-reentrant getaddrinfo() implementations - * after SIGALRM timeouts, for instance on MacOS X or NetBSD. */ +/** This is a getaddrinfo() replacement that (1) blocks SIGALRM and (2) + * calls res_init(), to avoid issues with non-reentrant getaddrinfo() + * implementations after SIGALRM timeouts, for instance on MacOS X or + * NetBSD, and (2) circumvents excessive /etc/resolv.conf caching on + * some systems such as glibc-based ones. + */ int fm_getaddrinfo(const char *node, const char *serv, const struct addrinfo *hints, struct addrinfo **res) { int rc; @@ -23,6 +27,15 @@ report(stderr, GT_("Cannot modify signal mask: %s"), strerror(errno)); #endif +#ifdef HAVE_RES_SEARCH + /* boldly assume that we also have res_init() if we have + * res_search(). res_init() is supposed to read the resolver + * configuration, so call it explicitly in case it has changed. + * NB: This assumes we aren't calling getaddrinfo() in a tight loop, + * else the cost for parsing the configuration may become excessive. + */ + res_init(); +#endif rc = getaddrinfo(node, serv, hints, res); #ifndef GETADDRINFO_ASYNCSAFE
pgpPBXjtcDP6v.pgp
Description: PGP signature