11c8e3
From e556b4067e0c4036e20fc26523e3b4d6d5c6be42 Mon Sep 17 00:00:00 2001
11c8e3
From: Andreas Schneider <asn@samba.org>
11c8e3
Date: Thu, 7 Oct 2021 15:55:37 +0200
11c8e3
Subject: [PATCH] waf: Fix resolv_wrapper with glibc 2.34
11c8e3
11c8e3
With glibc 2.34 we are not able to talk to the DNS server via socket_wrapper
11c8e3
anymore. The res_* symbols have been moved from libresolv to libc. We are not
11c8e3
able to intercept any traffic inside of libc.
11c8e3
11c8e3
Signed-off-by: Andreas Schneider <asn@samba.org>
11c8e3
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
11c8e3
Reviewed-by: Alexander Bokovoy <ab@samba.org>
11c8e3
---
11c8e3
 selftest/wscript                   |  2 +-
11c8e3
 third_party/resolv_wrapper/wscript | 13 +++++++++++++
11c8e3
 2 files changed, 14 insertions(+), 1 deletion(-)
11c8e3
11c8e3
diff --git a/selftest/wscript b/selftest/wscript
11c8e3
index a6be06c2ae9..85d9338489a 100644
11c8e3
--- a/selftest/wscript
11c8e3
+++ b/selftest/wscript
11c8e3
@@ -252,7 +252,7 @@ def cmd_testonly(opt):
11c8e3
     if os.environ.get('USE_NAMESPACES') is None:
11c8e3
         env.OPTIONS += " --socket_wrapper_so_path=" + CONFIG_GET(opt, 'LIBSOCKET_WRAPPER_SO_PATH')
11c8e3
 
11c8e3
-    if Utils.unversioned_sys_platform() in ('netbsd', 'openbsd', 'sunos'):
11c8e3
+    if not CONFIG_SET(opt, 'HAVE_RESOLV_CONF_SUPPORT'):
11c8e3
         env.OPTIONS += " --use-dns-faking"
11c8e3
 
11c8e3
     if CONFIG_GET(opt, 'USING_SYSTEM_KRB5') and CONFIG_GET(opt, 'MIT_KDC_PATH'):
11c8e3
diff --git a/third_party/resolv_wrapper/wscript b/third_party/resolv_wrapper/wscript
11c8e3
index a7f18389b0f..7e369bd90b5 100644
11c8e3
--- a/third_party/resolv_wrapper/wscript
11c8e3
+++ b/third_party/resolv_wrapper/wscript
11c8e3
@@ -1,6 +1,7 @@
11c8e3
 #!/usr/bin/env python
11c8e3
 
11c8e3
 import os
11c8e3
+from waflib import Logs
11c8e3
 
11c8e3
 VERSION="1.1.7"
11c8e3
 
11c8e3
@@ -49,6 +50,18 @@ def configure(conf):
11c8e3
         if conf.CONFIG_SET('HAVE_RES_NCLOSE'):
11c8e3
             conf.DEFINE('HAVE_RES_NCLOSE_IN_LIBRESOLV', 1)
11c8e3
 
11c8e3
+        # If we find res_nquery in libc, we can't do resolv.conf redirect
11c8e3
+        conf.CHECK_FUNCS('res_nquery __res_nquery')
11c8e3
+        if (conf.CONFIG_SET('HAVE_RES_NQUERY')
11c8e3
+                or conf.CONFIG_SET('HAVE___RES_NQUERY')):
11c8e3
+            Logs.warn("Detection for resolv_wrapper: "
11c8e3
+                      "Only dns faking will be available")
11c8e3
+        else:
11c8e3
+            if conf.CHECK_FUNCS('res_nquery', lib='resolv'):
11c8e3
+                conf.DEFINE('HAVE_RESOLV_CONF_SUPPORT', 1)
11c8e3
+            if conf.CHECK_FUNCS('__res_nquery', lib='resolv'):
11c8e3
+                conf.DEFINE('HAVE_RESOLV_CONF_SUPPORT', 1)
11c8e3
+
11c8e3
         conf.CHECK_FUNCS_IN('res_init __res_init', 'resolv', checklibc=True)
11c8e3
         conf.CHECK_FUNCS_IN('res_ninit __res_ninit', 'resolv', checklibc=True)
11c8e3
         conf.CHECK_FUNCS_IN('res_close __res_close', 'resolv', checklibc=True)
11c8e3
-- 
11c8e3
2.33.1
11c8e3