From 093b3152c26adb81bcf9235c4f372492da408aef Mon Sep 17 00:00:00 2001
From: Nicholas Hall <ngharo@gmail.com>
Date: Fri, 6 Mar 2015 12:51:27 -0600
Subject: [PATCH] Fix autotools check for res_init
Autotools configure check fails to detect res_init on recent glibc
versions. It appears that resolv.h in recent glibc maps res_init to
__res_init which autotools doesn't catch.
This is my first patch ever to anything autotools related. I used the
check that the ntpd uses and tested on Debian 8 x64 (glibc 2.19) and
LFS 7.4 (glibc 2.18) successfully.
This fixes bug #525
https://community.openvpn.net/openvpn/ticket/523
---
configure.ac | 14 ++++++++------
src/openvpn/socket.c | 4 ++++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9132468..c4db43a 100644
a
|
b
|
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 | | ) |
| 616 | AC_SEARCH_LIBS([res_init], [resolv], [], [], [-lsocket -lnsl]) |
| 617 | case "$host" in |
| 618 | *-*-darwin*) |
| 619 | AC_CHECK_LIB([resolv],[res_9_init]) |
| 620 | ;; |
| 621 | esac |
| 622 | AC_HEADER_RESOLV |
| 623 | AC_CHECK_FUNCS([res_init __res_init]) |
622 | 624 | # Windows use stdcall for winsock so we cannot auto detect these |
623 | 625 | m4_define( |
624 | 626 | [SOCKET_FUNCS], |
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index f5c740d..5f98f01 100644
a
|
b
|
|
41 | 41 | #include "manage.h" |
42 | 42 | #include "openvpn.h" |
43 | 43 | |
| 44 | #if !defined(HAVE_RES_INIT) && defined(HAVE___RES_INIT) |
| 45 | # define HAVE_RES_INIT |
| 46 | #endif |
| 47 | |
44 | 48 | #include "memdbg.h" |
45 | 49 | |
46 | 50 | const int proto_overhead[] = { /* indexed by PROTO_x */ |