summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-09-09 21:24:49 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-10-06 07:18:07 +0200
commit7d33ec3dfe78723d62f4941684060baeb9c4bda6 (patch)
tree0ca105c694d41ebda5d6b7e9c50e0b57d4204858 /source3
parent040055bb6a578516007ab6f56ebe2ee77b0f8605 (diff)
downloadsamba-7d33ec3dfe78723d62f4941684060baeb9c4bda6.tar.gz
samba-7d33ec3dfe78723d62f4941684060baeb9c4bda6.tar.bz2
samba-7d33ec3dfe78723d62f4941684060baeb9c4bda6.zip
lib/util: consolidate module loading into common code
This creates a samba-modules private libary that handles the details. Andrew Bartlett
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/includes.h2
-rw-r--r--source3/include/module.h28
-rw-r--r--source3/include/proto.h11
-rw-r--r--source3/lib/module.c120
-rw-r--r--source3/lib/util.c9
-rwxr-xr-xsource3/wscript_build2
7 files changed, 13 insertions, 161 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index c736ae8d06..a048090cee 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -464,7 +464,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) $(LIBTSOCKET_OBJ) \
../lib/util/charset/charset_macosxfs.o intl/lang_tdb.o \
lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
lib/sessionid_tdb.o \
- lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \
+ ../lib/util/modules.o lib/events.o @LIBTEVENT_OBJ0@ \
@CCAN_OBJ@ \
lib/server_contexts.o \
lib/server_prefork.o \
diff --git a/source3/include/includes.h b/source3/include/includes.h
index b644089712..786fb4e574 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -524,7 +524,7 @@ typedef char fstring[FSTRING_LEN];
#include "smb.h"
#include "../lib/util/byteorder.h"
-#include "module.h"
+#include "../lib/util/samba_modules.h"
#include "../lib/util/talloc_stack.h"
#include "../lib/util/smb_threads.h"
#include "../lib/util/smb_threads_internal.h"
diff --git a/source3/include/module.h b/source3/include/module.h
deleted file mode 100644
index 667fac653a..0000000000
--- a/source3/include/module.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Handling of idle/exit events
- Copyright (C) Stefan (metze) Metzmacher 2003
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _MODULE_H
-#define _MODULE_H
-
-/* Module support */
-typedef NTSTATUS (init_module_function) (void);
-
-NTSTATUS init_samba_module(void);
-
-#endif /* _MODULE_H */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f6e7236664..ffc90ffd2c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -185,16 +185,6 @@ void init_ldap_debugging(void);
char *escape_ldap_string(TALLOC_CTX *mem_ctx, const char *s);
char *escape_rdn_val_string_alloc(const char *s);
-/* The following definitions come from lib/module.c */
-
-NTSTATUS smb_load_module(const char *module_name);
-int smb_load_modules(const char **modules);
-NTSTATUS smb_probe_module(const char *subsystem, const char *module);
-NTSTATUS smb_load_module(const char *module_name);
-int smb_load_modules(const char **modules);
-NTSTATUS smb_probe_module(const char *subsystem, const char *module);
-void init_modules(void);
-
/* The following definitions come from lib/ms_fnmatch.c */
int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
@@ -604,6 +594,7 @@ bool map_open_params_to_ntcreate(const char *smb_base_fname,
uint32 *pcreate_disposition,
uint32 *pcreate_options,
uint32_t *pprivate_flags);
+void init_modules(void);
/* The following definitions come from lib/util_cmdline.c */
diff --git a/source3/lib/module.c b/source3/lib/module.c
index 9cd3884c51..a85d7d0528 100644
--- a/source3/lib/module.c
+++ b/source3/lib/module.c
@@ -20,123 +20,3 @@
*/
#include "includes.h"
-
-/* Load a dynamic module. Only log a level 0 error if we are not checking
- for the existence of a module (probling). */
-
-static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
-{
- void *handle;
- init_module_function *init;
- NTSTATUS status;
- const char *error;
-
- /* Always try to use LAZY symbol resolving; if the plugin has
- * backwards compatibility, there might be symbols in the
- * plugin referencing to old (removed) functions
- */
- handle = dlopen(module_name, RTLD_LAZY);
-
- /* This call should reset any possible non-fatal errors that
- occured since last call to dl* functions */
- error = dlerror();
-
- if(!handle) {
- int level = is_probe ? 3 : 0;
- DEBUG(level, ("Error loading module '%s': %s\n", module_name, error ? error : ""));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- init = (init_module_function *)dlsym(handle, "init_samba_module");
-
- /* we must check dlerror() to determine if it worked, because
- dlsym() can validly return NULL */
- error = dlerror();
- if (error) {
- DEBUG(0, ("Error trying to resolve symbol 'init_samba_module' "
- "in %s: %s\n", module_name, error));
- dlclose(handle);
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- DEBUG(2, ("Module '%s' loaded\n", module_name));
-
- status = init();
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("Module '%s' initialization failed: %s\n",
- module_name, get_friendly_nt_error_msg(status)));
- dlclose(handle);
- }
-
- return status;
-}
-
-NTSTATUS smb_load_module(const char *module_name)
-{
- return do_smb_load_module(module_name, False);
-}
-
-/* Load all modules in list and return number of
- * modules that has been successfully loaded */
-int smb_load_modules(const char **modules)
-{
- int i;
- int success = 0;
-
- for(i = 0; modules[i]; i++){
- if(NT_STATUS_IS_OK(smb_load_module(modules[i]))) {
- success++;
- }
- }
-
- DEBUG(2, ("%d modules successfully loaded\n", success));
-
- return success;
-}
-
-NTSTATUS smb_probe_module(const char *subsystem, const char *module)
-{
- char *full_path = NULL;
- TALLOC_CTX *ctx = talloc_stackframe();
- NTSTATUS status;
-
- /* Check for absolute path */
-
- /* if we make any 'samba multibyte string'
- calls here, we break
- for loading string modules */
-
- DEBUG(5, ("Probing module '%s'\n", module));
-
- if (module[0] == '/') {
- status = do_smb_load_module(module, True);
- TALLOC_FREE(ctx);
- return status;
- }
-
- full_path = talloc_asprintf(ctx,
- "%s/%s.%s",
- modules_path(ctx, subsystem),
- module,
- shlib_ext());
- if (!full_path) {
- TALLOC_FREE(ctx);
- return NT_STATUS_NO_MEMORY;
- }
-
- DEBUG(5, ("Probing module '%s': Trying to load from %s\n",
- module, full_path));
-
- status = do_smb_load_module(full_path, True);
-
- TALLOC_FREE(ctx);
- return status;
-}
-
-void init_modules(void)
-{
- /* FIXME: This can cause undefined symbol errors :
- * smb_register_vfs() isn't available in nmbd, for example */
- if(lp_preload_modules())
- smb_load_modules(lp_preload_modules());
-}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 887d1849ee..f29568fca0 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2414,3 +2414,12 @@ bool map_open_params_to_ntcreate(const char *smb_base_fname,
return True;
}
+
+
+void init_modules(void)
+{
+ /* FIXME: This can cause undefined symbol errors :
+ * smb_register_vfs() isn't available in nmbd, for example */
+ if(lp_preload_modules())
+ smb_load_modules(lp_preload_modules());
+}
diff --git a/source3/wscript_build b/source3/wscript_build
index d105f1fb5a..74a6880725 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -817,7 +817,7 @@ bld.SAMBA3_SUBSYSTEM('KRBCLIENT',
bld.SAMBA3_SUBSYSTEM('samba3core',
source=LIB_SRC,
- deps='LIBTSOCKET LIBCRYPTO ndr security NDR_SECURITY samba-util NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 UTIL_TDB UTIL_PW SAMBA_VERSION KRB5_WRAP flag_mapping util_reg PTHREADPOOL interfaces cap string_init param util_str CHARSET3 namearray dbwrap util_sec util_malloc memcache ccan errors3',
+ deps='LIBTSOCKET LIBCRYPTO ndr security NDR_SECURITY samba-util NDR_MESSAGING LIBASYNC_REQ tdb-wrap3 UTIL_TDB UTIL_PW SAMBA_VERSION KRB5_WRAP flag_mapping util_reg PTHREADPOOL interfaces cap string_init param util_str CHARSET3 namearray dbwrap util_sec util_malloc memcache ccan errors3 samba-modules',
vars=locals())
bld.SAMBA3_LIBRARY('smbd_shim',