diff options
Diffstat (limited to 'source3')
37 files changed, 163 insertions, 126 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c index 09e8f5e7225..8f718e3d4d3 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 5d72898006c..5a9b5534ab6 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 db5f7d82b08..bc03fecf749 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 db371935799..0875c482804 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 1fc8aa51bb8..9a619f81f67 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 a311f01dc3f..73af290af2a 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 efab2046c36..392178f77c1 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 840898415be..76b5c341836 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); } diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h index 77104894351..d04a84d5083 100644 --- a/source3/include/rpc_misc.h +++ b/source3/include/rpc_misc.h @@ -26,7 +26,7 @@ #ifndef _RPC_MISC_H /* _RPC_MISC_H */ #define _RPC_MISC_H - +#define SMB_RPC_INTERFACE_VERSION 1 /* well-known RIDs - Relative IDs */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 62cc95ecb08..5ee6b971721 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1736,6 +1736,6 @@ typedef struct { #include "popt_common.h" /* Module support */ -typedef int (init_module_function) (void); +typedef NTSTATUS (init_module_function) (void); #endif /* _SMB_H */ diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index 01fa31915a2..c09bff5fd7b 100644 --- a/source3/lib/iconv.c +++ b/source3/lib/iconv.c @@ -77,22 +77,23 @@ static struct charset_functions *find_charset_functions(const char *name) return NULL; } -BOOL smb_register_charset(struct charset_functions *funcs) +NTSTATUS smb_register_charset(struct charset_functions *funcs) { - struct charset_functions *c = charsets; + if (!funcs) { + return NT_STATUS_INVALID_PARAMETER; + } DEBUG(5, ("Attempting to register new charset %s\n", funcs->name)); /* Check whether we already have this charset... */ - if (find_charset_functions(funcs->name)) { DEBUG(0, ("Duplicate charset %s, not registering\n", funcs->name)); - return False; + return NT_STATUS_OBJECT_NAME_COLLISION; } funcs->next = funcs->prev = NULL; DEBUG(5, ("Registered charset %s\n", funcs->name)); DLIST_ADD(charsets, funcs); - return True; + return NT_STATUS_OK; } void lazy_initialize_iconv(void) @@ -219,14 +220,14 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) #endif /* check if there is a module available that can do this conversion */ - if (!ret->pull && smb_probe_module("charset", fromcode)) { + if (!ret->pull && NT_STATUS_IS_OK(smb_probe_module("charset", fromcode))) { if(!(from = find_charset_functions(fromcode))) DEBUG(0, ("Module %s doesn't provide charset %s!\n", fromcode, fromcode)); else ret->pull = from->pull; } - if (!ret->push && smb_probe_module("charset", tocode)) { + if (!ret->push && NT_STATUS_IS_OK(smb_probe_module("charset", tocode))) { if(!(to = find_charset_functions(tocode))) DEBUG(0, ("Module %s doesn't provide charset %s!\n", tocode, tocode)); else diff --git a/source3/lib/module.c b/source3/lib/module.c index 53223cfebe2..087c964d3c7 100644 --- a/source3/lib/module.c +++ b/source3/lib/module.c @@ -22,11 +22,11 @@ #include "includes.h" #ifdef HAVE_DLOPEN -int smb_load_module(const char *module_name) +NTSTATUS smb_load_module(const char *module_name) { void *handle; init_module_function *init; - int status; + NTSTATUS status; const char *error; /* Always try to use LAZY symbol resolving; if the plugin has @@ -37,7 +37,7 @@ int smb_load_module(const char *module_name) if(!handle) { DEBUG(0, ("Error loading module '%s': %s\n", module_name, sys_dlerror())); - return False; + return NT_STATUS_UNSUCCESSFUL; } init = sys_dlsym(handle, "init_module"); @@ -47,7 +47,7 @@ int smb_load_module(const char *module_name) error = sys_dlerror(); if (error) { DEBUG(0, ("Error trying to resolve symbol 'init_module' in %s: %s\n", module_name, error)); - return False; + return NT_STATUS_UNSUCCESSFUL; } status = init(); @@ -65,7 +65,7 @@ int smb_load_modules(const char **modules) int success = 0; for(i = 0; modules[i]; i++){ - if(smb_load_module(modules[i])) { + if(NT_STATUS_IS_OK(smb_load_module(modules[i]))) { success++; } } @@ -75,7 +75,7 @@ int smb_load_modules(const char **modules) return success; } -int smb_probe_module(const char *subsystem, const char *module) +NTSTATUS smb_probe_module(const char *subsystem, const char *module) { pstring full_path; @@ -95,22 +95,22 @@ int smb_probe_module(const char *subsystem, const char *module) #else /* HAVE_DLOPEN */ -int smb_load_module(const char *module_name) +NTSTATUS smb_load_module(const char *module_name) { DEBUG(0,("This samba executable has not been built with plugin support")); - return False; + return NT_STATUS_NOT_SUPPORTED; } int smb_load_modules(const char **modules) { DEBUG(0,("This samba executable has not been built with plugin support")); - return False; + return -1; } -int smb_probe_module(const char *subsystem, const char *module) +NTSTATUS 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; + return NT_STATUS_NOT_SUPPORTED; } #endif /* HAVE_DLOPEN */ diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c index fa9bf67a672..4f9dc1b1e40 100644 --- a/source3/modules/vfs_audit.c +++ b/source3/modules/vfs_audit.c @@ -270,7 +270,7 @@ static int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode) return result; } -int vfs_audit_init(void) +NTSTATUS vfs_audit_init(void) { - return smb_register_vfs("audit", audit_init, SMB_VFS_INTERFACE_VERSION); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "audit", audit_init); } diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c index f60acab36af..ef30ca70272 100644 --- a/source3/modules/vfs_extd_audit.c +++ b/source3/modules/vfs_extd_audit.c @@ -310,7 +310,7 @@ static int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode) return result; } -int vfs_extd_audit_init(void) +NTSTATUS vfs_extd_audit_init(void) { - return smb_register_vfs("extd_audit", audit_init, SMB_VFS_INTERFACE_VERSION); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "extd_audit", audit_init); } diff --git a/source3/modules/vfs_fake_perms.c b/source3/modules/vfs_fake_perms.c index 121a99a4519..3a18fbb730c 100644 --- a/source3/modules/vfs_fake_perms.c +++ b/source3/modules/vfs_fake_perms.c @@ -281,7 +281,7 @@ static vfs_op_tuple *fake_perms_init(const struct vfs_ops *def_vfs_ops, return fake_perms_ops; } -int vfs_fake_perms_init(void) +NTSTATUS vfs_fake_perms_init(void) { - return smb_register_vfs("fake_perms", fake_perms_init, SMB_VFS_INTERFACE_VERSION); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "fake_perms", fake_perms_init); } diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c index c9e3cde6210..718bc2a35ca 100644 --- a/source3/modules/vfs_netatalk.c +++ b/source3/modules/vfs_netatalk.c @@ -421,7 +421,7 @@ static vfs_op_tuple *netatalk_init(const struct vfs_ops *def_vfs_ops, return atalk_ops; } -int vfs_netatalk_init(void) +NTSTATUS vfs_netatalk_init(void) { - return smb_register_vfs("netatalk", netatalk_init, SMB_VFS_INTERFACE_VERSION); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "netatalk", netatalk_init); } diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index 85ce257c026..87dea944ac0 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -603,7 +603,7 @@ done: return rc; } -int vfs_recycle_init(void) -{ - return smb_register_vfs("recycle", recycle_init, SMB_VFS_INTERFACE_VERSION); +NTSTATUS vfs_recycle_init(void) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "recycle", recycle_init); } diff --git a/source3/modules/weird.c b/source3/modules/weird.c index 377a68d5187..444853f3831 100644 --- a/source3/modules/weird.c +++ b/source3/modules/weird.c @@ -125,7 +125,7 @@ static size_t weird_push(void *cd, char **inbuf, size_t *inbytesleft, struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push}; -int charset_weird_init(void) +NTSTATUS charset_weird_init(void) { return smb_register_charset(&weird_functions); } diff --git a/source3/passdb/pdb_guest.c b/source3/passdb/pdb_guest.c index f5a15057e09..999779b0c6c 100644 --- a/source3/passdb/pdb_guest.c +++ b/source3/passdb/pdb_guest.c @@ -122,8 +122,8 @@ NTSTATUS pdb_init_guestsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, c return NT_STATUS_OK; } -int pdb_guest_init(void) +NTSTATUS pdb_guest_init(void) { - return smb_register_passdb("guest", pdb_init_guestsam, PASSDB_INTERFACE_VERSION); + return smb_register_passdb(PASSDB_INTERFACE_VERSION, "guest", pdb_init_guestsam); } diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 57424bb2d8f..a8cc1f742af 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -36,18 +36,28 @@ static void lazy_initialize_passdb(void) static struct pdb_init_function_entry *pdb_find_backend_entry(const char *name); -BOOL smb_register_passdb(const char *name, pdb_init_function init, int version) +NTSTATUS smb_register_passdb(uint16 version, const char *name, pdb_init_function init) { struct pdb_init_function_entry *entry = backends; - if(version != PASSDB_INTERFACE_VERSION) - return False; + if(version != PASSDB_INTERFACE_VERSION) { + DEBUG(0,("Can't register passdb backend!\n" + "You tried to register a passdb module with PASSDB_INTERFACE_VERSION %d, " + "while this version of samba uses version %d\n", + version,PASSDB_INTERFACE_VERSION)); + return NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + if (!name || !init) { + return NT_STATUS_INVALID_PARAMETER; + } DEBUG(5,("Attempting to register passdb backend %s\n", name)); + /* Check for duplicates */ if (pdb_find_backend_entry(name)) { DEBUG(0,("There already is a passdb backend registered with the name %s!\n", name)); - return False; + return NT_STATUS_OBJECT_NAME_COLLISION; } entry = smb_xmalloc(sizeof(struct pdb_init_function_entry)); @@ -56,7 +66,7 @@ BOOL smb_register_passdb(const char *name, pdb_init_function init, int version) DLIST_ADD(backends, entry); DEBUG(5,("Successfully added passdb backend '%s'\n", name)); - return True; + return NT_STATUS_OK; } static struct pdb_init_function_entry *pdb_find_backend_entry(const char *name) @@ -426,7 +436,7 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c /* Try to find a module that contains this module */ if (!entry) { DEBUG(2,("No builtin backend found, trying to load plugin\n")); - if(smb_probe_module("pdb", module_name) && !(entry = pdb_find_backend_entry(module_name))) { + if(NT_STATUS_IS_OK(smb_probe_module("pdb", module_name)) && !(entry = pdb_find_backend_entry(module_name))) { DEBUG(0,("Plugin is available, but doesn't register passdb backend %s\n", module_name)); SAFE_FREE(module_name); return NT_STATUS_UNSUCCESSFUL; @@ -439,7 +449,7 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c 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)) { diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index a936fb298c9..bdbd5b265c7 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -3239,8 +3239,8 @@ static NTSTATUS pdb_init_ldapsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb int pdb_ldap_init(void) { - smb_register_passdb("ldapsam", pdb_init_ldapsam, PASSDB_INTERFACE_VERSION); - smb_register_passdb("ldapsam_compat", pdb_init_ldapsam_compat, PASSDB_INTERFACE_VERSION); - smb_register_passdb("ldapsam_nua", pdb_init_ldapsam_nua, PASSDB_INTERFACE_VERSION); + smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam", pdb_init_ldapsam); + smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam_compat", pdb_init_ldapsam_compat); + smb_register_passdb(PASSDB_INTERFACE_VERSION, "ldapsam_nua", pdb_init_ldapsam_nua); return True; } diff --git a/source3/passdb/pdb_mysql.c b/source3/passdb/pdb_mysql.c index ca1c239d73d..d3eb7cb975e 100644 --- a/source3/passdb/pdb_mysql.c +++ b/source3/passdb/pdb_mysql.c @@ -946,7 +946,7 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho return NT_STATUS_OK; } -int pdb_mysql_init(void) +NTSTATUS pdb_mysql_init(void) { - return smb_register_passdb("mysql", mysqlsam_init, PASSDB_INTERFACE_VERSION); + return smb_register_passdb(PASSDB_INTERFACE_VERSION, "mysql", mysqlsam_init); } diff --git a/source3/passdb/pdb_nisplus.c b/source3/passdb/pdb_nisplus.c index 73d65af1c6f..cd9288fed03 100644 --- a/source3/passdb/pdb_nisplus.c +++ b/source3/passdb/pdb_nisplus.c @@ -1553,7 +1553,7 @@ NTSTATUS pdb_init_nisplussam (PDB_CONTEXT * pdb_context, return NT_STATUS_OK; } -int pdb_nisplus_init(void) +NTSTATUS pdb_nisplus_init(void) { - return smb_register_passdb("nisplussam", pdb_init_nisplussam, PASSDB_INTERFACE_VERSION); + return smb_register_passdb(PASSDB_INTERFACE_VERSION, "nisplussam", pdb_init_nisplussam); } diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index 177621db1cd..cd66cf269c8 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -1580,9 +1580,9 @@ NTSTATUS pdb_init_smbpasswd_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_meth return NT_STATUS_OK; } -int pdb_smbpasswd_init(void) +NTSTATUS pdb_smbpasswd_init(void) { - smb_register_passdb("smbpasswd", pdb_init_smbpasswd, PASSDB_INTERFACE_VERSION); - smb_register_passdb("smbpasswd_nua", pdb_init_smbpasswd_nua, PASSDB_INTERFACE_VERSION); - return True; + smb_register_passdb(PASSDB_INTERFACE_VERSION, "smbpasswd", pdb_init_smbpasswd); + smb_register_passdb(PASSDB_INTERFACE_VERSION, "smbpasswd_nua", pdb_init_smbpasswd_nua); + return NT_STATUS_OK; } diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index 300b4e8f7db..c3538042ee1 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -990,10 +990,10 @@ NTSTATUS pdb_init_tdbsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, return NT_STATUS_OK; } -int pdb_tdbsam_init(void) +NTSTATUS pdb_tdbsam_init(void) { - smb_register_passdb("tdbsam", pdb_init_tdbsam, PASSDB_INTERFACE_VERSION); - smb_register_passdb("tdbsam_nua", pdb_init_tdbsam_nua, PASSDB_INTERFACE_VERSION); - return True; + smb_register_passdb(PASSDB_INTERFACE_VERSION, "tdbsam", pdb_init_tdbsam); + smb_register_passdb(PASSDB_INTERFACE_VERSION, "tdbsam_nua", pdb_init_tdbsam_nua); + return NT_STATUS_OK; } diff --git a/source3/passdb/pdb_xml.c b/source3/passdb/pdb_xml.c index 24e871a24c2..de2ee4594c4 100644 --- a/source3/passdb/pdb_xml.c +++ b/source3/passdb/pdb_xml.c @@ -553,7 +553,7 @@ static NTSTATUS xmlsam_init(PDB_CONTEXT * pdb_context, PDB_METHODS ** pdb_method return NT_STATUS_OK; } -int pdb_xml_init(void) +NTSTATUS pdb_xml_init(void) { - return smb_register_passdb("xml", xmlsam_init, PASSDB_INTERFACE_VERSION); + return smb_register_passdb(PASSDB_INTERFACE_VERSION, "xml", xmlsam_init); } diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 0807efd550c..75a24174ea3 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -158,7 +158,7 @@ static BOOL api_dfs_enum(pipes_struct *p) \pipe\netdfs commands ********************************************************************/ -int rpc_dfs_init(void) +NTSTATUS rpc_dfs_init(void) { struct api_struct api_netdfs_cmds[] = { @@ -168,6 +168,6 @@ int rpc_dfs_init(void) {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, {"DFS_ENUM", DFS_ENUM, api_dfs_enum } }; - return rpc_pipe_register_commands("netdfs", "netdfs", api_netdfs_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "netdfs", "netdfs", api_netdfs_cmds, sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_echo.c b/source3/rpc_server/srv_echo.c index dcd8dd0c53b..166b6e939d2 100644 --- a/source3/rpc_server/srv_echo.c +++ b/source3/rpc_server/srv_echo.c @@ -120,7 +120,7 @@ static BOOL api_sink_data(pipes_struct *p) \pipe\rpcecho commands ********************************************************************/ -int rpc_echo_init(void) +NTSTATUS rpc_echo_init(void) { struct api_struct api_echo_cmds[] = { {"ADD_ONE", ECHO_ADD_ONE, api_add_one }, @@ -129,7 +129,7 @@ int rpc_echo_init(void) {"SINK_DATA", ECHO_SINK_DATA, api_sink_data }, }; - return rpc_pipe_register_commands( + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "rpcecho", "rpcecho", api_echo_cmds, sizeof(api_echo_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 8648213fdaa..384e8e90949 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -645,7 +645,7 @@ static BOOL api_lsa_query_info2(pipes_struct *p) /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ -int rpc_lsa_init(void) +NTSTATUS rpc_lsa_init(void) { static const struct api_struct api_lsa_cmds[] = { @@ -671,6 +671,6 @@ static const struct api_struct api_lsa_cmds[] = { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } }; - return rpc_pipe_register_commands("lsarpc", "lsass", api_lsa_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds, sizeof(api_lsa_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7dc0f57f34f..0cd40731774 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -321,7 +321,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) array of \PIPE\NETLOGON operations ********************************************************************/ -int rpc_net_init(void) +NTSTATUS rpc_net_init(void) { static struct api_struct api_net_cmds [] = { @@ -336,6 +336,6 @@ int rpc_net_init(void) { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl } }; - return rpc_pipe_register_commands("NETLOGON", "lsass", api_net_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "NETLOGON", "lsass", api_net_cmds, sizeof(api_net_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b09058629af..5b9d39ddc79 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -781,10 +781,28 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, /******************************************************************* Register commands to an RPC pipe *******************************************************************/ -int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct api_struct *cmds, int size) +NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *srv, const struct api_struct *cmds, int size) { struct rpc_table *rpc_entry; + if (!clnt || !srv || !cmds) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (version != SMB_RPC_INTERFACE_VERSION) { + DEBUG(0,("Can't register rpc commands!\n" + "You tried to register a rpc module with SMB_RPC_INTERFACE_VERSION %d" + ", while this version of samba uses version %d!\n", + version,SMB_RPC_INTERFACE_VERSION)); + return NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + /* TODO: + * + * we still need to make sure that don't register the same commands twice!!! + * + * --metze + */ /* We use a temporary variable because this call can fail and rpc_lookup will still be valid afterwards. It could then succeed if @@ -794,7 +812,7 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a if (NULL == rpc_entry) { rpc_lookup_size--; DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n")); - return 0; + return NT_STATUS_NO_MEMORY; } else { rpc_lookup = rpc_entry; } @@ -810,7 +828,7 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a size * sizeof(struct api_struct)); rpc_entry->n_cmds += size; - return size; + return NT_STATUS_OK; } /******************************************************************* @@ -852,7 +870,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } if (i == rpc_lookup_size) { - if (!smb_probe_module("rpc", p->name)) { + if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", p->name )); if(!setup_bind_nak(p)) diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index f72d8e4f295..43bb1ad86a1 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -373,7 +373,7 @@ static BOOL api_reg_save_key(pipes_struct *p) array of \PIPE\reg operations ********************************************************************/ -int rpc_reg_init(void) +NTSTATUS rpc_reg_init(void) { static struct api_struct api_reg_cmds[] = { @@ -391,6 +391,6 @@ int rpc_reg_init(void) { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key } }; - return rpc_pipe_register_commands("winreg", "winreg", api_reg_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", api_reg_cmds, sizeof(api_reg_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 67c092775b9..9250b023d3b 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1443,7 +1443,7 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) array of \PIPE\samr operations ********************************************************************/ -int rpc_samr_init(void) +NTSTATUS rpc_samr_init(void) { static struct api_struct api_samr_cmds [] = { @@ -1501,6 +1501,6 @@ int rpc_samr_init(void) {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 } }; - return rpc_pipe_register_commands("samr", "lsass", api_samr_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "samr", "lsass", api_samr_cmds, sizeof(api_samr_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index a7dd7a6cef5..3e9ed9e39f9 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1580,7 +1580,7 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) \pipe\spoolss commands ********************************************************************/ -int rpc_spoolss_init(void) +NTSTATUS rpc_spoolss_init(void) { struct api_struct api_spoolss_cmds[] = { @@ -1640,6 +1640,6 @@ int rpc_spoolss_init(void) {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter } #endif }; - return rpc_pipe_register_commands("spoolss", "spoolss", api_spoolss_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss", api_spoolss_cmds, sizeof(api_spoolss_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 96820ae74bc..deba1224210 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -526,7 +526,7 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -int rpc_srv_init(void) +NTSTATUS rpc_srv_init(void) { static const struct api_struct api_srv_cmds[] = { @@ -548,6 +548,6 @@ int rpc_srv_init(void) { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc } }; - return rpc_pipe_register_commands("srvsvc", "ntsvcs", api_srv_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds, sizeof(api_srv_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index ddcbadd1d44..8efa29fd0bc 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -60,12 +60,12 @@ static BOOL api_wks_query_info(pipes_struct *p) \PIPE\wkssvc commands ********************************************************************/ -int rpc_wks_init(void) +NTSTATUS rpc_wks_init(void) { static struct api_struct api_wks_cmds[] = { { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } }; - return rpc_pipe_register_commands("wkssvc", "ntsvcs", api_wks_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "wkssvc", "ntsvcs", api_wks_cmds, sizeof(api_wks_cmds) / sizeof(struct api_struct)); } diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 75bcb099173..e33a8ccbe73 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -153,29 +153,30 @@ static struct vfs_init_function_entry *vfs_find_backend_entry(const char *name) return NULL; } -BOOL smb_register_vfs(const char *name, vfs_op_tuple *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *), int version) +NTSTATUS smb_register_vfs(uint16 version, const char *name, vfs_op_tuple *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *)) { struct vfs_init_function_entry *entry = backends; - + if ((version < SMB_VFS_INTERFACE_CASCADED)) { DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", version, SMB_VFS_INTERFACE_VERSION )); - return False; + return NT_STATUS_OBJECT_TYPE_MISMATCH; } if ((version < SMB_VFS_INTERFACE_VERSION)) { DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", version, SMB_VFS_INTERFACE_VERSION, version )); - return False; + return NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + if (!name || !init) { + return NT_STATUS_INVALID_PARAMETER; } - while(entry) { - if (strequal(entry->name, name)) { + if (vfs_find_backend_entry(name)) { DEBUG(0,("VFS module %s already loaded!\n", name)); - return False; - } - entry = entry->next; + return NT_STATUS_OBJECT_NAME_COLLISION; } entry = smb_xmalloc(sizeof(struct vfs_init_function_entry)); @@ -184,7 +185,7 @@ BOOL smb_register_vfs(const char *name, vfs_op_tuple *(*init)(const struct vfs_o DLIST_ADD(backends, entry); DEBUG(5, ("Successfully added vfs backend '%s'\n", name)); - return True; + return NT_STATUS_OK; } /**************************************************************************** @@ -267,7 +268,7 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object) /* First, try to load the module with the new module system */ if((entry = vfs_find_backend_entry(vfs_object)) || - (smb_probe_module("vfs", vfs_object) && + (NT_STATUS_IS_OK(smb_probe_module("vfs", vfs_object)) && (entry = vfs_find_backend_entry(vfs_object)))) { DEBUG(3,("Successfully loaded %s with the new modules system\n", vfs_object)); |