summaryrefslogtreecommitdiffstats
path: root/source4/passdb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-02-03 11:10:56 +0000
committerStefan Metzmacher <metze@samba.org>2004-02-03 11:10:56 +0000
commit1c798aba40fb0e389c7a54ad3d8f7d45876f2809 (patch)
tree3ee4790e25089106db52b1f16d20583f7bf90b9e /source4/passdb
parenta9b28120b84fd63e333d5be26fe8116c85f12c87 (diff)
downloadsamba-1c798aba40fb0e389c7a54ad3d8f7d45876f2809.tar.gz
samba-1c798aba40fb0e389c7a54ad3d8f7d45876f2809.tar.xz
samba-1c798aba40fb0e389c7a54ad3d8f7d45876f2809.zip
- port AUTH and PASSDB subsystems to new
SMB_SUBSYSTEM() scheme - some const fixes in ntvfs metze (This used to be commit af89a78123068767b1d134969c5651a0fd978b0d)
Diffstat (limited to 'source4/passdb')
-rw-r--r--source4/passdb/config.m415
-rw-r--r--source4/passdb/passdb.h119
-rw-r--r--source4/passdb/pdb_guest.c38
-rw-r--r--source4/passdb/pdb_interface.c153
-rw-r--r--source4/passdb/pdb_ldap.c47
-rw-r--r--source4/passdb/pdb_smbpasswd.c38
-rw-r--r--source4/passdb/pdb_tdb.c46
-rw-r--r--source4/passdb/pdb_unix.c23
8 files changed, 375 insertions, 104 deletions
diff --git a/source4/passdb/config.m4 b/source4/passdb/config.m4
index e69de29bb2d..328726481a8 100644
--- a/source4/passdb/config.m4
+++ b/source4/passdb/config.m4
@@ -0,0 +1,15 @@
+dnl # PASSDB Server subsystem
+
+SMB_MODULE(pdb_smbpasswd,PASSDB,STATIC,[passdb/pdb_smbpasswd.o])
+SMB_MODULE(pdb_tdb,PASSDB,NOT,[passdb/pdb_tdb.o])
+SMB_MODULE(pdb_guest,PASSDB,STATIC,[passdb/pdb_guest.o])
+SMB_MODULE(pdb_unix,PASSDB,STATIC,[passdb/pdb_unix.o])
+
+if test x"$with_ldap_support" = x"yes"; then
+ SMB_MODULE_DEFAULT(STATIC,pdb_ldap)
+fi
+SMB_MODULE(pdb_ldap,PASSDB,NOT,[passdb/pdb_ldap.o],[],[$LDAP_LIBS])
+
+SMB_SUBSYSTEM(PASSDB,passdb/pdb_interface.o,
+ [passdb/passdb.o passdb/machine_sid.o passdb/util_sam_sid.o passdb/pdb_get_set.o passdb/pdb_compat.o],
+ passdb/passdb_public_proto.h)
diff --git a/source4/passdb/passdb.h b/source4/passdb/passdb.h
new file mode 100644
index 00000000000..7b7f2210653
--- /dev/null
+++ b/source4/passdb/passdb.h
@@ -0,0 +1,119 @@
+/*
+ Unix SMB/CIFS implementation.
+ passdb structures and parameters
+ Copyright (C) Gerald Carter 2001
+ Copyright (C) Luke Kenneth Casson Leighton 1998 - 2000
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _SAMBA_PASSDB_H
+#define _SAMBA_PASSDB_H
+
+/*
+ * This next constant specifies the version number of the PASSDB interface
+ * this SAMBA will load. Increment this with a comment if *ANY* changes are made
+ * to the interface and maybe update struct auth_critical_sizes
+ */
+/* version 2 - init versioning of the interface - metze */
+/* version 3 - value states of SAM_ACCOUNT entries - metze */
+/* version 4 - add group mapping api - vlendec */
+#define PASSDB_INTERFACE_VERSION 4
+
+typedef struct pdb_context
+{
+ struct pdb_methods *pdb_methods;
+ struct pdb_methods *pwent_methods;
+
+ /* These functions are wrappers for the functions listed above.
+ They may do extra things like re-reading a SAM_ACCOUNT on update */
+
+ NTSTATUS (*pdb_setsampwent)(struct pdb_context *, BOOL update);
+
+ void (*pdb_endsampwent)(struct pdb_context *);
+
+ NTSTATUS (*pdb_getsampwent)(struct pdb_context *, SAM_ACCOUNT *user);
+
+ NTSTATUS (*pdb_getsampwnam)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const char *username);
+
+ NTSTATUS (*pdb_getsampwsid)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const DOM_SID *sid);
+
+ NTSTATUS (*pdb_add_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
+
+ NTSTATUS (*pdb_update_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
+
+ NTSTATUS (*pdb_delete_sam_account)(struct pdb_context *, SAM_ACCOUNT *username);
+
+ NTSTATUS (*pdb_delete_group_mapping_entry)(struct pdb_context *context,
+ DOM_SID sid);
+
+ void (*free_fn)(struct pdb_context **);
+
+ TALLOC_CTX *mem_ctx;
+
+} PDB_CONTEXT;
+
+typedef struct pdb_methods
+{
+ const char *name; /* What name got this module */
+ struct pdb_context *parent;
+
+ /* Use macros from dlinklist.h on these two */
+ struct pdb_methods *next;
+ struct pdb_methods *prev;
+
+ NTSTATUS (*setsampwent)(struct pdb_methods *, BOOL update);
+
+ void (*endsampwent)(struct pdb_methods *);
+
+ NTSTATUS (*getsampwent)(struct pdb_methods *, SAM_ACCOUNT *user);
+
+ NTSTATUS (*getsampwnam)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, const char *username);
+
+ NTSTATUS (*getsampwsid)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, const DOM_SID *Sid);
+
+ NTSTATUS (*add_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
+
+ NTSTATUS (*update_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
+
+ NTSTATUS (*delete_sam_account)(struct pdb_methods *, SAM_ACCOUNT *username);
+
+ NTSTATUS (*delete_group_mapping_entry)(struct pdb_methods *methods,
+ DOM_SID sid);
+
+ void *private_data; /* Private data of some kind */
+
+ void (*free_private_data)(void **);
+
+} PDB_METHODS;
+
+struct passdb_ops {
+ /* the name of the backend */
+ const char *name;
+
+ /* Function to create a member of the pdb_methods list */
+ NTSTATUS (*init)(struct pdb_context *, struct pdb_methods **, const char *);
+};
+
+/* this structure is used by modules to determine the size of some critical types */
+struct passdb_critical_sizes {
+ int interface_version;
+ int sizeof_passdb_ops;
+ int sizeof_pdb_methods;
+ int sizeof_pdb_context;
+ int sizeof_SAM_ACCOUNT;
+};
+
+#endif /* _SAMBA_PASSDB_H */
diff --git a/source4/passdb/pdb_guest.c b/source4/passdb/pdb_guest.c
index 3f0f06d18d0..11da9755014 100644
--- a/source4/passdb/pdb_guest.c
+++ b/source4/passdb/pdb_guest.c
@@ -100,7 +100,7 @@ static NTSTATUS guestsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT
return guestsam_getsampwrid(my_methods, user, rid);
}
-NTSTATUS pdb_init_guestsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_guestsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
@@ -121,3 +121,39 @@ NTSTATUS pdb_init_guestsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, c
/* There's not very much to initialise here */
return NT_STATUS_OK;
}
+
+NTSTATUS pdb_guest_init(void)
+{
+ NTSTATUS ret;
+ struct passdb_ops ops;
+
+ ZERO_STRUCT(ops);
+
+ /* fill in our name */
+ ops.name = "guestsam";
+ /* fill in all the operations */
+ ops.init = pdb_init_guestsam;
+
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
+
+ /* fill in our name */
+ ops.name = "guest";
+ /* fill in all the operations */
+ ops.init = pdb_init_guestsam;
+
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
+
+ return ret;
+}
diff --git a/source4/passdb/pdb_interface.c b/source4/passdb/pdb_interface.c
index 5b2c0812752..ecdd7b64868 100644
--- a/source4/passdb/pdb_interface.c
+++ b/source4/passdb/pdb_interface.c
@@ -24,78 +24,99 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
-/** List of various built-in passdb modules */
-static const struct {
- const char *name;
- /* Function to create a member of the pdb_methods list */
- pdb_init_function init;
-} builtin_pdb_init_functions[] = {
- { "smbpasswd", pdb_init_smbpasswd },
- { "smbpasswd_nua", pdb_init_smbpasswd_nua },
- { "tdbsam", pdb_init_tdbsam },
- { "tdbsam_nua", pdb_init_tdbsam_nua },
- { "ldapsam", pdb_init_ldapsam },
- { "ldapsam_nua", pdb_init_ldapsam_nua },
- { "unixsam", pdb_init_unixsam },
- { "guest", pdb_init_guestsam },
- { "nisplussam", pdb_init_nisplussam },
- { NULL, NULL}
-};
-
-static struct pdb_init_function_entry *backends;
-static void lazy_initialize_passdb(void);
-
-static void lazy_initialize_passdb()
+/* the list of currently registered AUTH backends */
+static struct {
+ const struct passdb_ops *ops;
+} *backends = NULL;
+static int num_backends;
+
+/*
+ register a AUTH backend.
+
+ The 'name' can be later used by other backends to find the operations
+ structure for this backend.
+*/
+static NTSTATUS passdb_register(void *_ops)
{
- int i;
- static BOOL initialised = False;
+ const struct passdb_ops *ops = _ops;
+ struct passdb_ops *new_ops;
- if(!initialised) {
- initialised = True;
+ if (passdb_backend_byname(ops->name) != NULL) {
+ /* its already registered! */
+ DEBUG(0,("PASSDB backend '%s' already registered\n",
+ ops->name));
+ return NT_STATUS_OBJECT_NAME_COLLISION;
+ }
- for(i = 0; builtin_pdb_init_functions[i].name; i++) {
- smb_register_passdb(builtin_pdb_init_functions[i].name, builtin_pdb_init_functions[i].init, PASSDB_INTERFACE_VERSION);
- }
+ backends = Realloc(backends, sizeof(backends[0]) * (num_backends+1));
+ if (!backends) {
+ smb_panic("out of memory in passdb_register");
}
-}
-BOOL smb_register_passdb(const char *name, pdb_init_function init, int version)
-{
- struct pdb_init_function_entry *entry = backends;
+ new_ops = smb_xmemdup(ops, sizeof(*ops));
+ new_ops->name = smb_xstrdup(ops->name);
- if(version != PASSDB_INTERFACE_VERSION)
- return False;
+ backends[num_backends].ops = new_ops;
+
+ num_backends++;
- DEBUG(5,("Attempting to register passdb backend %s\n", name));
+ DEBUG(3,("PASSDB backend '%s' registered\n",
+ ops->name));
+
+ return NT_STATUS_OK;
+}
- /* Check for duplicates */
- while(entry) {
- if(strcasecmp(name, entry->name) == 0) {
- DEBUG(0,("There already is a passdb backend registered with the name %s!\n", name));
- return False;
+/*
+ return the operations structure for a named backend of the specified type
+*/
+const struct passdb_ops *passdb_backend_byname(const char *name)
+{
+ int i;
+
+ for (i=0;i<num_backends;i++) {
+ if (strcmp(backends[i].ops->name, name) == 0) {
+ return backends[i].ops;
}
- entry = entry->next;
}
- entry = smb_xmalloc(sizeof(struct pdb_init_function_entry));
- entry->name = name;
- entry->init = init;
+ return NULL;
+}
- DLIST_ADD(backends, entry);
- DEBUG(5,("Successfully added passdb backend '%s'\n", name));
- return True;
+/*
+ return the PASSDB interface version, and the size of some critical types
+ This can be used by backends to either detect compilation errors, or provide
+ multiple implementations for different smbd compilation options in one module
+*/
+const struct passdb_critical_sizes *passdb_interface_version(void)
+{
+ static const struct passdb_critical_sizes critical_sizes = {
+ PASSDB_INTERFACE_VERSION,
+ sizeof(struct passdb_ops),
+ sizeof(struct pdb_methods),
+ sizeof(struct pdb_context),
+ sizeof(SAM_ACCOUNT)
+ };
+
+ return &critical_sizes;
}
-struct pdb_init_function_entry *pdb_find_backend_entry(const char *name)
+/*
+ initialise the PASSDB subsystem
+*/
+BOOL passdb_init(void)
{
- struct pdb_init_function_entry *entry = backends;
+ NTSTATUS status;
- while(entry) {
- if (strequal(entry->name, name)) return entry;
- entry = entry->next;
+ status = register_subsystem("passdb", passdb_register);
+ if (!NT_STATUS_IS_OK(status)) {
+ return False;
}
- return NULL;
+ /* FIXME: Perhaps panic if a basic backend, such as SAM, fails to initialise? */
+ static_init_passdb;
+
+ DEBUG(3,("PASSDB subsystem version %d initialised\n", PASSDB_INTERFACE_VERSION));
+ return True;
}
static NTSTATUS context_setsampwent(struct pdb_context *context, BOOL update)
@@ -300,18 +321,16 @@ static void free_pdb_context(struct pdb_context **context)
static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_context *context, const char *selected)
{
char *module_name = smb_xstrdup(selected);
- char *module_location = NULL, *p;
- struct pdb_init_function_entry *entry;
+ char *module_param = NULL, *p;
+ const struct passdb_ops *ops;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- lazy_initialize_passdb();
-
p = strchr(module_name, ':');
if (p) {
*p = 0;
- module_location = p+1;
- trim_string(module_location, " ", " ");
+ module_param = p+1;
+ trim_string(module_param, " ", " ");
}
trim_string(module_name, " ", " ");
@@ -319,20 +338,18 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c
DEBUG(5,("Attempting to find an passdb backend to match %s (%s)\n", selected, module_name));
- entry = pdb_find_backend_entry(module_name);
-
+ ops = passdb_backend_byname(module_name);
/* No such backend found */
- if(!entry) {
+ if(!ops) {
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);
+ DEBUG(5,("Found PASSDB backend %s\n", module_name));
+ nt_status = ops->init(context, methods, module_param);
if (NT_STATUS_IS_OK(nt_status)) {
- DEBUG(5,("pdb backend %s has a valid init\n", selected));
+ DEBUG(5,("PASSDB backend %s has a valid init\n", selected));
} else {
- DEBUG(0,("pdb backend %s did not correctly init (error was %s)\n", selected, nt_errstr(nt_status)));
+ DEBUG(0,("PASSDB backend %s did not correctly init (error was %s)\n", selected, nt_errstr(nt_status)));
}
SAFE_FREE(module_name);
return nt_status;
diff --git a/source4/passdb/pdb_ldap.c b/source4/passdb/pdb_ldap.c
index 6bab5b9bca2..5f7db7f5de5 100644
--- a/source4/passdb/pdb_ldap.c
+++ b/source4/passdb/pdb_ldap.c
@@ -28,7 +28,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
-#ifdef HAVE_LDAP
/* TODO:
* persistent connections: if using NSS LDAP, many connections are made
* however, using only one within Samba would be nice
@@ -1979,7 +1978,7 @@ static void free_private_data(void **vp)
/* No need to free any further, as it is talloc()ed */
}
-NTSTATUS pdb_init_ldapsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_ldapsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
struct ldapsam_privates *ldap_state;
@@ -2036,7 +2035,7 @@ NTSTATUS pdb_init_ldapsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, co
return NT_STATUS_OK;
}
-NTSTATUS pdb_init_ldapsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_ldapsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
struct ldapsam_privates *ldap_state;
@@ -2064,20 +2063,36 @@ NTSTATUS pdb_init_ldapsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method
return NT_STATUS_OK;
}
-
-#else
-
-NTSTATUS pdb_init_ldapsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+NTSTATUS pdb_ldap_init(void)
{
- DEBUG(0, ("ldap not detected at configure time, ldapsam not availalble!\n"));
- return NT_STATUS_UNSUCCESSFUL;
-}
+ NTSTATUS ret;
+ struct passdb_ops ops;
+
+ /* fill in our name */
+ ops.name = "ldapsam";
+ /* fill in all the operations */
+ ops.init = pdb_init_ldapsam;
+
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
-NTSTATUS pdb_init_ldapsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
-{
- DEBUG(0, ("ldap not dectected at configure time, ldapsam_nua not available!\n"));
- return NT_STATUS_UNSUCCESSFUL;
-}
+ /* fill in our name */
+ ops.name = "ldapsam_nua";
+ /* fill in all the operations */
+ ops.init = pdb_init_ldapsam_nua;
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
-#endif
+ return ret;
+}
diff --git a/source4/passdb/pdb_smbpasswd.c b/source4/passdb/pdb_smbpasswd.c
index 6f8c8a6fcc4..0811c23484d 100644
--- a/source4/passdb/pdb_smbpasswd.c
+++ b/source4/passdb/pdb_smbpasswd.c
@@ -1508,7 +1508,7 @@ static void free_private_data(void **vp)
}
-NTSTATUS pdb_init_smbpasswd(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_smbpasswd(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
struct smbpasswd_privates *privates;
@@ -1557,7 +1557,7 @@ NTSTATUS pdb_init_smbpasswd(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method,
return NT_STATUS_OK;
}
-NTSTATUS pdb_init_smbpasswd_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_smbpasswd_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
struct smbpasswd_privates *privates;
@@ -1579,3 +1579,37 @@ NTSTATUS pdb_init_smbpasswd_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_meth
return NT_STATUS_OK;
}
+
+NTSTATUS pdb_smbpasswd_init(void)
+{
+ NTSTATUS ret;
+ struct passdb_ops ops;
+
+ /* fill in our name */
+ ops.name = "smbpasswd";
+ /* fill in all the operations */
+ ops.init = pdb_init_smbpasswd;
+
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
+
+ /* fill in our name */
+ ops.name = "smbpasswd_nua";
+ /* fill in all the operations */
+ ops.init = pdb_init_smbpasswd_nua;
+
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
+
+ return ret;
+}
diff --git a/source4/passdb/pdb_tdb.c b/source4/passdb/pdb_tdb.c
index c48c9567b16..a3fda1f47e6 100644
--- a/source4/passdb/pdb_tdb.c
+++ b/source4/passdb/pdb_tdb.c
@@ -37,8 +37,6 @@ static int tdbsam_debug_level = DBGC_ALL;
#endif
-#ifdef WITH_TDB_SAM
-
#define PDB_VERSION "20010830"
#define PASSDB_FILE_NAME "passdb.tdb"
#define TDB_FORMAT_STRING "ddddddBBBBBBBBBBBBddBBwdwdBdd"
@@ -906,7 +904,7 @@ static void free_private_data(void **vp)
}
-NTSTATUS pdb_init_tdbsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_tdbsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
struct tdbsam_privates *tdb_state;
@@ -960,7 +958,7 @@ NTSTATUS pdb_init_tdbsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, con
return NT_STATUS_OK;
}
-NTSTATUS pdb_init_tdbsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_tdbsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
struct tdbsam_privates *tdb_state;
@@ -988,20 +986,36 @@ NTSTATUS pdb_init_tdbsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method,
return NT_STATUS_OK;
}
+NTSTATUS pdb_tdb_init(void)
+{
+ NTSTATUS ret;
+ struct passdb_ops ops;
-#else
+ /* fill in our name */
+ ops.name = "tdbsam";
+ /* fill in all the operations */
+ ops.init = pdb_init_tdbsam;
-NTSTATUS pdb_init_tdbsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
-{
- DEBUG(0, ("tdbsam not compiled in!\n"));
- return NT_STATUS_UNSUCCESSFUL;
-}
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
-NTSTATUS pdb_init_tdbsam_nua(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
-{
- DEBUG(0, ("tdbsam_nua not compiled in!\n"));
- return NT_STATUS_UNSUCCESSFUL;
-}
+ /* fill in our name */
+ ops.name = "tdbsam_nua";
+ /* fill in all the operations */
+ ops.init = pdb_init_tdbsam_nua;
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
-#endif
+ return ret;
+}
diff --git a/source4/passdb/pdb_unix.c b/source4/passdb/pdb_unix.c
index b42843d8020..a1552981f1b 100644
--- a/source4/passdb/pdb_unix.c
+++ b/source4/passdb/pdb_unix.c
@@ -88,7 +88,7 @@ static NTSTATUS unixsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT
return unixsam_getsampwrid(my_methods, user, rid);
}
-NTSTATUS pdb_init_unixsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
+static NTSTATUS pdb_init_unixsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
{
NTSTATUS nt_status;
@@ -108,3 +108,24 @@ NTSTATUS pdb_init_unixsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, co
/* There's not very much to initialise here */
return NT_STATUS_OK;
}
+
+NTSTATUS pdb_unix_init(void)
+{
+ NTSTATUS ret;
+ struct passdb_ops ops;
+
+ /* fill in our name */
+ ops.name = "unixsam";
+ /* fill in all the operations */
+ ops.init = pdb_init_unixsam;
+
+ /* register ourselves with the PASSDB subsystem. */
+ ret = register_backend("passdb", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register '%s' PASSDB backend!\n",
+ ops.name));
+ return ret;
+ }
+
+ return ret;
+}