summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/module.c35
-rw-r--r--source3/param/loadparm.c6
-rw-r--r--source3/passdb/pdb_interface.c53
-rw-r--r--source3/smbd/server.c3
-rw-r--r--source3/utils/pdbedit.c3
-rw-r--r--source3/utils/testparm.c6
6 files changed, 77 insertions, 29 deletions
diff --git a/source3/lib/module.c b/source3/lib/module.c
index dd94f79950..4e2fe48af7 100644
--- a/source3/lib/module.c
+++ b/source3/lib/module.c
@@ -75,18 +75,47 @@ int smb_load_modules(const char **modules)
return success;
}
+int smb_probe_module(const char *subsystem, const char *module)
+{
+ pstring full_path;
+
+ /* Check for absolute path */
+ if(module[0] == '/')return smb_load_module(module);
+
+ pstrcpy(full_path, lib_path(subsystem));
+ pstrcat(full_path, "/");
+ pstrcat(full_path, module);
+ pstrcat(full_path, ".");
+ pstrcat(full_path, shlib_ext());
+
+ return smb_load_module(full_path);
+}
+
#else /* HAVE_DLOPEN */
int smb_load_module(const char *module_name)
{
- DEBUG(0,("This samba executable has not been build with plugin support"));
+ DEBUG(0,("This samba executable has not been built with plugin support"));
return False;
}
int smb_load_modules(const char **modules)
{
- DEBUG(0,("This samba executable has not been build with plugin support"));
- return -1;
+ DEBUG(0,("This samba executable has not been built with plugin support"));
+ return False;
+}
+
+int smb_probe_module(const char *subsystem, const char *module)
+{
+ DEBUG(0,("This samba executable has not been built with plugin support, not probing"));
+ return False;
}
#endif /* HAVE_DLOPEN */
+
+void init_modules(void)
+{
+ if(lp_preload_modules())
+ smb_load_modules(lp_preload_modules());
+ /* FIXME: load static modules */
+}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index b57b169adc..0eeb9be9de 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -120,7 +120,7 @@ typedef struct
char *szPrivateDir;
char **szPassdbBackend;
char **szSamBackend;
- char **szModules;
+ char **szPreloadModules;
char *szPasswordServer;
char *szSocketOptions;
char *szRealm;
@@ -823,7 +823,7 @@ static struct parm_struct parm_table[] = {
{"allow hosts", P_LIST, P_LOCAL, &sDefault.szHostsallow, NULL, NULL, FLAG_HIDE},
{"hosts deny", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_GLOBAL | FLAG_BASIC | FLAG_ADVANCED | FLAG_SHARE | FLAG_PRINT | FLAG_DEVELOPER},
{"deny hosts", P_LIST, P_LOCAL, &sDefault.szHostsdeny, NULL, NULL, FLAG_HIDE},
- {"modules", P_LIST, P_GLOBAL, &Globals.szModules, NULL, NULL, FLAG_BASIC | FLAG_GLOBAL},
+ {"preload modules", P_LIST, P_GLOBAL, &Globals.szPreloadModules, NULL, NULL, FLAG_BASIC | FLAG_GLOBAL},
{"Logging Options", P_SEP, P_SEPARATOR},
@@ -1609,7 +1609,7 @@ static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
FN_GLOBAL_LIST(lp_passdb_backend, &Globals.szPassdbBackend)
FN_GLOBAL_LIST(lp_sam_backend, &Globals.szSamBackend)
-FN_GLOBAL_LIST(lp_modules, &Globals.szModules)
+FN_GLOBAL_LIST(lp_preload_modules, &Globals.szPreloadModules)
FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index d465439dda..48a039b3de 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -86,6 +86,18 @@ BOOL smb_register_passdb(const char *name, pdb_init_function init, int version)
return True;
}
+struct pdb_init_function_entry *pdb_find_backend_entry(const char *name)
+{
+ struct pdb_init_function_entry *entry = backends;
+
+ while(entry) {
+ if (strequal(entry->name, name)) return entry;
+ entry = entry->next;
+ }
+
+ return NULL;
+}
+
static NTSTATUS context_setsampwent(struct pdb_context *context, BOOL update)
{
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
@@ -423,8 +435,6 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c
lazy_initialize_passdb();
- entry = backends;
-
p = strchr(module_name, ':');
if (p) {
@@ -435,27 +445,32 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c
trim_string(module_name, " ", " ");
+
DEBUG(5,("Attempting to find an passdb backend to match %s (%s)\n", selected, module_name));
- while(entry) {
- if (strequal(entry->name, module_name))
- {
- DEBUG(5,("Found pdb backend %s\n", module_name));
- nt_status = entry->init(context, methods, module_location);
- if (NT_STATUS_IS_OK(nt_status)) {
- DEBUG(5,("pdb backend %s has a valid init\n", selected));
- } else {
- DEBUG(0,("pdb backend %s did not correctly init (error was %s)\n", selected, nt_errstr(nt_status)));
- }
- SAFE_FREE(module_name);
- return nt_status;
- break; /* unreached */
- }
- entry = entry->next;
- }
+ entry = pdb_find_backend_entry(module_name);
+
+ /* Try to find a module that contains this module */
+ if(!entry) {
+ smb_probe_module("passdb", module_name);
+ entry = pdb_find_backend_entry(module_name);
+ }
+
/* No such backend found */
+ if(!entry) {
+ SAFE_FREE(module_name);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ DEBUG(5,("Found pdb backend %s\n", module_name));
+ nt_status = entry->init(context, methods, module_location);
+ if (NT_STATUS_IS_OK(nt_status)) {
+ DEBUG(5,("pdb backend %s has a valid init\n", selected));
+ } else {
+ DEBUG(0,("pdb backend %s did not correctly init (error was %s)\n", selected, nt_errstr(nt_status)));
+ }
SAFE_FREE(module_name);
- return NT_STATUS_INVALID_PARAMETER;
+ return nt_status;
}
/******************************************************************
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index ba03a9b9de..b7fb3b5701 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -412,8 +412,7 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
}
/* Load DSO's */
- if(lp_modules())
- smb_load_modules(lp_modules());
+ init_modules();
return True;
}
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index ee269114c9..cec3e70687 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -536,8 +536,7 @@ int main (int argc, char **argv)
exit(1);
}
- if(lp_modules())
- smb_load_modules(lp_modules());
+ init_modules();
if (!init_names())
exit(1);
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index 0fafd1b83d..b68deaaa5d 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -177,6 +177,12 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
printf("'algorithmic rid base' must be even.\n");
}
+#ifndef HAVE_DLOPEN
+ if (lp_preload_modules()) {
+ printf("WARNING: 'preload modules = ' set while loading plugins not supported.\n");
+ }
+#endif
+
return ret;
}