From 17a3acafa89bfc6090b0767d05a00a7505003fcc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 28 Apr 2003 17:48:48 +0000 Subject: 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 bc4b51bcb2daa7271c884cb83bf8bdba6d3a9b6d) --- source3/auth/auth.c | 31 +++++++++++++++++++------------ source3/auth/auth_builtin.c | 10 +++++----- source3/auth/auth_domain.c | 8 ++++---- source3/auth/auth_rhosts.c | 8 ++++---- source3/auth/auth_sam.c | 8 ++++---- source3/auth/auth_server.c | 4 ++-- source3/auth/auth_unix.c | 4 ++-- source3/auth/auth_winbind.c | 4 ++-- 8 files changed, 42 insertions(+), 35 deletions(-) (limited to 'source3/auth') 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 1fc8aa51bb..9a619f81f6 100644 --- a/source3/auth/auth_sam.c +++ b/source3/auth/auth_sam.c @@ -518,9 +518,9 @@ NTSTATUS auth_init_samstrict(struct auth_context *auth_context, const char *para return NT_STATUS_OK; } -int auth_sam_init(void) +NTSTATUS auth_sam_init(void) { - 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", 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); } -- cgit