rwrap: Don't do a deep bind if we run with libasan
authorAndreas Schneider <asn@samba.org>
Sat, 1 Sep 2018 17:47:35 +0000 (19:47 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Sun, 20 Oct 2019 12:59:27 +0000 (14:59 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
src/resolv_wrapper.c

index b89e5427c8bf21f258052db17eca3b9bd7ab987b..10ab0cdf778773076237a5551c9f065e37e3c38a 100644 (file)
@@ -1316,7 +1316,25 @@ static void *rwrap_load_lib_handle(enum rwrap_lib lib)
        int i;
 
 #ifdef RTLD_DEEPBIND
-       flags |= RTLD_DEEPBIND;
+       const char *env_preload = getenv("LD_PRELOAD");
+       const char *env_deepbind = getenv("RESOLV_WRAPPER_DISABLE_DEEPBIND");
+       bool enable_deepbind = true;
+
+       /* Don't do a deepbind if we run with libasan */
+       if (env_preload != NULL && strlen(env_preload) < 1024) {
+               const char *p = strstr(env_preload, "libasan.so");
+               if (p != NULL) {
+                       enable_deepbind = false;
+               }
+       }
+
+       if (env_deepbind != NULL && strlen(env_deepbind) >= 1) {
+               enable_deepbind = false;
+       }
+
+       if (enable_deepbind) {
+               flags |= RTLD_DEEPBIND;
+       }
 #endif
 
        switch (lib) {