summaryrefslogtreecommitdiff
path: root/source3/auth
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
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')
-rw-r--r--source3/auth/auth.c31
-rw-r--r--source3/auth/auth_builtin.c10
-rw-r--r--source3/auth/auth_domain.c8
-rw-r--r--source3/auth/auth_rhosts.c8
-rw-r--r--source3/auth/auth_sam.c10
-rw-r--r--source3/auth/auth_server.c4
-rw-r--r--source3/auth/auth_unix.c4
-rw-r--r--source3/auth/auth_winbind.c4
8 files changed, 43 insertions, 36 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))) {
diff --git a/source3/auth/auth_builtin.c b/source3/auth/auth_builtin.c
index 5d72898006..5a9b5534ab 100644
--- a/source3/auth/auth_builtin.c
+++ b/source3/auth/auth_builtin.c
@@ -163,12 +163,12 @@ static NTSTATUS auth_init_fixed_challenge(struct auth_context *auth_context, con
}
#endif /* DEVELOPER */
-int auth_builtin_init(void)
+NTSTATUS auth_builtin_init(void)
{
- smb_register_auth("guest", auth_init_guest, AUTH_INTERFACE_VERSION);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "guest", auth_init_guest);
#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);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "fixed_challenge", auth_init_fixed_challenge);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "name_to_ntstatus", auth_init_name_to_ntstatus);
#endif
- return True;
+ return NT_STATUS_OK;
}
diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c
index db5f7d82b0..bc03fecf74 100644
--- a/source3/auth/auth_domain.c
+++ b/source3/auth/auth_domain.c
@@ -557,9 +557,9 @@ NTSTATUS auth_init_trustdomain(struct auth_context *auth_context, const char* pa
return NT_STATUS_OK;
}
-int auth_domain_init(void)
+NTSTATUS 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;
+ smb_register_auth(AUTH_INTERFACE_VERSION, "trustdomain", auth_init_trustdomain);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "ntdomain", auth_init_ntdomain);
+ return NT_STATUS_OK;
}
diff --git a/source3/auth/auth_rhosts.c b/source3/auth/auth_rhosts.c
index db37193579..0875c48280 100644
--- a/source3/auth/auth_rhosts.c
+++ b/source3/auth/auth_rhosts.c
@@ -243,9 +243,9 @@ NTSTATUS auth_init_rhosts(struct auth_context *auth_context, const char *param,
return NT_STATUS_OK;
}
-int auth_rhosts_init(void)
+NTSTATUS 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;
+ smb_register_auth(AUTH_INTERFACE_VERSION, "rhosts", auth_init_rhosts);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "hostsequiv", auth_init_hostsequiv);
+ return NT_STATUS_OK;
}
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c
index aa399f33e2..33ea9bc73e 100644
--- a/source3/auth/auth_sam.c
+++ b/source3/auth/auth_sam.c
@@ -563,10 +563,10 @@ NTSTATUS auth_init_samstrict_dc(struct auth_context *auth_context, const char *p
return NT_STATUS_OK;
}
-int auth_sam_init(void)
+NTSTATUS 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;
+ smb_register_auth(AUTH_INTERFACE_VERSION, "samstrict_dc", auth_init_samstrict_dc);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "samstrict", auth_init_samstrict);
+ smb_register_auth(AUTH_INTERFACE_VERSION, "sam", auth_init_sam);
+ return NT_STATUS_OK;
}
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index a311f01dc3..73af290af2 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -401,7 +401,7 @@ NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const char* para
return NT_STATUS_OK;
}
-int auth_server_init(void)
+NTSTATUS auth_server_init(void)
{
- return smb_register_auth("smbserver", auth_init_smbserver, AUTH_INTERFACE_VERSION);
+ return smb_register_auth(AUTH_INTERFACE_VERSION, "smbserver", auth_init_smbserver);
}
diff --git a/source3/auth/auth_unix.c b/source3/auth/auth_unix.c
index efab2046c3..392178f77c 100644
--- a/source3/auth/auth_unix.c
+++ b/source3/auth/auth_unix.c
@@ -130,7 +130,7 @@ NTSTATUS auth_init_unix(struct auth_context *auth_context, const char* param, au
return NT_STATUS_OK;
}
-int auth_unix_init(void)
+NTSTATUS auth_unix_init(void)
{
- return smb_register_auth("unix", auth_init_unix, AUTH_INTERFACE_VERSION);
+ return smb_register_auth(AUTH_INTERFACE_VERSION, "unix", auth_init_unix);
}
diff --git a/source3/auth/auth_winbind.c b/source3/auth/auth_winbind.c
index 840898415b..76b5c34183 100644
--- a/source3/auth/auth_winbind.c
+++ b/source3/auth/auth_winbind.c
@@ -147,7 +147,7 @@ NTSTATUS auth_init_winbind(struct auth_context *auth_context, const char *param,
return NT_STATUS_OK;
}
-int auth_winbind_init(void)
+NTSTATUS auth_winbind_init(void)
{
- return smb_register_auth("winbind", auth_init_winbind, AUTH_INTERFACE_VERSION);
+ return smb_register_auth(AUTH_INTERFACE_VERSION, "winbind", auth_init_winbind);
}