svn rev #24157: trunk/src/ include/ lib/kdb/ lib/krb5/error_tables/ plugins/kdb/db2/ ...

ghudson@MIT.EDU ghudson at MIT.EDU
Thu Jul 1 23:23:21 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=24157
Commit By: ghudson
Log Message:
ticket: 6749
subject: DAL improvements
status: open

Add KRB5_KDB_API_VERSION to allow callers to adjust to incompatible
changes in libkdb; to be kept in sync with the libkdb major version,
which is bumped to 5 in anticipation of other changes.

Add KRB5_KDB_DAL_VERSION to allow database modules to detect when they
are mismatched with the KDB version.  Since KDB modules are often
developed concurrently with trunk code, this is defined to be the date
of the last incompatible DAL change.  The DAL version is passed to the
init_library DAL function; the module should check it against the value
of KRB5_KDB_DAL_VERSION it was compiled with and return
KRB5_KDB_DBTYPE_MISMATCH if it doesn't match.



Changed Files:
U   trunk/src/include/kdb.h
U   trunk/src/lib/kdb/Makefile.in
U   trunk/src/lib/kdb/kdb5.c
U   trunk/src/lib/krb5/error_tables/kdb5_err.et
U   trunk/src/plugins/kdb/db2/db2_exp.c
U   trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h
U   trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c
Modified: trunk/src/include/kdb.h
===================================================================
--- trunk/src/include/kdb.h	2010-07-01 16:56:22 UTC (rev 24156)
+++ trunk/src/include/kdb.h	2010-07-02 03:23:21 UTC (rev 24157)
@@ -72,6 +72,10 @@
 
 #include <krb5.h>
 
+/* This version will be incremented when incompatible changes are made to the
+ * KDB API, and will be kept in sync with the libkdb major version. */
+#define KRB5_KDB_API_VERSION 5
+
 /* Salt types */
 #define KRB5_KDB_SALTTYPE_NORMAL        0
 #define KRB5_KDB_SALTTYPE_V4            1
@@ -860,6 +864,13 @@
 #define KRB5_KDB_OPT_SET_LOCK_MODE      1
 
 /*
+ * This number indicates the date of the last incompatible change to the
+ * DAL.  It is passed to init_library to allow KDB modules to detect when
+ * they are being loaded by an incompatible version of the KDC.
+ */
+#define KRB5_KDB_DAL_VERSION 20100701
+
+/*
  * A krb5_context can hold one database object.  Modules should use
  * context->dal_handle->db_context to store state associated with the database
  * object.
@@ -886,7 +897,7 @@
      * Mandatory: Invoked after the module library is loaded, when the first DB
      * using the module is opened, across all contexts.
      */
-    krb5_error_code (*init_library)(void);
+    krb5_error_code (*init_library)(int dal_version);
 
     /*
      * Mandatory: Invoked before the module library is unloaded, after the last

Modified: trunk/src/lib/kdb/Makefile.in
===================================================================
--- trunk/src/lib/kdb/Makefile.in	2010-07-01 16:56:22 UTC (rev 24156)
+++ trunk/src/lib/kdb/Makefile.in	2010-07-02 03:23:21 UTC (rev 24157)
@@ -8,8 +8,9 @@
 LOCALINCLUDES= -I.
 DEFS=
 
+# Keep LIBMAJOR in sync with KRB5_KDB_API_VERSION in include/kdb.h.
 LIBBASE=kdb5
-LIBMAJOR=4
+LIBMAJOR=5
 LIBMINOR=0
 LIBINITFUNC=kdb_init_lock_list
 LIBFINIFUNC=kdb_fini_lock_list

Modified: trunk/src/lib/kdb/kdb5.c
===================================================================
--- trunk/src/lib/kdb/kdb5.c	2010-07-01 16:56:22 UTC (rev 24156)
+++ trunk/src/lib/kdb/kdb5.c	2010-07-02 03:23:21 UTC (rev 24157)
@@ -311,7 +311,7 @@
     memcpy(&lib->vftabl, vftabl_addr, sizeof(kdb_vftabl));
     kdb_setup_opt_functions(lib);
 
-    status = lib->vftabl.init_library();
+    status = lib->vftabl.init_library(KRB5_KDB_DAL_VERSION);
     if (status)
         goto cleanup;
 
@@ -408,7 +408,7 @@
     memcpy(&(*lib)->vftabl, vftabl_addrs[0], sizeof(kdb_vftabl));
     kdb_setup_opt_functions(*lib);
 
-    if ((status = (*lib)->vftabl.init_library()))
+    if ((status = (*lib)->vftabl.init_library(KRB5_KDB_DAL_VERSION)))
         goto clean_n_exit;
 
 clean_n_exit:

Modified: trunk/src/lib/krb5/error_tables/kdb5_err.et
===================================================================
--- trunk/src/lib/krb5/error_tables/kdb5_err.et	2010-07-01 16:56:22 UTC (rev 24156)
+++ trunk/src/lib/krb5/error_tables/kdb5_err.et	2010-07-02 03:23:21 UTC (rev 24157)
@@ -82,5 +82,6 @@
 ec KRB5_LOG_UNSTABLE,		"Update log is unstable"
 ec KRB5_LOG_CORRUPT,		"Update log is corrupt"
 ec KRB5_LOG_ERROR,		"Generic update log error"
+ec KRB5_KDB_DBTYPE_MISMATCH,    "Database module does not match KDC version"
 
 end

Modified: trunk/src/plugins/kdb/db2/db2_exp.c
===================================================================
--- trunk/src/plugins/kdb/db2/db2_exp.c	2010-07-01 16:56:22 UTC (rev 24156)
+++ trunk/src/plugins/kdb/db2/db2_exp.c	2010-07-02 03:23:21 UTC (rev 24157)
@@ -201,9 +201,12 @@
         (kcontext, method, request, response));
 
 static krb5_error_code
-hack_init ()
+hack_init (int dal_version)
 {
     krb5_error_code c;
+
+    if (dal_version != KRB5_KDB_DAL_VERSION)
+        return KRB5_KDB_DBTYPE_MISMATCH;
     c = krb5int_mutex_alloc (&krb5_db2_mutex);
     if (c)
         return c;

Modified: trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h
===================================================================
--- trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h	2010-07-01 16:56:22 UTC (rev 24156)
+++ trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h	2010-07-02 03:23:21 UTC (rev 24157)
@@ -254,7 +254,7 @@
 krb5_ldap_db_get_age(krb5_context, char *, time_t *);
 
 krb5_error_code
-krb5_ldap_lib_init(void);
+krb5_ldap_lib_init(int dal_version);
 
 krb5_error_code
 krb5_ldap_lib_cleanup(void);

Modified: trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c
===================================================================
--- trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c	2010-07-01 16:56:22 UTC (rev 24156)
+++ trunk/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c	2010-07-02 03:23:21 UTC (rev 24157)
@@ -312,9 +312,10 @@
  *     DAL API functions
  */
 krb5_error_code
-krb5_ldap_lib_init()
+krb5_ldap_lib_init(int dal_version)
 {
-    return 0;
+    if (dal_version != KRB5_KDB_DAL_VERSION)
+        return KRB5_KDB_DBTYPE_MISMATCH;
 }
 
 krb5_error_code




More information about the cvs-krb5 mailing list