summaryrefslogtreecommitdiff
path: root/source3
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
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')
-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
-rw-r--r--source3/include/rpc_misc.h2
-rw-r--r--source3/include/smb.h2
-rw-r--r--source3/lib/iconv.c15
-rw-r--r--source3/lib/module.c22
-rw-r--r--source3/modules/vfs_audit.c4
-rw-r--r--source3/modules/vfs_extd_audit.c4
-rw-r--r--source3/modules/vfs_fake_perms.c4
-rw-r--r--source3/modules/vfs_netatalk.c4
-rw-r--r--source3/modules/vfs_recycle.c6
-rw-r--r--source3/passdb/pdb_guest.c4
-rw-r--r--source3/passdb/pdb_interface.c24
-rw-r--r--source3/passdb/pdb_ldap.c5
-rw-r--r--source3/passdb/pdb_mysql.c4
-rw-r--r--source3/passdb/pdb_nisplus.c4
-rw-r--r--source3/passdb/pdb_unix.c2
-rw-r--r--source3/passdb/pdb_xml.c4
-rw-r--r--source3/rpc_server/srv_dfs.c4
-rw-r--r--source3/rpc_server/srv_echo.c4
-rw-r--r--source3/rpc_server/srv_lsa.c4
-rw-r--r--source3/rpc_server/srv_netlog.c4
-rw-r--r--source3/rpc_server/srv_pipe.c26
-rw-r--r--source3/rpc_server/srv_reg.c4
-rw-r--r--source3/rpc_server/srv_samr.c4
-rwxr-xr-xsource3/rpc_server/srv_spoolss.c4
-rw-r--r--source3/rpc_server/srv_srvsvc.c4
-rw-r--r--source3/rpc_server/srv_wkssvc.c4
-rw-r--r--source3/smbd/vfs.c23
35 files changed, 155 insertions, 119 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);
}
diff --git a/source3/include/rpc_misc.h b/source3/include/rpc_misc.h
index 06ad760c58..a0572a0bfd 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 62cc95ecb0..5ee6b97172 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 a5fcf32b5b..d9160f0d01 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 53223cfebe..087c964d3c 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 fa9bf67a67..4f9dc1b1e4 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 f60acab36a..ef30ca7027 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 121a99a451..3a18fbb730 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 c9e3cde621..718bc2a35c 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 85ce257c02..87dea944ac 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/passdb/pdb_guest.c b/source3/passdb/pdb_guest.c
index f5a15057e0..999779b0c6 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 57424bb2d8..a8cc1f742a 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 0ebbd446ec..ecca633d2f 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -2065,8 +2065,7 @@ NTSTATUS pdb_init_ldapsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, co
return NT_STATUS_OK;
}
-int pdb_ldap_init(void)
+NTSTATUS pdb_ldap_init(void)
{
- smb_register_passdb("ldapsam", pdb_init_ldapsam, PASSDB_INTERFACE_VERSION);
- return True;
+ return smb_register_passdb("ldapsam", pdb_init_ldapsam, PASSDB_INTERFACE_VERSION);
}
diff --git a/source3/passdb/pdb_mysql.c b/source3/passdb/pdb_mysql.c
index ca1c239d73..d3eb7cb975 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 73d65af1c6..cd9288fed0 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_unix.c b/source3/passdb/pdb_unix.c
index ed83024248..69356c45db 100644
--- a/source3/passdb/pdb_unix.c
+++ b/source3/passdb/pdb_unix.c
@@ -125,7 +125,7 @@ NTSTATUS pdb_init_unixsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, co
return NT_STATUS_OK;
}
-int pdb_unix_init(void)
+NTSTATUS pdb_unix_init(void)
{
return smb_register_passdb("unixsam", pdb_init_unixsam, PASSDB_INTERFACE_VERSION);
}
diff --git a/source3/passdb/pdb_xml.c b/source3/passdb/pdb_xml.c
index bde2d14a85..7a5c0e2b53 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 0807efd550..75a24174ea 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 dcd8dd0c53..166b6e939d 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 bfa706acf2..7bd300dc7c 100644
--- a/source3/rpc_server/srv_lsa.c
+++ b/source3/rpc_server/srv_lsa.c
@@ -771,7 +771,7 @@ static BOOL api_lsa_remove_acct_rights(pipes_struct *p)
\PIPE\ntlsa commands
***************************************************************************/
-int rpc_lsa_init(void)
+NTSTATUS rpc_lsa_init(void)
{
static const struct api_struct api_lsa_cmds[] =
{
@@ -801,6 +801,6 @@ int rpc_lsa_init(void)
{ "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights},
};
- 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 7dc0f57f34..0cd4073177 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 b09058629a..5b9d39ddc7 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 f72d8e4f29..43bb1ad86a 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 67c092775b..9250b023d3 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 a7dd7a6cef..3e9ed9e39f 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 96820ae74b..deba122421 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 ddcbadd1d4..8efa29fd0b 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 75bcb09917..e33a8ccbe7 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));