From: Gert Doering Date: Mon, 27 Apr 2015 19:27:21 +0000 (+0200) Subject: assume res_init() is always there. X-Git-Tag: v2.3.7~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae9aff25c5a74e770a29a3a675f5b8f8dd8c5bf8;p=thirdparty%2Fopenvpn.git assume res_init() is always there. Previously, the code tried to find res_init(), and on some systems got it wrong in configure, silently not-using res_init(), leading to unexpected failures to re-init the resolver. We know that all supported OSes (except Windows) have res_init(), so change the call to "#ifndef WIN32", and adjust configure.ac to just find the library to link (if any). With that, failures to find res_init() are no longer "hidden" but clearly visible at link time. AC_SEARCH_LIBS() bits inspired by CUPS' cups_network.m4 (GPLv2) Fix (part of) trac #523 Signed-off-by: Gert Doering Lazy-ACK-by: Gert Doering Message-Id: <1430162841-5840-1-git-send-email-gert@greenie.muc.de> URL: http://article.gmane.org/gmane.network.openvpn.devel/9614 (cherry picked from commit 403dc434d245e5df5ae262935aa2e7364547e260) --- diff --git a/configure.ac b/configure.ac index 9b8c380ce..ab700cf54 100644 --- a/configure.ac +++ b/configure.ac @@ -603,12 +603,6 @@ AC_SUBST([SOCKETS_LIBS]) old_LIBS="${LIBS}" LIBS="${LIBS} ${SOCKETS_LIBS}" AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton]) -AC_CHECK_FUNCS( - [res_init], - , - , - [[#include ]] -) # Windows use stdcall for winsock so we cannot auto detect these m4_define( [SOCKET_FUNCS], @@ -636,6 +630,11 @@ else fi LIBS="${old_LIBS}" +# we assume res_init() always exist, but need to find out *where*... +AC_SEARCH_LIBS(__res_init, resolv bind, , + AC_SEARCH_LIBS(res_9_init, resolv bind, , + AC_SEARCH_LIBS(res_init, resolv bind, , ))) + AC_ARG_VAR([TAP_CFLAGS], [C compiler flags for tap]) old_CFLAGS="${CFLAGS}" CFLAGS="${CFLAGS} ${TAP_CFLAGS}" diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 6e68c18aa..af13e3620 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -137,7 +137,7 @@ openvpn_getaddrinfo (unsigned int flags, ASSERT(res); -#if defined(HAVE_RES_INIT) +#ifndef WIN32 res_init (); #endif