[PATCH] PASSDB_INTERFACE_VERSION (pdb_module maintainers keep
your heads up!)
Stefan (metze) Metzmacher
metze at metzemix.de
Fri Jun 21 00:28:02 GMT 2002
Hi Andrew,
here's the patch, witch adds interface versioning to the pdb_interface.
Hi pdb_module maintainer,
We have change the pdb_interface!
Please take a look at the current CVS code!
Now you MUST have a pdb_version() function in your module, witch return the
pdb_interface version.
Simply add this:
int pdb_version(void)
{
return PASSDB_INTERFACE_VERSION;
}
SAMBA will NOT load the module:
- when it can't get the PASSDB_INTERFACE_VERSION of the module
(there is no pdb_version() function)
- when the PASSDB_INTERFACE_VERSION of the module doesn't match SAMBA's
PASSDB_INTERFACE_VERSION!
metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <metze at metzemix.de>
-------------- next part --------------
diff -Nur --exclude=CVS HEAD/source/include/passdb.h HEAD-pdb/source/include/passdb.h
--- HEAD/source/include/passdb.h Mon May 27 13:11:00 2002
+++ HEAD-pdb/source/include/passdb.h Fri Jun 21 08:35:04 2002
@@ -27,6 +27,13 @@
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
+
typedef struct pdb_context
{
struct pdb_methods *pdb_methods;
diff -Nur --exclude=CVS HEAD/source/passdb/pdb_plugin.c HEAD-pdb/source/passdb/pdb_plugin.c
--- HEAD/source/passdb/pdb_plugin.c Tue May 21 14:07:18 2002
+++ HEAD-pdb/source/passdb/pdb_plugin.c Fri Jun 21 09:08:04 2002
@@ -29,6 +29,7 @@
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 @@
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;
}
diff -Nur --exclude=CVS HEAD/examples/pdb/README HEAD-pdb/examples/pdb/README
--- HEAD/examples/pdb/README Mon Apr 15 10:31:14 2002
+++ HEAD-pdb/examples/pdb/README Fri Jun 21 09:18:41 2002
@@ -1,5 +1,36 @@
README for Samba Password Database (PDB) examples
====================================================
+21-6-2002 Stefan (metze) Metzmacher <metze at metzemix.de>
+
+I have added an interface versioning.
+
+Every module MUST have a pdb_version() function.
+
+int pdb_version(void)
+{
+ return PASSDB_INTERFACE_VERSION;
+}
+
+21-6-2002 Stefan (metze) Metzmacher <metze at 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 at nl.linux.org>
The pdb_test.c file in this directory contains a very basic example of
diff -Nur --exclude=CVS HEAD/examples/pdb/pdb_test.c HEAD-pdb/examples/pdb/pdb_test.c
--- HEAD/examples/pdb/pdb_test.c Fri Jun 14 09:20:57 2002
+++ HEAD-pdb/examples/pdb/pdb_test.c Fri Jun 21 09:14:25 2002
@@ -63,12 +63,12 @@
}
/***************************************************************************
- 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 +119,7 @@
(*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;
@@ -136,3 +136,8 @@
return NT_STATUS_OK;
}
+
+int pdb_version(void)
+{
+ return PASSDB_INTERFACE_VERSION;
+}
\ No newline at end of file
More information about the samba-technical
mailing list