nwrap: Add NSS_WRAPPER_DISABLE_DEEPBIND env variable
authorAndreas Schneider <asn@samba.org>
Tue, 21 May 2019 06:30:53 +0000 (08:30 +0200)
committerAndreas Schneider <asn@samba.org>
Thu, 11 Jul 2019 20:13:06 +0000 (22:13 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
src/nss_wrapper.c

index 62c7af16774a16e9cf998d5eb3071428009121d0..33b610b6cc3905d25a366b1143267422924d2b9d 100644 (file)
@@ -848,15 +848,25 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
        int i;
 
 #ifdef RTLD_DEEPBIND
-       const char *env = getenv("LD_PRELOAD");
+       const char *env_preload = getenv("LD_PRELOAD");
+       const char *env_deepbind = getenv("NSS_WRAPPER_DISABLE_DEEPBIND");
+       bool enable_deepbind = true;
 
        /* Don't do a deepbind if we run with libasan */
-       if (env != NULL && strlen(env) < 1024) {
-               const char *p = strstr(env, "libasan.so");
-               if (p == NULL) {
-                       flags |= RTLD_DEEPBIND;
+       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) {