Change our module code to not use the special symbol name init_module()
authorAndrew Tridgell <tridge@samba.org>
Tue, 17 Jun 2008 03:11:29 +0000 (13:11 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 17 Jun 2008 03:11:29 +0000 (13:11 +1000)
Current glibc libraries include a function called init_module(). If we
use the same name, then a dlsym() can find the glibc function if the
module doesn't have an initialisation function.

In ldb, none of our modules have an init_module(), so we end up calling the libc
functions with bogus arguments.
(This used to be commit 1b0621068998590e7b1e9528b78744dcd2cd5909)

source4/include/includes.h
source4/lib/ldb/common/ldb.c
source4/lib/ldb/common/ldb_modules.c
source4/param/util.c

index 1a92e4665718749a11290bb92055a90e4a2856e0..df0d8f77132ba53d728f20fe09d25d86e6a61b5c 100644 (file)
 #define TALLOC_ABORT(reason) smb_panic(reason)
 #endif
 
+/* this needs to be a string which is not in the C library. We
+   previously used "init_module", but that meant that modules which
+   did not define this function ended up calling the C library
+   function init_module() which makes a system call */
+#define SAMBA_INIT_MODULE "samba_init_module"
+
 #endif /* _INCLUDES_H */
index d0570c538211eefa2f9a5d45db10b910dab62ce9..cac0a383d8d6e2c0112c93e8ad69691d5a907c5c 100644 (file)
@@ -184,16 +184,6 @@ int ldb_connect_backend(struct ldb_context *ldb,
 
        fn = ldb_find_backend(backend);
 
-       if (fn == NULL) {
-               int (*init_fn) (void);
-
-               init_fn = ldb_dso_load_symbol(ldb, backend,
-                                             "init_module");
-               if (init_fn != NULL && init_fn() == 0) {
-                       fn = ldb_find_backend(backend);
-               }
-       }
-
        if (fn == NULL) {
                struct ldb_backend_ops *ops;
                char *symbol_name = talloc_asprintf(ldb, "ldb_%s_backend_ops", backend);
index ddbe0f23a60cee35c904c92f20eff172b728836b..fbfb5e5322fdca4f05e71e2066908e6e049c37ca 100644 (file)
@@ -223,16 +223,6 @@ int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, str
                const struct ldb_module_ops *ops;
                
                ops = ldb_find_module_ops(module_list[i]);
-               if (ops == NULL) {
-                       int (*init_fn) (void);
-
-                       init_fn = ldb_dso_load_symbol(ldb, module_list[i], 
-                                                     "init_module");
-                       if (init_fn != NULL && init_fn() == 0) {
-                               ops = ldb_find_module_ops(module_list[i]);
-                       }
-               }
-
                if (ops == NULL) {
                        char *symbol_name = talloc_asprintf(ldb, "ldb_%s_module_ops", 
                                                                                                module_list[i]);
index 15e3b4768ceb5ebe094bbd599be38174b4aee09b..ec192939d0a1933d78379211747b1e682c458a1b 100644 (file)
@@ -182,7 +182,7 @@ init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path)
                return NULL;
        }
 
-       init_fn = dlsym(handle, "init_module");
+       init_fn = dlsym(handle, SAMBA_INIT_MODULE);
 
        if (init_fn == NULL) {
                DEBUG(0, ("Unable to find init_module() in %s: %s\n", path, dlerror()));