summaryrefslogtreecommitdiff
path: root/source3/passdb
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/passdb
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/passdb')
-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
7 files changed, 28 insertions, 19 deletions
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);
}