summaryrefslogtreecommitdiff
path: root/source3/auth/auth.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2003-04-28 18:33:25 +0000
committerJelmer Vernooij <jelmer@samba.org>2003-04-28 18:33:25 +0000
commit81256ecbb977351b4d6a992df17be4b107071935 (patch)
treeb299293b39b94c7c4fb9eb8f7ffc179aad46a03d /source3/auth/auth.c
parent023cd5ff70083526423320470c41eefef1b8f93f (diff)
downloadsamba-81256ecbb977351b4d6a992df17be4b107071935.tar.gz
samba-81256ecbb977351b4d6a992df17be4b107071935.tar.bz2
samba-81256ecbb977351b4d6a992df17be4b107071935.zip
Use NTSTATUS as return value for smb_register_*() functions and init_module()
function. Patch by metze with some minor modifications. (This used to be commit f4576757d1d52a8f1b96894c869bb76450003fd1)
Diffstat (limited to 'source3/auth/auth.c')
-rw-r--r--source3/auth/auth.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c
index 09e8f5e722..8f718e3d4d 100644
--- a/source3/auth/auth.c
+++ b/source3/auth/auth.c
@@ -25,21 +25,28 @@
static struct auth_init_function_entry *backends = NULL;
-BOOL smb_register_auth(const char *name, auth_init_function init, int version)
+static struct auth_init_function_entry *auth_find_backend_entry(const char *name);
+
+NTSTATUS smb_register_auth(uint16 version, const char *name, auth_init_function init)
{
struct auth_init_function_entry *entry = backends;
- if(version != AUTH_INTERFACE_VERSION)
- return False;
+ if (version != AUTH_INTERFACE_VERSION) {
+ DEBUG(0,("Can't register auth_method!\n"
+ "You tried to register an auth module with AUTH_INTERFACE_VERSION %d, while this version of samba uses %d\n",
+ version,AUTH_INTERFACE_VERSION));
+ return NT_STATUS_OBJECT_TYPE_MISMATCH;
+ }
+
+ if (!name || !init) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
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;
+ if (auth_find_backend_entry(name)) {
+ DEBUG(0,("There already is an auth method registered with the name %s!\n", name));
+ return NT_STATUS_OBJECT_NAME_COLLISION;
}
entry = smb_xmalloc(sizeof(struct auth_init_function_entry));
@@ -47,8 +54,8 @@ BOOL smb_register_auth(const char *name, auth_init_function init, int version)
entry->init = init;
DLIST_ADD(backends, entry);
- DEBUG(5,("Successfully added auth backend '%s'\n", name));
- return True;
+ DEBUG(5,("Successfully added auth method '%s'\n", name));
+ return NT_STATUS_OK;
}
static struct auth_init_function_entry *auth_find_backend_entry(const char *name)
@@ -365,7 +372,7 @@ BOOL load_auth_module(struct auth_context *auth_context,
entry = auth_find_backend_entry(module_name);
- if(!(entry = auth_find_backend_entry(module_name)) && !smb_probe_module("auth", module_name) &&
+ if(!(entry = auth_find_backend_entry(module_name)) && NT_STATUS_IS_ERR(smb_probe_module("auth", module_name)) &&
!(entry = auth_find_backend_entry(module_name))) {
DEBUG(0,("load_auth_module: can't find auth method %s!\n", module_name));
} else if (!NT_STATUS_IS_OK(entry->init(auth_context, module_params, ret))) {