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 */
+}
char *szPrivateDir;
char **szPassdbBackend;
char **szSamBackend;
- char **szModules;
+ char **szPreloadModules;
char *szPasswordServer;
char *szSocketOptions;
char *szRealm;
{"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},
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)
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;
lazy_initialize_passdb();
- entry = backends;
-
p = strchr(module_name, ':');
if (p) {
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;
}
/******************************************************************
}
/* Load DSO's */
- if(lp_modules())
- smb_load_modules(lp_modules());
+ init_modules();
return True;
}
exit(1);
}
- if(lp_modules())
- smb_load_modules(lp_modules());
+ init_modules();
if (!init_names())
exit(1);
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;
}