s4-ldb: added support for ldb module version checking
authorAndrew Tridgell <tridge@samba.org>
Mon, 1 Nov 2010 11:28:59 +0000 (22:28 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 1 Nov 2010 13:05:04 +0000 (13:05 +0000)
source4/lib/ldb/include/ldb_module.h
source4/lib/ldb/wscript

index 800bf72e446979add53cf99c00943c48042b479d..fbea70770d5287c516c032f2b04137684cd4a41b 100644 (file)
@@ -252,4 +252,11 @@ int ldb_register_hook(ldb_hook_fn hook_fn);
  */
 int ldb_modules_hook(struct ldb_context *ldb, enum ldb_module_hook_type t);
 
+#define LDB_MODULE_CHECK_VERSION(version) do { \
+ if (strcmp(version, LDB_VERSION) != 0) { \
+       fprintf(stderr, "ldb: module version mismatch in %s : ldb_version=%s module_version=%s\n", \
+                       __FILE__, version, LDB_VERSION); \
+        return LDB_ERR_UNAVAILABLE; \
+ }} while (0)
+
 #endif
index 3204ba8e326012c07ca6f8609346d58249993e34..4ed7298434353d9ee8ebde306c798b5dfcfdc668 100644 (file)
@@ -56,6 +56,8 @@ def configure(conf):
         if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
             conf.env.ENABLE_LDAP_BACKEND = True
 
+    conf.DEFINE('LDB_VERSION', VERSION, quote=True)
+
     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
 
     # we don't want any libraries or modules to rely on runtime
@@ -124,7 +126,7 @@ def build(bld):
                           vnum=VERSION,
                           manpages='man/ldb.3',
                           abi_file = abi_file,
-                          abi_match = abi_match)
+                         abi_match = abi_match)
 
 
         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
@@ -204,7 +206,7 @@ def build(bld):
                             'common/ldb.c',
                             deps='tevent',
                             includes='include',
-                            cflags='-DLDB_MODULESDIR=\"%s\" -DLDB_VERSION=\"%s\"' % (modules_dir, VERSION))
+                            cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir)
 
     bld.SAMBA_LIBRARY('ldb-cmdline',
                       source='tools/ldbutil.c tools/cmdline.c',