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.
ticket: 6749
status: open
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24157
dc483132-0cff-0310-8789-
dd5450dbe970
#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
#define KRB5_KDB_OPT_SET_DB_NAME 0
#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
* 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
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
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;
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:
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
(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;
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);
* 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