init_library interface. Instead use the already existing maj_ver
field of the DAL vtable to detect incompatibilities. Since maj_ver
is a short int, use an incrementing number instead of a date for the
major version.
ticket: 6749
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24200
dc483132-0cff-0310-8789-
dd5450dbe970
#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.
+ * This number indicates the date of the last incompatible change to the DAL.
+ * The maj_ver field of the module's vtable structure must match this version.
*/
-#define KRB5_KDB_DAL_VERSION 20100714
+#define KRB5_KDB_DAL_MAJOR_VERSION 2
/*
* A krb5_context can hold one database object. Modules should use
* 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)(int dal_version);
+ krb5_error_code (*init_library)(void);
/*
* Mandatory: Invoked before the module library is unloaded, after the last
memcpy(&lib->vftabl, vftabl_addr, sizeof(kdb_vftabl));
kdb_setup_opt_functions(lib);
- status = lib->vftabl.init_library(KRB5_KDB_DAL_VERSION);
+ status = lib->vftabl.init_library();
if (status)
goto cleanup;
goto clean_n_exit;
}
+ if (((kdb_vftabl *)vftabl_addrs[0])->maj_ver !=
+ KRB5_KDB_DAL_MAJOR_VERSION) {
+ status = KRB5_KDB_DBTYPE_MISMATCH;
+ goto clean_n_exit;
+ }
+
memcpy(&(*lib)->vftabl, vftabl_addrs[0], sizeof(kdb_vftabl));
kdb_setup_opt_functions(*lib);
- if ((status = (*lib)->vftabl.init_library(KRB5_KDB_DAL_VERSION)))
+ if ((status = (*lib)->vftabl.init_library()))
goto clean_n_exit;
clean_n_exit:
(kcontext, request, client, server, authtime, error_code));
static krb5_error_code
-hack_init (int dal_version)
+hack_init (void)
{
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;
*/
kdb_vftabl PLUGIN_SYMBOL_NAME(krb5_db2, kdb_function_table) = {
- 1, /* major version number 1 */
+ KRB5_KDB_DAL_MAJOR_VERSION, /* major version number */
0, /* minor version number 0 */
/* init_library */ hack_init,
/* fini_library */ hack_cleanup,
#include "kdb_hdb.h"
static krb5_error_code
-kh_init(int dal_version)
+kh_init(void)
{
- if (dal_version != KRB5_KDB_DAL_VERSION)
- return KRB5_KDB_DBTYPE_MISMATCH;
return 0;
}
}
kdb_vftabl kdb_function_table = {
- 1,
+ KRB5_KDB_DAL_MAJOR_VERSION,
0,
kh_init,
kh_fini,
*/
kdb_vftabl PLUGIN_SYMBOL_NAME(krb5_ldap, kdb_function_table) = {
- 1, /* major version number 1 */
+ KRB5_KDB_DAL_MAJOR_VERSION, /* major version number */
0, /* minor version number 0 */
/* init_library */ krb5_ldap_lib_init,
/* fini_library */ krb5_ldap_lib_cleanup,
krb5_ldap_get_age(krb5_context, char *, time_t *);
krb5_error_code
-krb5_ldap_lib_init(int dal_version);
+krb5_ldap_lib_init(void);
krb5_error_code
krb5_ldap_lib_cleanup(void);
* DAL API functions
*/
krb5_error_code
-krb5_ldap_lib_init(int dal_version)
+krb5_ldap_lib_init()
{
- if (dal_version != KRB5_KDB_DAL_VERSION)
- return KRB5_KDB_DBTYPE_MISMATCH;
return 0;
}