- Rename 'modules = ' to 'preload modules = '
authorJelmer Vernooij <jelmer@samba.org>
Thu, 27 Feb 2003 01:54:41 +0000 (01:54 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 27 Feb 2003 01:54:41 +0000 (01:54 +0000)
- Add smb_probe_module()
- Add init_modules()
- Call these functions
(This used to be commit f8f21653225792c0001d183c6efe8b7d89a0785d)

source3/lib/module.c
source3/param/loadparm.c
source3/passdb/pdb_interface.c
source3/smbd/server.c
source3/utils/pdbedit.c
source3/utils/testparm.c

index dd94f799506fd7004876d3adea1b07cdf8b1e17e..4e2fe48af70dc887c961ddb393e4178645d962e0 100644 (file)
@@ -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 */
+}
index b57b169adc609117d7851ab5a8e6c8cfea04f65b..0eeb9be9de6a0173d317fce70efd70dda42ec522 100644 (file)
@@ -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)
index d465439dda1b6f296d12a02ac1a12f9ffda19981..48a039b3dee18b32ef835fbf438c3cb687798ac6 100644 (file)
@@ -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;
 }
 
 /******************************************************************
index ba03a9b9de665f2a8aaf2a99b76fb689b662fc3a..b7fb3b5701e0d2218ce9ec622261a48765f22244 100644 (file)
@@ -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; 
                        }
index ee269114c99e372185ffbd69ddc43c8e9511d3ce..cec3e706872a89a23f7a2fb0d0e5e4dcc1f25faf 100644 (file)
@@ -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);
index 0fafd1b83d2b24336bea9dfc646e6e91d1b1d84c..b68deaaa5de12f11e6e0638f5a35f56081a6ce0b 100644 (file)
@@ -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;
 }