uwrap: Don't do a deep bind if we run with libasan
authorAndreas Schneider <asn@samba.org>
Sat, 1 Sep 2018 17:43:20 +0000 (19:43 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 3 Jun 2019 10:54:22 +0000 (12:54 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@samba.org>
src/uid_wrapper.c

index c362d41212afb391935023651458b9f314d8db79..85dd2bac75667e1c31070fe78b6a7a067d84bb45 100644 (file)
@@ -395,7 +395,25 @@ static void *uwrap_load_lib_handle(enum uwrap_lib lib)
        int i;
 
 #ifdef RTLD_DEEPBIND
-       flags |= RTLD_DEEPBIND;
+       const char *env_preload = getenv("LD_PRELOAD");
+       const char *env_deepbind = getenv("UID_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) {