Hi Andrew,

here's the NEXT 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 macro in your module:
PDB_MODULE_VERSIONING_MAGIC


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 <[EMAIL PROTECTED]>
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 10:54:50 2002
@@ -1,5 +1,41 @@
 README for Samba Password Database (PDB) examples
 ====================================================
+21-6-2002 Stefan (metze) Metzmacher <[EMAIL PROTECTED]>
+
+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 <[EMAIL PROTECTED]>
+
+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 <[EMAIL PROTECTED]>
 
 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 10:57:07 2002
@@ -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 @@
 }
 
 /***************************************************************************
- 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 @@
        (*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 -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 10:51:51 2002
@@ -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;

Reply via email to