summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/pdb/README36
-rw-r--r--examples/pdb/pdb_test.c13
-rw-r--r--source3/include/passdb.h14
-rw-r--r--source3/passdb/pdb_ldap.c2
-rw-r--r--source3/passdb/pdb_plugin.c18
5 files changed, 77 insertions, 6 deletions
diff --git a/examples/pdb/README b/examples/pdb/README
index 9ca03bf593..a212604792 100644
--- a/examples/pdb/README
+++ b/examples/pdb/README
@@ -1,5 +1,41 @@
README for Samba Password Database (PDB) examples
====================================================
+21-6-2002 Stefan (metze) Metzmacher <metze@metzemix.de>
+
+I have added an interface versioning.
+
+Every module MUST have a pdb_version() function.
+
+this is defined in include/passdb.h:
+#define PDB_MODULE_VERSIONING_MAGIC \
+int pdb_version(void)\
+{\
+ return PASSDB_INTERFACE_VERSION;\
+}
+
+You MUST add this line inside a module:
+PDB_MODULE_VERSIONING_MAGIC
+
+21-6-2002 Stefan (metze) Metzmacher <metze@metzemix.de>
+
+The pdb_interface was changed:
+
+this function are deleted:
+static BOOL testsam_getsampwrid (struct pdb_methods *methods, SAM_ACCOUNT *user, uint32 rid)
+
+this function are added:
+static BOOL testsam_getsampwsid (struct pdb_methods *methods, SAM_ACCOUNT *user, DOM_SID sid)
+
+In the SAM_ACCOUNT struct:
+
+this fields are deleted:
+uint32 user_rid;
+uint32 group_rid;
+
+this fields are added:
+DOM_SID user_sid;
+DOM_SID group_sid;
+
15-2-2002 Jelmer Vernooij <jelmer@nl.linux.org>
The pdb_test.c file in this directory contains a very basic example of
diff --git a/examples/pdb/pdb_test.c b/examples/pdb/pdb_test.c
index c932c6128b..d2722d2e03 100644
--- a/examples/pdb/pdb_test.c
+++ b/examples/pdb/pdb_test.c
@@ -19,10 +19,15 @@
#include "includes.h"
+
static int testsam_debug_level = DBGC_ALL;
+
#undef DBGC_CLASS
#define DBGC_CLASS testsam_debug_level
+/* define the version of the passdb interface */
+PDB_MODULE_VERSIONING_MAGIC
+
/***************************************************************
Start enumeration of the passwd list.
****************************************************************/
@@ -63,12 +68,12 @@ static BOOL testsam_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user,
}
/***************************************************************************
- Search by rid
+ Search by sid
**************************************************************************/
-static BOOL testsam_getsampwrid (struct pdb_methods *methods, SAM_ACCOUNT *user, uint32 rid)
+static BOOL testsam_getsampwsid (struct pdb_methods *methods, SAM_ACCOUNT *user, DOM_SID sid)
{
- DEBUG(10, ("testsam_getsampwrid called\n"));
+ DEBUG(10, ("testsam_getsampwsid called\n"));
return False;
}
@@ -119,7 +124,7 @@ NTSTATUS pdb_init(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char
(*pdb_method)->endsampwent = testsam_endsampwent;
(*pdb_method)->getsampwent = testsam_getsampwent;
(*pdb_method)->getsampwnam = testsam_getsampwnam;
- (*pdb_method)->getsampwrid = testsam_getsampwrid;
+ (*pdb_method)->getsampwsid = testsam_getsampwsid;
(*pdb_method)->add_sam_account = testsam_add_sam_account;
(*pdb_method)->update_sam_account = testsam_update_sam_account;
(*pdb_method)->delete_sam_account = testsam_delete_sam_account;
diff --git a/source3/include/passdb.h b/source3/include/passdb.h
index bd1d1e159b..a79c8a0289 100644
--- a/source3/include/passdb.h
+++ b/source3/include/passdb.h
@@ -27,6 +27,20 @@
Functions to be implemented by the new (v2) passdb API
****************************************************************/
+/*
+ * This next constant specifies the version number of the PASSDB interface
+ * this SAMBA will load. Increment this if *ANY* changes are made to the interface.
+ */
+
+#define PASSDB_INTERFACE_VERSION 2
+
+/* use this inside a passdb module */
+#define PDB_MODULE_VERSIONING_MAGIC \
+int pdb_version(void)\
+{\
+ return PASSDB_INTERFACE_VERSION;\
+}
+
typedef struct pdb_context
{
struct pdb_methods *pdb_methods;
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 0a16071419..a5530efdb6 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -693,7 +693,7 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state,
if (!get_single_attribute(ldap_struct, entry, "homeDrive", dir_drive)) {
pdb_set_dir_drive(sampass, standard_sub_specified(sampass->mem_ctx,
- lp_logon_path(),
+ lp_logon_drive(),
username, domain,
uid, gid),
False);
diff --git a/source3/passdb/pdb_plugin.c b/source3/passdb/pdb_plugin.c
index f7ab2b90e2..1a246631fe 100644
--- a/source3/passdb/pdb_plugin.c
+++ b/source3/passdb/pdb_plugin.c
@@ -29,6 +29,7 @@ NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, con
void * dl_handle;
char *plugin_location, *plugin_name, *p;
pdb_init_function plugin_init;
+ int (*plugin_version)(void);
if (location == NULL) {
DEBUG(0, ("The plugin module needs an argument!\n"));
@@ -51,8 +52,23 @@ NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, con
return NT_STATUS_UNSUCCESSFUL;
}
+ plugin_version = sys_dlsym(dl_handle, "pdb_version");
+ if (!plugin_version) {
+ sys_dlclose(dl_handle);
+ DEBUG(0, ("Failed to find function 'pdb_version' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror()));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ if (plugin_version()!=PASSDB_INTERFACE_VERSION) {
+ sys_dlclose(dl_handle);
+ DEBUG(0, ("Wrong PASSDB_INTERFACE_VERSION! sam plugin has version %d and version %d is needed! Please update!\n",
+ plugin_version(),PASSDB_INTERFACE_VERSION));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
plugin_init = sys_dlsym(dl_handle, "pdb_init");
- if (!plugin_init){
+ if (!plugin_init) {
+ sys_dlclose(dl_handle);
DEBUG(0, ("Failed to find function 'pdb_init' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror()));
return NT_STATUS_UNSUCCESSFUL;
}