Ticket #523: 0001-Fix-autotools-check-for-res_init.patch

File 0001-Fix-autotools-check-for-res_init.patch, 1.7 KB (added by ngharo, 9 years ago)
  • configure.ac

    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]) 
    613613old_LIBS="${LIBS}"
    614614LIBS="${LIBS} ${SOCKETS_LIBS}"
    615615AC_CHECK_FUNCS([sendmsg recvmsg inet_ntop inet_pton])
    616 AC_CHECK_FUNCS(
    617         [res_init],
    618         ,
    619         ,
    620         [[#include <resolv.h>]]
    621 )
     616AC_SEARCH_LIBS([res_init], [resolv], [], [], [-lsocket -lnsl])
     617case "$host" in
     618        *-*-darwin*)
     619                AC_CHECK_LIB([resolv],[res_9_init])
     620                ;;
     621esac
     622AC_HEADER_RESOLV
     623AC_CHECK_FUNCS([res_init __res_init])
    622624# Windows use stdcall for winsock so we cannot auto detect these
    623625m4_define(
    624626        [SOCKET_FUNCS],
  • src/openvpn/socket.c

    diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
    index f5c740d..5f98f01 100644
    a b  
    4141#include "manage.h"
    4242#include "openvpn.h"
    4343
     44#if !defined(HAVE_RES_INIT) && defined(HAVE___RES_INIT)
     45# define HAVE_RES_INIT
     46#endif
     47
    4448#include "memdbg.h"
    4549
    4650const int proto_overhead[] = { /* indexed by PROTO_x */