nwrap: Add missing check for gethostbyname2_r()
authorAndreas Schneider <asn@samba.org>
Tue, 17 Mar 2020 17:07:44 +0000 (18:07 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 17 Mar 2020 17:13:59 +0000 (18:13 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@suse.de>
ConfigureChecks.cmake
config.h.cmake
src/nss_wrapper.c

index 2947a8edee3b600f30f122d8b9d3ca5ac5111f6b..30510d84741e9a4fd0d79d2d3cf51b71ec0991e1 100644 (file)
@@ -77,6 +77,7 @@ check_function_exists(gethostbyaddr_r HAVE_GETHOSTBYADDR_R)
 check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R)
 
 check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2)
+check_function_exists(gethostbyname2_r HAVE_GETHOSTBYNAME2_R)
 
 check_function_exists(getprogname HAVE_GETPROGNAME)
 check_function_exists(getexecname HAVE_GETEXECNAME)
index de0b5dfba27d6e1fec2a45693cd85407b36808a7..41b25319f9dfb1f808f596e159f9fd8fb7c7356c 100644 (file)
@@ -59,6 +59,9 @@
 /* Define to 1 if you have the `gethostbyname2' function. */
 #cmakedefine HAVE_GETHOSTBYNAME2 1
 
+/* Define to 1 if you have the `gethostbyname2_r' function. */
+#cmakedefine HAVE_GETHOSTBYNAME2_R 1
+
 #cmakedefine HAVE_GETPROGNAME 1
 #cmakedefine HAVE_GETEXECNAME 1
 
index 4c7d36d913611f5519210cd1903333ecf8d173ef..b02e11fd1dd2d12d8151c76a8de4bbc2c783a734 100644 (file)
@@ -351,6 +351,15 @@ struct nwrap_libc_fns {
        struct hostent *(*_libc_gethostbyname)(const char *name);
 #ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
        struct hostent *(*_libc_gethostbyname2)(const char *name, int af);
+#endif
+#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */
+       int (*_libc_gethostbyname2_r)(const char *name,
+                                     int af,
+                                     struct hostent *ret,
+                                     char *buf,
+                                     size_t buflen,
+                                     struct hostent **result,
+                                     int *h_errnop);
 #endif
        struct hostent *(*_libc_gethostbyaddr)(const void *addr, socklen_t len, int type);
 
@@ -1376,6 +1385,27 @@ static struct hostent *libc_gethostbyname2(const char *name, int af)
 }
 #endif
 
+#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */
+static int libc_gethostbyname2_r(const char *name,
+                                int af,
+                                struct hostent *ret,
+                                char *buf,
+                                size_t buflen,
+                                struct hostent **result,
+                                int *h_errnop)
+{
+       nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname2_r);
+
+       return nwrap_main_global->libc->fns->_libc_gethostbyname2_r(name,
+                                                                   af,
+                                                                   ret,
+                                                                   buf,
+                                                                   buflen,
+                                                                   result,
+                                                                   h_errnop);
+}
+#endif
+
 static struct hostent *libc_gethostbyaddr(const void *addr,
                                          socklen_t len,
                                          int type)