Report information
The Basics
Id:
44024
Status:
resolved
Priority:
Medium/Medium
Queue:

BugTracker
Version Fixed:
(no value)
Version Found:
(no value)
Versions Affected:
(no value)
Versions Planned:
(no value)
Priority:
(no value)
Severity:
(no value)
CVSS Score:
(no value)
CVE ID:
(no value)
Component:
(no value)
Area:
(no value)

Dates
Created:Tue, 03 Jan 2017 13:31:39 -0500
Updated:Wed, 24 Jan 2018 12:17:35 -0500
Closed:Wed, 24 Jan 2018 12:17:35 -0500



This bug tracker is no longer active.

Please go to our Gitlab to submit issues (both feature requests and bug reports) for active projects maintained by Internet Systems Consortium (ISC).

Due to security and confidentiality requirements, full access is limited to the primary maintainers.

Subject: Libirs - getaddrinfo exported from bind library
Date: Tue, 03 Jan 2017 19:31:24 +0100
To: bind-suggest@isc.org
From: "Petr Menšík" <pemensik@redhat.com>
Hello ISC, we have trouble with exported getaddrinfo function (also getnameinfo, freeaddrinfo, gai_strerror) from libirs. It is unclear to me why it does export symbols without irs_ prefix and without its own header file. I found some testing in configure script regarding salen attribute. But it does not even test supported flags of system call. What is reason to reimplement library call provided usually by libc library? I think there might be some testing in configure script whether getaddrinfo implementation is sufficient. If not, it might add its own symbols. But I would prefer something like lwresd_getaddrinfo: irs_getaddrinfo, maybe with possibility to define getaddrinfo define from header. I miss at least manual configure option to disable it. I suspect there is some reason for it. Is there functionality missing from system libraries? Would it make sense to export irs_ prefixed variants where own implementation is needed and use system functions in the other case? I have found libirs is usually used only by delv from bind package, maybe to provide also verification. It is used also by DHCP server however. But it prevents linking together with openldap library, which is using flags that bind implementation does not support. See https://bugzilla.redhat.com/show_bug.cgi?id=1205168 What is a reason to export system calls? Best Regards, -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemensik@redhat.com  PGP: 65C6C973

Message body not shown because it is not plain text.

I have created patch to prefix those calls. More in bind-workers list at https://lists.isc.org/pipermail/bind-workers/2017-February/003402.html On Tue Jan 03 19:31:39 2017, pemensik@redhat.com wrote: > Hello ISC, > > we have trouble with exported getaddrinfo function (also getnameinfo, > freeaddrinfo, gai_strerror) from libirs. It is unclear to me why it > does export symbols without irs_ prefix and without its own header > file. I found some testing in configure script regarding salen > attribute. But it does not even test supported flags of system call. > > What is reason to reimplement library call provided usually by libc > library? I think there might be some testing in configure script > whether getaddrinfo implementation is sufficient. If not, it might add > its own symbols. But I would prefer something like lwresd_getaddrinfo: > irs_getaddrinfo, maybe with possibility to define getaddrinfo define > from header. I miss at least manual configure option to disable it. I > suspect there is some reason for it. Is there functionality missing > from system libraries? Would it make sense to export irs_ prefixed > variants where own implementation is needed and use system functions in > the other case? > > I have found libirs is usually used only by delv from bind package, > maybe to provide also verification. It is used also by DHCP server > however. But it prevents linking together with openldap library, which > is using flags that bind implementation does not support. > > See https://bugzilla.redhat.com/show_bug.cgi?id=1205168 > > What is a reason to export system calls? > > Best Regards, > > -- > Petr Menšík > Software Engineer > Red Hat, http://www.redhat.com/ > email: pemensik@redhat.com  PGP: 65C6C973
Subject: 0001-Prefix-provided-getaddrinfo-in-libirs-with-irs_.patch
From e472341769931b837c8cd826978f83f32c9623c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com> Date: Tue, 21 Feb 2017 12:53:43 +0100 Subject: [PATCH 1/2] Prefix provided getaddrinfo in libirs with irs_ --- config.h.in | 12 --------- configure | 55 ++++++++++++++++++------------------------ configure.in | 37 ++++++++++++++-------------- lib/irs/gai_strerror.c | 2 +- lib/irs/getaddrinfo.c | 4 +-- lib/irs/getnameinfo.c | 8 +++--- lib/irs/include/irs/netdb.h.in | 28 +++++++++++++++++++++ lib/irs/resconf.c | 2 +- 8 files changed, 78 insertions(+), 70 deletions(-) diff --git a/config.h.in b/config.h.in index 3e1b0d4..4dad23d 100644 --- a/config.h.in +++ b/config.h.in @@ -428,18 +428,6 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP -/* return type of gai_strerror */ -#undef IRS_GAISTRERROR_RETURN_T - -/* Define to the buffer length type used by getnameinfo(3). */ -#undef IRS_GETNAMEINFO_BUFLEN_T - -/* Define to the flags type used by getnameinfo(3). */ -#undef IRS_GETNAMEINFO_FLAGS_T - -/* Define to the sockaddr length type used by getnameinfo(3). */ -#undef IRS_GETNAMEINFO_SOCKLEN_T - /* Define to allow building of objects for dlopen(). */ #undef ISC_DLZ_DLOPEN diff --git a/configure b/configure index 4813f77..4f2a278 100755 --- a/configure +++ b/configure @@ -750,6 +750,10 @@ ISC_IRS_GETNAMEINFOSOCKLEN ISC_LWRES_GETNAMEINFOPROTO ISC_LWRES_GETADDRINFOPROTO ISC_LWRES_GETIPNODEPROTO +IRS_GAISTRERROR_RETURN_T +IRS_GETNAMEINFO_FLAGS_T +IRS_GETNAMEINFO_BUFLEN_T +IRS_GETNAMEINFO_SOCKLEN_T ISC_LWRES_NEEDHERRNO ISC_LWRES_GETHOSTBYADDRVOID ISC_LWRES_ENDNETENTINT @@ -17392,15 +17396,9 @@ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: socklen_t for buflen; u_int for flags" >&5 $as_echo "socklen_t for buflen; u_int for flags" >&6; } - -$as_echo "#define IRS_GETNAMEINFO_SOCKLEN_T socklen_t" >>confdefs.h - - -$as_echo "#define IRS_GETNAMEINFO_BUFLEN_T socklen_t" >>confdefs.h - - -$as_echo "#define IRS_GETNAMEINFO_FLAGS_T unsigned int" >>confdefs.h - + IRS_GETNAMEINFO_SOCKLEN_T=socklen_t + IRS_GETNAMEINFO_BUFLEN_T=socklen_t + IRS_GETNAMEINFO_FLAGS_T="unsigned int" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -17421,12 +17419,9 @@ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: size_t for buflen; int for flags" >&5 $as_echo "size_t for buflen; int for flags" >&6; } - $as_echo "#define IRS_GETNAMEINFO_SOCKLEN_T socklen_t" >>confdefs.h - - $as_echo "#define IRS_GETNAMEINFO_BUFLEN_T size_t" >>confdefs.h - - $as_echo "#define IRS_GETNAMEINFO_FLAGS_T int" >>confdefs.h - + IRS_GETNAMEINFO_SOCKLEN_T=socklen_t + IRS_GETNAMEINFO_BUFLEN_T=size_t + IRS_GETNAMEINFO_FLAGS_T=int else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -17447,21 +17442,15 @@ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: size_t for buflen; int for flags" >&5 $as_echo "size_t for buflen; int for flags" >&6; } - $as_echo "#define IRS_GETNAMEINFO_SOCKLEN_T size_t" >>confdefs.h - - $as_echo "#define IRS_GETNAMEINFO_BUFLEN_T size_t" >>confdefs.h - - $as_echo "#define IRS_GETNAMEINFO_FLAGS_T int" >>confdefs.h - + IRS_GETNAMEINFO_SOCKLEN_T=size_t + IRS_GETNAMEINFO_BUFLEN_T=size_t + IRS_GETNAMEINFO_FLAGS_T=int else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not match any subspecies; assume standard definition" >&5 $as_echo "not match any subspecies; assume standard definition" >&6; } -$as_echo "#define IRS_GETNAMEINFO_SOCKLEN_T socklen_t" >>confdefs.h - -$as_echo "#define IRS_GETNAMEINFO_BUFLEN_T socklen_t" >>confdefs.h - -$as_echo "#define IRS_GETNAMEINFO_FLAGS_T int" >>confdefs.h - +IRS_GETNAMEINFO_SOCKLEN_T=socklen_t +IRS_GETNAMEINFO_BUFLEN_T=socklen_t +IRS_GETNAMEINFO_FLAGS_T=int fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi @@ -17469,6 +17458,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + + + # # ...and same for gai_strerror(). # @@ -17492,17 +17485,15 @@ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: returning char *" >&5 $as_echo "returning char *" >&6; } - -$as_echo "#define IRS_GAISTRERROR_RETURN_T char *" >>confdefs.h - + IRS_GAISTRERROR_RETURN_T='char *' else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not match any subspecies; assume standard definition" >&5 $as_echo "not match any subspecies; assume standard definition" >&6; } -$as_echo "#define IRS_GAISTRERROR_RETURN_T const char *" >>confdefs.h - +IRS_GAISTRERROR_RETURN_T='const char *' fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_fn_c_check_func "$LINENO" "getipnodebyname" "ac_cv_func_getipnodebyname" if test "x$ac_cv_func_getipnodebyname" = xyes; then : ISC_LWRES_GETIPNODEPROTO="#undef ISC_LWRES_GETIPNODEPROTO" diff --git a/configure.in b/configure.in index ba8ddd1..a39adcf 100644 --- a/configure.in +++ b/configure.in @@ -2559,12 +2559,9 @@ int getnameinfo(const struct sockaddr *, socklen_t, char *, socklen_t, char *, socklen_t, unsigned int);], [ return (0);], [AC_MSG_RESULT(socklen_t for buflen; u_int for flags) - AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t, - [Define to the sockaddr length type used by getnameinfo(3).]) - AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t, - [Define to the buffer length type used by getnameinfo(3).]) - AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, unsigned int, - [Define to the flags type used by getnameinfo(3).])], + IRS_GETNAMEINFO_SOCKLEN_T=socklen_t + IRS_GETNAMEINFO_BUFLEN_T=socklen_t + IRS_GETNAMEINFO_FLAGS_T="unsigned int"], [AC_TRY_COMPILE([ #include <sys/types.h> #include <sys/socket.h> @@ -2573,9 +2570,9 @@ int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int);], [ return (0);], [AC_MSG_RESULT(size_t for buflen; int for flags) - AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t) - AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t) - AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)], + IRS_GETNAMEINFO_SOCKLEN_T=socklen_t + IRS_GETNAMEINFO_BUFLEN_T=size_t + IRS_GETNAMEINFO_FLAGS_T=int], [AC_TRY_COMPILE([ #include <sys/types.h> #include <sys/socket.h> @@ -2584,13 +2581,17 @@ int getnameinfo(const struct sockaddr *, size_t, char *, size_t, char *, size_t, int);], [ return (0);], [AC_MSG_RESULT(size_t for buflen; int for flags) - AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, size_t) - AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t) - AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)], + IRS_GETNAMEINFO_SOCKLEN_T=size_t + IRS_GETNAMEINFO_BUFLEN_T=size_t + IRS_GETNAMEINFO_FLAGS_T=int], [AC_MSG_RESULT(not match any subspecies; assume standard definition) -AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t) -AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t) -AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)])])]) +IRS_GETNAMEINFO_SOCKLEN_T=socklen_t +IRS_GETNAMEINFO_BUFLEN_T=socklen_t +IRS_GETNAMEINFO_FLAGS_T=int])])]) + +AC_SUBST(IRS_GETNAMEINFO_SOCKLEN_T) +AC_SUBST(IRS_GETNAMEINFO_BUFLEN_T) +AC_SUBST(IRS_GETNAMEINFO_FLAGS_T) # # ...and same for gai_strerror(). @@ -2603,10 +2604,10 @@ AC_TRY_COMPILE([ char *gai_strerror(int ecode);], [ return (0); ], [AC_MSG_RESULT(returning char *) - AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [char *], - [return type of gai_strerror])], + IRS_GAISTRERROR_RETURN_T='char *'], [AC_MSG_RESULT(not match any subspecies; assume standard definition) -AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [const char *])]) +IRS_GAISTRERROR_RETURN_T='const char *']) +AC_SUBST(IRS_GAISTRERROR_RETURN_T) AC_CHECK_FUNC(getipnodebyname, [ISC_LWRES_GETIPNODEPROTO="#undef ISC_LWRES_GETIPNODEPROTO"], diff --git a/lib/irs/gai_strerror.c b/lib/irs/gai_strerror.c index 2fe3941..b9a51ef 100644 --- a/lib/irs/gai_strerror.c +++ b/lib/irs/gai_strerror.c @@ -77,7 +77,7 @@ static const char *gai_messages[] = { * Returns an error message corresponding to an error code returned by * getaddrinfo() and getnameinfo() */ -IRS_GAISTRERROR_RETURN_T +irs_gaistrerror_t gai_strerror(int ecode) { union { const char *const_ptr; diff --git a/lib/irs/getaddrinfo.c b/lib/irs/getaddrinfo.c index 5f904ed..3fa27ea 100644 --- a/lib/irs/getaddrinfo.c +++ b/lib/irs/getaddrinfo.c @@ -191,7 +191,7 @@ static void _freeaddrinfo(struct addrinfo *ai); * service servname. */ int -getaddrinfo(const char *hostname, const char *servname, +irs_getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) { struct servent *sp; @@ -1174,7 +1174,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, /*% Free address info. */ void -freeaddrinfo(struct addrinfo *ai) { +irs_freeaddrinfo(struct addrinfo *ai) { _freeaddrinfo(ai); } diff --git a/lib/irs/getnameinfo.c b/lib/irs/getnameinfo.c index ec43043..a046fb8 100644 --- a/lib/irs/getnameinfo.c +++ b/lib/irs/getnameinfo.c @@ -143,10 +143,10 @@ static struct afd { } while (0) int -getnameinfo(const struct sockaddr *sa, IRS_GETNAMEINFO_SOCKLEN_T salen, - char *host, IRS_GETNAMEINFO_BUFLEN_T hostlen, - char *serv, IRS_GETNAMEINFO_BUFLEN_T servlen, - IRS_GETNAMEINFO_FLAGS_T flags) +irs_getnameinfo(const struct sockaddr *sa, irs_socklen_t salen, + char *host, irs_buflen_t hostlen, + char *serv, irs_buflen_t servlen, + irs_flags_t flags) { struct afd *afd = NULL; struct servent *sp; diff --git a/lib/irs/include/irs/netdb.h.in b/lib/irs/include/irs/netdb.h.in index 299928b..3cf173f 100644 --- a/lib/irs/include/irs/netdb.h.in +++ b/lib/irs/include/irs/netdb.h.in @@ -157,6 +157,34 @@ struct addrinfo { #define NI_NUMERICSERV 0x00000008 #define NI_DGRAM 0x00000010 +typedef @IRS_GETNAMEINFO_SOCKLEN_T@ irs_socklen_t; +typedef @IRS_GETNAMEINFO_BUFLEN_T@ irs_buflen_t; +typedef @IRS_GETNAMEINFO_FLAGS_T@ irs_flags_t; +typedef @IRS_GAISTRERROR_RETURN_T@ irs_gaistrerror_t; + +int +irs_getaddrinfo(const char *hostname, const char *servname, + const struct addrinfo *hints, struct addrinfo **res); + +void +irs_freeaddrinfo(struct addrinfo *ai); + +int +irs_getnameinfo(const struct sockaddr *sa, irs_socklen_t salen, + char *host, irs_buflen_t hostlen, + char *serv, irs_buflen_t servlen, + irs_flags_t flags); + +irs_gaistrerror_t +irs_gai_strerror(int ecode); + +#ifndef IRS_NO_GETADDRINFO_COMPAT +#define getaddrinfo irs_getaddrinfo +#define freeaddrinfo irs_freeaddrinfo +#define getnameinfo irs_getnameinfo +#define gai_strerror irs_gai_strerror +#endif + /* * Tell Emacs to use C mode on this file. * Local variables: diff --git a/lib/irs/resconf.c b/lib/irs/resconf.c index 2ec6ac8..7480ff6 100644 --- a/lib/irs/resconf.c +++ b/lib/irs/resconf.c @@ -46,7 +46,6 @@ #include <ctype.h> #include <errno.h> -#include <netdb.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -58,6 +57,7 @@ #include <isc/util.h> #include <irs/resconf.h> +#include <irs/netdb.h> #define IRS_RESCONF_MAGIC ISC_MAGIC('R', 'E', 'S', 'c') #define IRS_RESCONF_VALID(c) ISC_MAGIC_VALID(c, IRS_RESCONF_MAGIC) -- 2.9.3
Subject: 0002-Allow-usage-of-getaddrinfo-provided-by-the-system.patch
From 76a55c18a68a2ff3443606677a841a820398c509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com> Date: Tue, 21 Feb 2017 13:16:29 +0100 Subject: [PATCH 2/2] Allow usage of getaddrinfo provided by the system --- config.h.in | 3 ++ configure | 70 ++++++++++++++++++++++++++++++++++++++++++ configure.in | 43 ++++++++++++++++++++++++++ lib/irs/Makefile.in | 11 ++++--- lib/irs/include/irs/netdb.h.in | 3 ++ 5 files changed, 126 insertions(+), 4 deletions(-) diff --git a/config.h.in b/config.h.in index 4dad23d..d2018c8 100644 --- a/config.h.in +++ b/config.h.in @@ -323,6 +323,9 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if you have the `nanosleep' function. */ #undef HAVE_NANOSLEEP +/* Define to 1 to use native getaddrinfo and getnameinfo */ +#undef HAVE_NATIVEADDRINFO + /* Define to 1 if you have the <net/if6.h> header file. */ #undef HAVE_NET_IF6_H diff --git a/configure b/configure index 4f2a278..f6a9275 100755 --- a/configure +++ b/configure @@ -746,6 +746,9 @@ LWRES_PLATFORM_NEEDSTRTOUL ISC_PLATFORM_NEEDSTRTOUL ISC_PLATFORM_NEEDMEMMOVE ISC_PLATFORM_NEEDSTRSEP +USE_NATIVE_ADDRINFO_SRCS +USE_NATIVE_ADDRINFO_OBJS +USE_CUSTOM_ADDRINFO ISC_IRS_GETNAMEINFOSOCKLEN ISC_LWRES_GETNAMEINFOPROTO ISC_LWRES_GETADDRINFOPROTO @@ -1005,6 +1008,7 @@ with_export_includedir enable_ipv6 with_kame enable_getifaddrs +enable_nativeaddrinfo with_readline enable_isc_spnego enable_chroot @@ -1685,6 +1689,7 @@ Optional Features: [default=no] --enable-ipv6 use IPv6 default=autodetect --enable-getifaddrs Enable the use of getifaddrs() [yes|no]. + --enable-nativeaddrinfo Use native getaddrinfo in irs library [yes|no]. --disable-isc-spnego use SPNEGO from GSSAPI library --disable-chroot disable chroot --disable-linux-caps disable linux capabilities @@ -17564,6 +17569,71 @@ no) ;; esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct addrinfo flags" >&5 +$as_echo_n "checking for struct addrinfo flags... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> +struct addrinfo a; a.ai_flags=AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST; +int +main () +{ +return(0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + ADDRINFO_FLAGS=yes +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ADDRINFO_FLAGS=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +# Check whether --enable-nativeaddrinfo was given. +if test "${enable_nativeaddrinfo+set}" = set; then : + enableval=$enable_nativeaddrinfo; want_nativeaddrinfo="$enableval" +else + want_nativeaddrinfo="no" +fi + + +if test "$want_nativeaddrinfo" = "yes" +then + for FUNC in getnameinfo getaddrinfo gai_strerror + do + if test "yes" != "$ac_cv_func_$FUNC" + then + as_fn_error $? "System addrinfo calls not supported" "$LINENO" 5 + want_nativeaddrinfo="no" + fi + done +fi + +if test "$want_nativeaddrinfo" = "yes" -a "$ADDRINFO_FLAGS" = "yes" +then + USE_NATIVE_ADDRINFO_OBJS='' + USE_NATIVE_ADDRINFO_SRCS='' + +$as_echo "#define HAVE_NATIVEADDRINFO 1" >>confdefs.h + + USE_CUSTOM_ADDRINFO=0 +else + USE_NATIVE_ADDRINFO_OBJS='${ADDRINFO_OBJS}' + USE_NATIVE_ADDRINFO_SRCS='${ADDRINFO_SRCS}' + USE_CUSTOM_ADDRINFO=1 +fi + + + + # # Look for a sysctl call to get the list of network interfaces. # diff --git a/configure.in b/configure.in index a39adcf..39a236a 100644 --- a/configure.in +++ b/configure.in @@ -2646,6 +2646,49 @@ no) ;; esac +AC_MSG_CHECKING(for struct addrinfo flags) +AC_TRY_COMPILE([ +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> +struct addrinfo a; a.ai_flags=AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST;], +[return(0);], + [AC_MSG_RESULT(yes) + ADDRINFO_FLAGS=yes], + [AC_MSG_RESULT(no) + ADDRINFO_FLAGS=no]) + +AC_ARG_ENABLE(nativeaddrinfo, +[ --enable-nativeaddrinfo Use native getaddrinfo in irs library [[yes|no]].], + want_nativeaddrinfo="$enableval", want_nativeaddrinfo="no") + +if test "$want_nativeaddrinfo" = "yes" +then + for FUNC in getnameinfo getaddrinfo gai_strerror + do + if test "yes" != "$ac_cv_func_$FUNC" + then + AC_MSG_ERROR(System addrinfo calls not supported) + want_nativeaddrinfo="no" + fi + done +fi + +if test "$want_nativeaddrinfo" = "yes" -a "$ADDRINFO_FLAGS" = "yes" +then + USE_NATIVE_ADDRINFO_OBJS='' + USE_NATIVE_ADDRINFO_SRCS='' + AC_DEFINE(HAVE_NATIVEADDRINFO, [1], [Define to 1 to use native getaddrinfo and getnameinfo]) + USE_CUSTOM_ADDRINFO=0 +else + USE_NATIVE_ADDRINFO_OBJS='${ADDRINFO_OBJS}' + USE_NATIVE_ADDRINFO_SRCS='${ADDRINFO_SRCS}' + USE_CUSTOM_ADDRINFO=1 +fi +AC_SUBST(USE_CUSTOM_ADDRINFO) +AC_SUBST(USE_NATIVE_ADDRINFO_OBJS) +AC_SUBST(USE_NATIVE_ADDRINFO_SRCS) + # # Look for a sysctl call to get the list of network interfaces. # diff --git a/lib/irs/Makefile.in b/lib/irs/Makefile.in index fc302b2..b4ec562 100644 --- a/lib/irs/Makefile.in +++ b/lib/irs/Makefile.in @@ -30,17 +30,20 @@ CINCLUDES = -I. -I./include -I${srcdir}/include \ CDEFINES = CWARNINGS = +ADDRINFO_OBJS = gai_strerror.@O@ getaddrinfo.@O@ getnameinfo.@O@ +ADDRINFO_SRCS = gai_strerror.c getaddrinfo.c getnameinfo.c + # Alphabetically OBJS = context.@O@ \ dnsconf.@O@ \ - gai_strerror.@O@ getaddrinfo.@O@ getnameinfo.@O@ \ - resconf.@O@ + resconf.@O@ \ + @USE_NATIVE_ADDRINFO_OBJS@ # Alphabetically SRCS = context.c \ dnsconf.c \ - gai_strerror.c getaddrinfo.c getnameinfo.c \ - resconf.c + resconf.c \ + @USE_NATIVE_ADDRINFO_SRCS@ LIBS = @LIBS@ diff --git a/lib/irs/include/irs/netdb.h.in b/lib/irs/include/irs/netdb.h.in index 3cf173f..fd9dce3 100644 --- a/lib/irs/include/irs/netdb.h.in +++ b/lib/irs/include/irs/netdb.h.in @@ -24,6 +24,7 @@ #include <stddef.h> /* Required on FreeBSD (and others?) for size_t. */ #include <netdb.h> /* Contractual provision. */ +#if @USE_CUSTOM_ADDRINFO@ /* * Define if <netdb.h> does not declare struct addrinfo. */ @@ -185,6 +186,8 @@ irs_gai_strerror(int ecode); #define gai_strerror irs_gai_strerror #endif +#endif /* USE_CUSTOM_ADDRINFO */ + /* * Tell Emacs to use C mode on this file. * Local variables: -- 2.9.3
I think this problem may already have been addressed by remapping getaddrinfo() to irs_getaddrinfo() in lib/irs/include/irs/netdb.h.in. The patch seems to address the same problem in a more expansive way, and may be useful, but I don't think there's any urgency about it now.
On Wed Oct 04 21:42:27 2017, each wrote: > I think this problem may already have been addressed by remapping > getaddrinfo() to irs_getaddrinfo() in lib/irs/include/irs/netdb.h.in. > > The patch seems to address the same problem in a more expansive way, and > may be useful, but I don't think there's any urgency about it now. Yes, I think that change solves this issue and this one can be closed.