s4-ldb: use RTLD_DEEPBIND if available for ldb modules
authorAndrew Tridgell <tridge@samba.org>
Tue, 7 Dec 2010 22:41:25 +0000 (09:41 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 8 Dec 2010 04:26:05 +0000 (05:26 +0100)
this allows us to avoid issues with ldb using heimdal while an
application using ldb using MIT kerberos

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/lib/ldb/common/ldb_modules.c

index e3301371405ea91394d30f5153d8d66a6bbcaa2a..b382a91ec8e45e2662303b1452776318b68a492c 100644 (file)
@@ -858,6 +858,7 @@ static int ldb_modules_load_path(const char *path, const char *version)
                dev_t st_dev;
        } *loaded;
        struct loaded *le;
+       int dlopen_flags;
 
        ret = stat(path, &st);
        if (ret != 0) {
@@ -889,7 +890,18 @@ static int ldb_modules_load_path(const char *path, const char *version)
                return ldb_modules_load_dir(path, version);
        }
 
-       handle = dlopen(path, RTLD_NOW);
+       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
+       */
+       dlopen_flags |= RTLD_DEEPBIND;
+#endif
+
+       handle = dlopen(path, dlopen_flags);
        if (handle == NULL) {
                fprintf(stderr, "ldb: unable to dlopen %s : %s\n", path, dlerror());
                return LDB_SUCCESS;