ldb: Add a env variable to disable RTLD_DEEPBIND.
authorAndreas Schneider <asn@samba.org>
Tue, 4 Mar 2014 12:50:41 +0000 (13:50 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 17 Apr 2014 12:56:06 +0000 (14:56 +0200)
We need a way to disable this in order to allow the
ldb_*ldap modules to work with a preloaded socket wrapper.

The only known user is the bind_dlz module,
but symbol versioniong might be enough...

So in future we may remove this completely
or at least invert the default behavior.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/ldb/common/ldb_modules.c

index a39b12df92ecf690f718c0a985b0291ee1d62b82..05a8d8aa1dcd51b7c48591e99b5a172ee802f6c3 100644 (file)
@@ -901,6 +901,7 @@ static int ldb_modules_load_path(const char *path, const char *version)
        } *loaded;
        struct loaded *le;
        int dlopen_flags;
+       bool deepbind_enabled = (getenv("LDB_MODULES_DISABLE_DEEPBIND") == NULL);
 
        ret = stat(path, &st);
        if (ret != 0) {
@@ -934,13 +935,25 @@ static int ldb_modules_load_path(const char *path, const char *version)
 
        dlopen_flags = RTLD_NOW;
 #ifdef RTLD_DEEPBIND
-       /* use deepbind if possible, to avoid issues with different
-          system library varients, for example ldb modules may be linked
-          against Heimdal while the application may use MIT kerberos
-
-          See the dlopen manpage for details
+       /*
+        * use deepbind if possible, to avoid issues with different
+        * system library varients, for example ldb modules may be linked
+        * against Heimdal while the application may use MIT kerberos.
+        *
+        * See the dlopen manpage for details.
+        *
+        * One typical user is the bind_dlz module of Samba,
+        * but symbol versioniong might be enough...
+        *
+        * We need a way to disable this in order to allow the
+        * ldb_*ldap modules to work with a preloaded socket wrapper.
+        *
+        * So in future we may remove this completely
+        * or at least invert the default behavior.
        */
-       dlopen_flags |= RTLD_DEEPBIND;
+       if (deepbind_enabled) {
+               dlopen_flags |= RTLD_DEEPBIND;
+       }
 #endif
 
        handle = dlopen(path, dlopen_flags);