Browse code

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 <gert@greenie.muc.de>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1430162841-5840-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9614

Gert Doering authored on 2015/04/28 04:27:21
Showing 2 changed files
... ...
@@ -613,12 +613,6 @@ AC_SUBST([SOCKETS_LIBS])
613 613
 old_LIBS="${LIBS}"
614 614
 LIBS="${LIBS} ${SOCKETS_LIBS}"
615 615
 AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])
616
-AC_CHECK_FUNCS(
617
-	[res_init],
618
-	,
619
-	,
620
-	[[#include <resolv.h>]]
621
-)
622 616
 # Windows use stdcall for winsock so we cannot auto detect these
623 617
 m4_define(
624 618
 	[SOCKET_FUNCS],
... ...
@@ -646,6 +640,11 @@ else
646 646
 fi
647 647
 LIBS="${old_LIBS}"
648 648
 
649
+# we assume res_init() always exist, but need to find out *where*...
650
+AC_SEARCH_LIBS(__res_init, resolv bind, ,
651
+    AC_SEARCH_LIBS(res_9_init, resolv bind, ,
652
+	AC_SEARCH_LIBS(res_init, resolv bind, , )))
653
+
649 654
 AC_ARG_VAR([TAP_CFLAGS], [C compiler flags for tap])
650 655
 old_CFLAGS="${CFLAGS}"
651 656
 CFLAGS="${CFLAGS} ${TAP_CFLAGS}"
... ...
@@ -314,7 +314,7 @@ openvpn_getaddrinfo (unsigned int flags,
314 314
 
315 315
   ASSERT(res);
316 316
 
317
-#if defined(HAVE_RES_INIT)
317
+#ifndef WIN32
318 318
   res_init ();
319 319
 #endif
320 320