summaryrefslogtreecommitdiff
path: root/source3/auth
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2003-03-24 23:03:46 +0000
committerJelmer Vernooij <jelmer@samba.org>2003-03-24 23:03:46 +0000
commit6d6f1c0522201792412b4618098536bcc45f4919 (patch)
tree9a35a31e8c33dcd93d1fc5531a50c1dc7eab35cb /source3/auth
parentcdfe4b9b85441678067c37e438ed1c29ee5fa1cf (diff)
downloadsamba-6d6f1c0522201792412b4618098536bcc45f4919.tar.gz
samba-6d6f1c0522201792412b4618098536bcc45f4919.tar.bz2
samba-6d6f1c0522201792412b4618098536bcc45f4919.zip
- Add support to auth/ for the new modules system
- Quite some small fixes (also fixes the build) (This used to be commit 3defbd5e0633acfa4631531b49601c7706072d86)
Diffstat (limited to 'source3/auth')
-rw-r--r--source3/auth/auth.c94
-rw-r--r--source3/auth/auth_builtin.c54
-rw-r--r--source3/auth/auth_domain.c7
-rw-r--r--source3/auth/auth_rhosts.c7
-rw-r--r--source3/auth/auth_sam.c8
-rw-r--r--source3/auth/auth_server.c5
-rw-r--r--source3/auth/auth_unix.c4
-rw-r--r--source3/auth/auth_winbind.c5
8 files changed, 103 insertions, 81 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c
index 8b33010e91..4416f93fba 100644
--- a/source3/auth/auth.c
+++ b/source3/auth/auth.c
@@ -23,27 +23,45 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
-/** List of various built-in authentication modules */
-
-static const struct auth_init_function_entry builtin_auth_init_functions[] = {
- { "guest", auth_init_guest },
- { "rhosts", auth_init_rhosts },
- { "hostsequiv", auth_init_hostsequiv },
- { "sam", auth_init_sam },
- { "samstrict", auth_init_samstrict },
- { "samstrict_dc", auth_init_samstrict_dc },
- { "unix", auth_init_unix },
- { "smbserver", auth_init_smbserver },
- { "ntdomain", auth_init_ntdomain },
- { "trustdomain", auth_init_trustdomain },
- { "winbind", auth_init_winbind },
-#ifdef DEVELOPER
- { "name_to_ntstatus", auth_init_name_to_ntstatus },
- { "fixed_challenge", auth_init_fixed_challenge },
-#endif
- { "plugin", auth_init_plugin },
- { NULL, NULL}
-};
+static struct auth_init_function_entry *backends = NULL;
+
+BOOL smb_register_auth(const char *name, auth_init_function init, int version)
+{
+ struct auth_init_function_entry *entry = backends;
+
+ if(version != AUTH_INTERFACE_VERSION)
+ return False;
+
+ DEBUG(5,("Attempting to register auth backend %s\n", name));
+
+ while(entry) {
+ if (strequal(name, entry->name)) {
+ DEBUG(0,("There already is an auth backend registered with the name %s!\n", name));
+ return False;
+ }
+ entry = entry->next;
+ }
+
+ entry = smb_xmalloc(sizeof(struct auth_init_function_entry));
+ entry->name = smb_xstrdup(name);
+ entry->init = init;
+
+ DLIST_ADD(backends, entry);
+ DEBUG(5,("Successfully added auth backend '%s'\n", name));
+ return True;
+}
+
+static struct auth_init_function_entry *auth_find_backend_entry(const char *name)
+{
+ struct auth_init_function_entry *entry = backends;
+
+ while(entry) {
+ if (strequal(entry->name, name)) return entry;
+ entry = entry->next;
+ }
+
+ return NULL;
+}
/****************************************************************************
Try to get a challenge out of the various authentication modules.
@@ -325,8 +343,8 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context,
auth_methods *list = NULL;
auth_methods *t = NULL;
auth_methods *tmp;
- int i;
NTSTATUS nt_status;
+ static BOOL initialised_static_modules = False;
if (!text_list) {
DEBUG(2,("make_auth_context_text_list: No auth method list!?\n"));
@@ -335,11 +353,17 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context,
if (!NT_STATUS_IS_OK(nt_status = make_auth_context(auth_context)))
return nt_status;
+
+ /* Initialise static modules if not done so yet */
+ if(!initialised_static_modules) {
+ static_init_auth;
+ initialised_static_modules = True;
+ }
for (;*text_list; text_list++) {
DEBUG(5,("make_auth_context_text_list: Attempting to find an auth method to match %s\n",
*text_list));
- for (i = 0; builtin_auth_init_functions[i].name; i++) {
+ struct auth_init_function_entry *entry;
char *module_name = smb_xstrdup(*text_list);
char *module_params = NULL;
char *p;
@@ -353,20 +377,20 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context,
trim_string(module_name, " ", " ");
- if (strequal(builtin_auth_init_functions[i].name, module_name)) {
- DEBUG(5,("make_auth_context_text_list: Found auth method %s (at pos %d)\n", *text_list, i));
- if (NT_STATUS_IS_OK(builtin_auth_init_functions[i].init(*auth_context, module_params, &t))) {
- DEBUG(5,("make_auth_context_text_list: auth method %s has a valid init\n",
- *text_list));
- DLIST_ADD_END(list, t, tmp);
- } else {
- DEBUG(0,("make_auth_context_text_list: auth method %s did not correctly init\n",
- *text_list));
- }
- break;
+ entry = auth_find_backend_entry(module_name);
+
+ if(!(entry = auth_find_backend_entry(module_name)) && !smb_probe_module("auth", module_name) &&
+ !(entry = auth_find_backend_entry(module_name))) {
+ DEBUG(0,("make_auth_context_text_list: can't find auth method %s!\n", module_name));
+ } else if (!NT_STATUS_IS_OK(entry->init(*auth_context, module_params, &t))) {
+ DEBUG(0,("make_auth_context_text_list: auth method %s did not correctly init\n",
+ *text_list));
+ } else {
+ DEBUG(5,("make_auth_context_text_list: auth method %s has a valid init\n",
+ *text_list));
+ DLIST_ADD_END(list, t, tmp);
}
SAFE_FREE(module_name);
- }
}
(*auth_context)->auth_method_list = list;
diff --git a/source3/auth/auth_builtin.c b/source3/auth/auth_builtin.c
index 3b0b84b525..509a4afba9 100644
--- a/source3/auth/auth_builtin.c
+++ b/source3/auth/auth_builtin.c
@@ -1,6 +1,6 @@
/*
Unix SMB/CIFS implementation.
- Generic authenticaion types
+ Generic authentication types
Copyright (C) Andrew Bartlett 2001-2002
Copyright (C) Jelmer Vernooij 2002
@@ -161,50 +161,12 @@ NTSTATUS auth_init_fixed_challenge(struct auth_context *auth_context, const char
return NT_STATUS_OK;
}
-/**
- * Outsorce an auth module to an external loadable .so
- *
- * Only works on systems with dlopen() etc.
- **/
-
-/* Plugin modules initialisation */
-
-NTSTATUS auth_init_plugin(struct auth_context *auth_context, const char *param, auth_methods **auth_method)
+int auth_builtin_init(void)
{
- void * dl_handle;
- char *plugin_param, *plugin_name, *p;
- auth_init_function plugin_init;
-
- if (param == NULL) {
- DEBUG(0, ("auth_init_plugin: The plugin module needs an argument!\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- plugin_name = smb_xstrdup(param);
- p = strchr(plugin_name, ':');
- if (p) {
- *p = 0;
- plugin_param = p+1;
- trim_string(plugin_param, " ", " ");
- } else plugin_param = NULL;
-
- trim_string(plugin_name, " ", " ");
-
- DEBUG(5, ("auth_init_plugin: Trying to load auth plugin %s\n", plugin_name));
- dl_handle = sys_dlopen(plugin_name, RTLD_NOW );
- if (!dl_handle) {
- DEBUG(0, ("auth_init_plugin: Failed to load auth plugin %s using sys_dlopen (%s)\n",
- plugin_name, sys_dlerror()));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- plugin_init = sys_dlsym(dl_handle, "auth_init");
- if (!plugin_init){
- DEBUG(0, ("Failed to find function 'auth_init' using sys_dlsym in sam plugin %s (%s)\n",
- plugin_name, sys_dlerror()));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- DEBUG(5, ("Starting sam plugin %s with paramater %s\n", plugin_name, plugin_param?plugin_param:"(null)"));
- return plugin_init(auth_context, plugin_param, auth_method);
+ smb_register_auth("guest", auth_init_guest, AUTH_INTERFACE_VERSION);
+#ifdef DEVELOPER
+ smb_register_auth("fixed_challenge", auth_init_fixed_challenge, AUTH_INTERFACE_VERSION);
+ smb_register_auth("name_to_ntstatus", auth_init_name_to_ntstatus, AUTH_INTERFACE_VERSION);
+#endif
+ return True;
}
diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c
index 7cf7ed1199..9ca2f4e190 100644
--- a/source3/auth/auth_domain.c
+++ b/source3/auth/auth_domain.c
@@ -545,3 +545,10 @@ NTSTATUS auth_init_trustdomain(struct auth_context *auth_context, const char* pa
(*auth_method)->auth = check_trustdomain_security;
return NT_STATUS_OK;
}
+
+int auth_domain_init(void)
+{
+ smb_register_auth("trustdomain", auth_init_trustdomain, AUTH_INTERFACE_VERSION);
+ smb_register_auth("ntdomain", auth_init_ntdomain, AUTH_INTERFACE_VERSION);
+ return True;
+}
diff --git a/source3/auth/auth_rhosts.c b/source3/auth/auth_rhosts.c
index 5451f7d930..db37193579 100644
--- a/source3/auth/auth_rhosts.c
+++ b/source3/auth/auth_rhosts.c
@@ -242,3 +242,10 @@ NTSTATUS auth_init_rhosts(struct auth_context *auth_context, const char *param,
(*auth_method)->name = "rhosts";
return NT_STATUS_OK;
}
+
+int auth_rhosts_init(void)
+{
+ smb_register_auth("rhosts", auth_init_rhosts, AUTH_INTERFACE_VERSION);
+ smb_register_auth("hostsequiv", auth_init_hostsequiv, AUTH_INTERFACE_VERSION);
+ return True;
+}
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c
index 48fabba0a2..aa399f33e2 100644
--- a/source3/auth/auth_sam.c
+++ b/source3/auth/auth_sam.c
@@ -562,3 +562,11 @@ NTSTATUS auth_init_samstrict_dc(struct auth_context *auth_context, const char *p
(*auth_method)->name = "samstrict_dc";
return NT_STATUS_OK;
}
+
+int auth_sam_init(void)
+{
+ smb_register_auth("samstrict_dc", auth_init_samstrict_dc, AUTH_INTERFACE_VERSION);
+ smb_register_auth("samstrict", auth_init_samstrict, AUTH_INTERFACE_VERSION);
+ smb_register_auth("sam", auth_init_sam, AUTH_INTERFACE_VERSION);
+ return True;
+}
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index 5144852d3b..a311f01dc3 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -400,3 +400,8 @@ NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const char* para
(*auth_method)->free_private_data = free_server_private_data;
return NT_STATUS_OK;
}
+
+int auth_server_init(void)
+{
+ return smb_register_auth("smbserver", auth_init_smbserver, AUTH_INTERFACE_VERSION);
+}
diff --git a/source3/auth/auth_unix.c b/source3/auth/auth_unix.c
index 4f44767a81..efab2046c3 100644
--- a/source3/auth/auth_unix.c
+++ b/source3/auth/auth_unix.c
@@ -130,3 +130,7 @@ NTSTATUS auth_init_unix(struct auth_context *auth_context, const char* param, au
return NT_STATUS_OK;
}
+int auth_unix_init(void)
+{
+ return smb_register_auth("unix", auth_init_unix, AUTH_INTERFACE_VERSION);
+}
diff --git a/source3/auth/auth_winbind.c b/source3/auth/auth_winbind.c
index 5e1567d3c1..e2a292dd01 100644
--- a/source3/auth/auth_winbind.c
+++ b/source3/auth/auth_winbind.c
@@ -134,3 +134,8 @@ NTSTATUS auth_init_winbind(struct auth_context *auth_context, const char *param,
(*auth_method)->auth = check_winbind_security;
return NT_STATUS_OK;
}
+
+int auth_winbind_init(void)
+{
+ return smb_register_auth("winbind", auth_init_winbind, AUTH_INTERFACE_VERSION);
+}