From a9883866e0b8c72986965c98dbfa98b7f50640cf Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Wed, 21 Jul 2010 19:01:35 +0000 Subject: [PATCH] Revert the part of r24157 which added the dal_version argument to the 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 --- src/include/kdb.h | 9 ++++----- src/lib/kdb/kdb5.c | 10 ++++++++-- src/plugins/kdb/db2/db2_exp.c | 6 ++---- src/plugins/kdb/hdb/kdb_hdb.c | 6 ++---- src/plugins/kdb/ldap/ldap_exp.c | 2 +- src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h | 2 +- src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c | 4 +--- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/include/kdb.h b/src/include/kdb.h index e4970e72a..d401fd544 100644 --- a/src/include/kdb.h +++ b/src/include/kdb.h @@ -742,11 +742,10 @@ krb5_dbe_free_tl_data(krb5_context, krb5_tl_data *); #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 @@ -775,7 +774,7 @@ typedef struct _kdb_vftabl { * 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 diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c index 7d0b84ca2..978650300 100644 --- a/src/lib/kdb/kdb5.c +++ b/src/lib/kdb/kdb5.c @@ -295,7 +295,7 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library *libptr) 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; @@ -389,10 +389,16 @@ kdb_load_library(krb5_context kcontext, char *lib_name, db_library * lib) 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: diff --git a/src/plugins/kdb/db2/db2_exp.c b/src/plugins/kdb/db2/db2_exp.c index 2de4bbcac..327a6b822 100644 --- a/src/plugins/kdb/db2/db2_exp.c +++ b/src/plugins/kdb/db2/db2_exp.c @@ -193,12 +193,10 @@ WRAP_VOID (krb5_db2_audit_as_req, (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; @@ -219,7 +217,7 @@ hack_cleanup (void) */ 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, diff --git a/src/plugins/kdb/hdb/kdb_hdb.c b/src/plugins/kdb/hdb/kdb_hdb.c index 23039b7be..460636ac1 100644 --- a/src/plugins/kdb/hdb/kdb_hdb.c +++ b/src/plugins/kdb/hdb/kdb_hdb.c @@ -40,10 +40,8 @@ #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; } @@ -1218,7 +1216,7 @@ kh_db_check_allowed_to_delegate(krb5_context context, } kdb_vftabl kdb_function_table = { - 1, + KRB5_KDB_DAL_MAJOR_VERSION, 0, kh_init, kh_fini, diff --git a/src/plugins/kdb/ldap/ldap_exp.c b/src/plugins/kdb/ldap/ldap_exp.c index 55f10d9b6..069ee8230 100644 --- a/src/plugins/kdb/ldap/ldap_exp.c +++ b/src/plugins/kdb/ldap/ldap_exp.c @@ -47,7 +47,7 @@ */ 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, diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h index 8531b8cc6..1f998a48c 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h @@ -254,7 +254,7 @@ krb5_error_code 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); diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c index 6749bce32..82b0333cd 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c @@ -312,10 +312,8 @@ krb5_ldap_rebind(krb5_ldap_context *ldap_context, * 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; } -- 2.26.2