From: Ken Raeburn Date: Mon, 2 Jun 2008 19:45:16 +0000 (+0000) Subject: Change krb5_context.db_context to point to the real structure type, X-Git-Tag: krb5-1.7-alpha1~671 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7da16b5b7cc56806bd7fbff3295ce9e9e18efba0;p=krb5.git Change krb5_context.db_context to point to the real structure type, and change uses to not cast all the time. Also rename it from db_context to dal_handle, since one of the fields in the pointed-to structure is also called db_context. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20348 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/k5-int.h b/src/include/k5-int.h index 2fb23dd51..5e1fd113a 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1989,1990,1991,1992,1993,1994,1995,2000,2001, 2003,2006,2007 by the Massachusetts Institute of Technology, + * Copyright (C) 1989,1990,1991,1992,1993,1994,1995,2000,2001, 2003,2006,2007,2008 by the Massachusetts Institute of Technology, * Cambridge, MA, USA. All Rights Reserved. * * This software is being provided to you, the LICENSEE, by the @@ -1125,6 +1125,8 @@ void KRB5_CALLCONV krb5_free_pa_enc_ts #include "com_err.h" #include "k5-plugin.h" +struct _kdb5_dal_handle; /* private, in kdb5.h */ +typedef struct _kdb5_dal_handle kdb5_dal_handle; struct _krb5_context { krb5_magic magic; krb5_enctype *in_tkt_ktypes; @@ -1134,7 +1136,7 @@ struct _krb5_context { struct _krb5_os_context os_context; char *default_realm; profile_t profile; - void *db_context; + kdb5_dal_handle *dal_handle; int ser_ctx_count; void *ser_ctx; /* allowable clock skew */ diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c index 168892974..bdade9904 100644 --- a/src/lib/kdb/kdb5.c +++ b/src/lib/kdb/kdb5.c @@ -542,7 +542,7 @@ kdb_setup_lib_handle(krb5_context kcontext) } dal_handle->lib_handle = lib; - kcontext->db_context = (void *) dal_handle; + kcontext->dal_handle = dal_handle; clean_n_exit: free(library); @@ -562,15 +562,13 @@ kdb_free_lib_handle(krb5_context kcontext) { krb5_error_code status = 0; - status = - kdb_free_library(((kdb5_dal_handle *) kcontext->db_context)-> - lib_handle); + status = kdb_free_library(kcontext->dal_handle->lib_handle); if (status) { goto clean_n_exit; } - free(kcontext->db_context); - kcontext->db_context = NULL; + free(kcontext->dal_handle); + kcontext->dal_handle = NULL; clean_n_exit: return status; @@ -585,8 +583,8 @@ get_errmsg (krb5_context kcontext, krb5_error_code err_code) return; assert(kcontext != NULL); /* Must be called with dal_handle->lib_handle locked! */ - assert(kcontext->db_context != NULL); - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + assert(kcontext->dal_handle != NULL); + dal_handle = kcontext->dal_handle; if (dal_handle->lib_handle->vftabl.errcode_2_string == NULL) return; e = dal_handle->lib_handle->vftabl.errcode_2_string(kcontext, err_code); @@ -615,14 +613,14 @@ krb5_db_open(krb5_context kcontext, char **db_args, int mode) goto clean_n_exit; } - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -644,8 +642,8 @@ krb5_db_open(krb5_context kcontext, char **db_args, int mode) krb5_error_code krb5_db_inited(krb5_context kcontext) { - return !(kcontext && kcontext->db_context && - ((kdb5_dal_handle *) kcontext->db_context)->db_context); + return !(kcontext && kcontext->dal_handle && + kcontext->dal_handle->db_context); } krb5_error_code @@ -664,14 +662,14 @@ krb5_db_create(krb5_context kcontext, char **db_args) goto clean_n_exit; } - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -695,12 +693,12 @@ krb5_db_fini(krb5_context kcontext) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { /* module not loaded. So nothing to be done */ goto clean_n_exit; } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -737,14 +735,14 @@ krb5_db_destroy(krb5_context kcontext, char **db_args) goto clean_n_exit; } - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -767,14 +765,14 @@ krb5_db_get_age(krb5_context kcontext, char *db_name, time_t * t) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -794,14 +792,14 @@ krb5_db_set_option(krb5_context kcontext, int option, void *value) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -822,14 +820,14 @@ krb5_db_lock(krb5_context kcontext, int lock_mode) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; /* acquire an exclusive lock, ensures no other thread uses this context */ status = kdb_lock_lib_lock(dal_handle->lib_handle, TRUE); if (status) { @@ -852,14 +850,14 @@ krb5_db_unlock(krb5_context kcontext) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; /* normal lock acquired and exclusive lock released */ status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { @@ -884,14 +882,14 @@ krb5_db_get_principal(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -914,14 +912,14 @@ krb5_db_free_principal(krb5_context kcontext, krb5_db_entry * entry, int count) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -947,7 +945,7 @@ krb5_db_put_principal(krb5_context kcontext, krb5_tl_data *prev, *curr, *next; int db_args_size = 0; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; @@ -1002,7 +1000,7 @@ krb5_db_put_principal(krb5_context kcontext, } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1035,14 +1033,14 @@ krb5_db_delete_principal(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1068,14 +1066,14 @@ krb5_db_iterate(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1097,14 +1095,14 @@ krb5_supported_realms(krb5_context kcontext, char **realms) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1125,14 +1123,14 @@ krb5_free_supported_realms(krb5_context kcontext, char **realms) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1155,14 +1153,14 @@ krb5_db_set_master_key_ext(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1189,14 +1187,14 @@ krb5_db_get_mkey(krb5_context kcontext, krb5_keyblock ** key) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1221,14 +1219,14 @@ krb5_db_store_master_key(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1292,14 +1290,14 @@ krb5_db_fetch_mkey(krb5_context context, } else { kdb5_dal_handle *dal_handle; - if (context->db_context == NULL) { + if (context->dal_handle == NULL) { retval = kdb_setup_lib_handle(context); if (retval) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; retval = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (retval) { goto clean_n_exit; @@ -1345,14 +1343,14 @@ krb5_db_verify_master_key(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1374,14 +1372,14 @@ krb5_db_alloc(krb5_context kcontext, void *ptr, size_t size) kdb5_dal_handle *dal_handle; void *new_ptr = NULL; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; new_ptr = dal_handle->lib_handle->vftabl.db_alloc(kcontext, ptr, size); @@ -1395,14 +1393,14 @@ krb5_db_free(krb5_context kcontext, void *ptr) krb5_error_code status; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; dal_handle->lib_handle->vftabl.db_free(kcontext, ptr); @@ -1435,14 +1433,14 @@ krb5_dbe_search_enctype(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1728,14 +1726,14 @@ krb5_dbe_cpw(krb5_context kcontext, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1762,14 +1760,14 @@ krb5_db_create_policy(krb5_context kcontext, osa_policy_ent_t policy) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1790,14 +1788,14 @@ krb5_db_get_policy(krb5_context kcontext, char *name, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1819,14 +1817,14 @@ krb5_db_put_policy(krb5_context kcontext, osa_policy_ent_t policy) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1847,14 +1845,14 @@ krb5_db_iter_policy(krb5_context kcontext, char *match_entry, krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1876,14 +1874,14 @@ krb5_db_delete_policy(krb5_context kcontext, char *policy) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1903,14 +1901,14 @@ krb5_db_free_policy(krb5_context kcontext, osa_policy_ent_t policy) krb5_error_code status = 0; kdb5_dal_handle *dal_handle; - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; @@ -1940,14 +1938,14 @@ krb5_db_promote(krb5_context kcontext, char **db_args) goto clean_n_exit; } - if (kcontext->db_context == NULL) { + if (kcontext->dal_handle == NULL) { status = kdb_setup_lib_handle(kcontext); if (status) { goto clean_n_exit; } } - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; status = kdb_lock_lib_lock(dal_handle->lib_handle, FALSE); if (status) { goto clean_n_exit; diff --git a/src/lib/kdb/kdb5.h b/src/lib/kdb/kdb5.h index f19b077e4..328ce2519 100644 --- a/src/lib/kdb/kdb5.h +++ b/src/lib/kdb/kdb5.h @@ -186,12 +186,13 @@ typedef struct _db_library { struct _db_library *next, *prev; } *db_library; -typedef struct _kdb5_dal_handle +struct _kdb5_dal_handle { /* Helps us to change db_library without affecting modules to some extent. */ void *db_context; db_library lib_handle; -} kdb5_dal_handle; +}; +/* typedef kdb5_dal_handle is in k5-int.h now */ #endif /* end of _KRB5_KDB5_H_ */ diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c index 57f5b8fba..e29557066 100644 --- a/src/lib/krb5/krb/init_ctx.c +++ b/src/lib/krb5/krb/init_ctx.c @@ -1,7 +1,7 @@ /* * lib/krb5/krb/init_ctx.c * - * Copyright 1994,1999,2000, 2002, 2003, 2007 by the Massachusetts Institute of Technology. + * Copyright 1994,1999,2000, 2002, 2003, 2007, 2008 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -529,7 +529,7 @@ krb5_copy_context(krb5_context ctx, krb5_context *nctx_out) nctx->tgs_ktype_count = 0; nctx->default_realm = NULL; nctx->profile = NULL; - nctx->db_context = NULL; + nctx->dal_handle = NULL; nctx->ser_ctx_count = 0; nctx->ser_ctx = NULL; nctx->prompt_types = NULL; diff --git a/src/lib/krb5/krb/ser_ctx.c b/src/lib/krb5/krb/ser_ctx.c index 8a0088768..5854123ea 100644 --- a/src/lib/krb5/krb/ser_ctx.c +++ b/src/lib/krb5/krb/ser_ctx.c @@ -1,7 +1,7 @@ /* * lib/krb5/krb/ser_ctx.c * - * Copyright 1995, 2007 by the Massachusetts Institute of Technology. + * Copyright 1995, 2007, 2008 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -138,10 +138,10 @@ krb5_context_size(krb5_context kcontext, krb5_pointer arg, size_t *sizep) &required); /* Calculate size required by db_context, if appropriate */ - if (!kret && context->db_context) + if (!kret && context->dal_handle) kret = krb5_size_opaque(kcontext, KV5M_DB_CONTEXT, - (krb5_pointer) context->db_context, + (krb5_pointer) context->dal_handle, &required); /* Finally, calculate size required by profile, if appropriate */ @@ -288,9 +288,9 @@ krb5_context_externalize(krb5_context kcontext, krb5_pointer arg, krb5_octet **b return (kret); /* Now handle database context, if appropriate */ - if (context->db_context) { + if (context->dal_handle) { kret = krb5_externalize_opaque(kcontext, KV5M_DB_CONTEXT, - (krb5_pointer) context->db_context, + (krb5_pointer) context->dal_handle, &bp, &remain); if (kret) return (kret); @@ -465,7 +465,7 @@ krb5_context_internalize(krb5_context kcontext, krb5_pointer *argp, krb5_octet * /* Attempt to read in the db_context */ kret = krb5_internalize_opaque(kcontext, KV5M_DB_CONTEXT, - (krb5_pointer *) &context->db_context, + (krb5_pointer *) &context->dal_handle, &bp, &remain); if (kret && (kret != EINVAL) && (kret != ENOENT)) goto cleanup; diff --git a/src/plugins/kdb/db2/kdb_db2.c b/src/plugins/kdb/db2/kdb_db2.c index eda5274d9..1026b7313 100644 --- a/src/plugins/kdb/db2/kdb_db2.c +++ b/src/plugins/kdb/db2/kdb_db2.c @@ -1,7 +1,7 @@ /* * lib/kdb/kdb_db2.c * - * Copyright 1997,2006,2007 by the Massachusetts Institute of Technology. + * Copyright 1997,2006,2007,2008 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -132,9 +132,9 @@ static char default_db_name[] = DEFAULT_KDB_FILE; /* * Routines to deal with context. */ -#define k5db2_inited(c) (c && c->db_context \ - && ((kdb5_dal_handle*)c->db_context)->db_context \ - && ((krb5_db2_context *) ((kdb5_dal_handle*)c->db_context)->db_context)->db_inited) +#define k5db2_inited(c) (c && c->dal_handle \ + && c->dal_handle->db_context \ + && ((krb5_db2_context *) c->dal_handle->db_context)->db_inited) static krb5_error_code krb5_db2_get_db_opt(char *input, char **opt, char **val) @@ -188,7 +188,7 @@ k5db2_init_context(krb5_context context) krb5_db2_context *db_ctx; kdb5_dal_handle *dal_handle; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; if (dal_handle->db_context == NULL) { db_ctx = (krb5_db2_context *) malloc(sizeof(krb5_db2_context)); @@ -287,7 +287,7 @@ krb5_db2_db_set_hashfirst(krb5_context context, int hashfirst) if (k5db2_inited(context)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; dbc = (krb5_db2_context *) dal_handle->db_context; dbc->hashfirst = hashfirst; return 0; @@ -313,7 +313,7 @@ krb5_db2_db_init(krb5_context context) if ((retval = k5db2_init_context(context))) return (retval); - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = dal_handle->db_context; db_ctx->db = NULL; @@ -368,7 +368,7 @@ krb5_db2_db_fini(krb5_context context) krb5_db2_context *db_ctx; kdb5_dal_handle *dal_handle; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; if (dal_handle == NULL) { return 0; } @@ -408,7 +408,7 @@ krb5_db2_db_set_mkey(krb5_context context, krb5_keyblock *key) if (!k5db2_inited(context)) return (KRB5_KDB_DBNOTINITED); - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = dal_handle->db_context; db_ctx->db_master_key = key; return 0; @@ -423,7 +423,7 @@ krb5_db2_db_get_mkey(krb5_context context, krb5_keyblock **key) if (!k5db2_inited(context)) return (KRB5_KDB_DBNOTINITED); - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = dal_handle->db_context; *key = db_ctx->db_master_key; @@ -457,7 +457,7 @@ krb5_db2_db_set_name(krb5_context context, char *name, int tempdb) if (name == NULL) name = default_db_name; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = dal_handle->db_context; db_ctx->tempdb = tempdb; db = k5db2_dbopen(db_ctx, name, O_RDONLY, 0, tempdb); @@ -484,7 +484,7 @@ krb5_db2_db_get_age(krb5_context context, char *db_name, time_t *age) if (!k5db2_inited(context)) return (KRB5_KDB_DBNOTINITED); - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; if (fstat(db_ctx->db_lf_file, &st) < 0) @@ -522,7 +522,7 @@ krb5_db2_db_end_update(krb5_context context) return (KRB5_KDB_DBNOTINITED); retval = 0; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = dal_handle->db_context; now = time((time_t *) NULL); if (fstat(db_ctx->db_lf_file, &st) == 0) { @@ -577,7 +577,7 @@ krb5_db2_db_lock(krb5_context context, int in_mode) if (!k5db2_inited(context)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; if (db_ctx->db_locks_held && (db_ctx->db_lock_mode >= mode)) { /* No need to upgrade lock, just return */ @@ -648,7 +648,7 @@ krb5_db2_db_unlock(krb5_context context) if (!k5db2_inited(context)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; if ((retval = osa_adb_release_lock(db_ctx->policy_db))) { @@ -688,7 +688,7 @@ krb5_db2_db_create(krb5_context context, char *db_name, krb5_int32 flags) if ((retval = k5db2_init_context(context))) return (retval); - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; switch (flags) { case KRB5_KDB_CREATE_HASH: @@ -835,8 +835,8 @@ krb5_db2_db_destroy(krb5_context context, char *dbname) char policy_db_name[1024], policy_lock_name[1024]; tmpcontext = 0; - if (!context->db_context - || !((kdb5_dal_handle *) context->db_context)->db_context) { + if (!context->dal_handle + || !context->dal_handle->db_context) { tmpcontext = 1; if ((retval1 = k5db2_init_context(context))) return (retval1); @@ -847,10 +847,9 @@ krb5_db2_db_destroy(krb5_context context, char *dbname) retval2 = destroy_file_suffix(dbname, KDB2_LOCK_EXT); if (tmpcontext) { - k5db2_clear_context((krb5_db2_context *) ((kdb5_dal_handle *) context-> - db_context)->db_context); - free(((kdb5_dal_handle *) context->db_context)->db_context); - ((kdb5_dal_handle *) context->db_context)->db_context = NULL; + k5db2_clear_context((krb5_db2_context *) context->dal_handle->db_context); + free(context->dal_handle->db_context); + context->dal_handle->db_context = NULL; } if (retval1 || retval2) @@ -893,7 +892,7 @@ krb5_db2_db_get_principal(krb5_context context, if (!k5db2_inited(context)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; for (trynum = 0; trynum < KRB5_DB2_MAX_RETRY; trynum++) { @@ -991,7 +990,7 @@ krb5_db2_db_put_principal(krb5_context context, if (!k5db2_inited(context)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; if ((retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_EXCLUSIVE))) return retval; @@ -1054,7 +1053,7 @@ krb5_db2_db_delete_principal(krb5_context context, if (!k5db2_inited(context)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; if ((retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_EXCLUSIVE))) return (retval); @@ -1141,7 +1140,7 @@ krb5_db2_db_iterate_ext(krb5_context context, if (!k5db2_inited(context)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_SHARED); @@ -1216,7 +1215,7 @@ krb5_db2_db_set_lockmode(krb5_context context, krb5_boolean mode) krb5_db2_context *db_ctx; kdb5_dal_handle *dal_handle; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; old = mode; if (dal_handle && (db_ctx = (krb5_db2_context *) dal_handle->db_context)) { old = db_ctx->db_nb_locks; @@ -1498,7 +1497,7 @@ krb5_db2_db_set_option(krb5_context kcontext, int option, void *value) if (!k5db2_inited(kcontext)) return KRB5_KDB_DBNOTINITED; - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; db_ctx = (krb5_db2_context *) dal_handle->db_context; @@ -1539,7 +1538,7 @@ krb5_db2_create_policy(krb5_context kcontext, osa_policy_ent_t policy) kdb5_dal_handle *dal_handle; krb5_db2_context *dbc; - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; dbc = (krb5_db2_context *) dal_handle->db_context; return osa_adb_create_policy(dbc->policy_db, policy); @@ -1552,7 +1551,7 @@ krb5_db2_get_policy(krb5_context kcontext, kdb5_dal_handle *dal_handle; krb5_db2_context *dbc; - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; dbc = (krb5_db2_context *) dal_handle->db_context; return osa_adb_get_policy(dbc->policy_db, name, policy, cnt); @@ -1564,7 +1563,7 @@ krb5_db2_put_policy(krb5_context kcontext, osa_policy_ent_t policy) kdb5_dal_handle *dal_handle; krb5_db2_context *dbc; - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; dbc = (krb5_db2_context *) dal_handle->db_context; return osa_adb_put_policy(dbc->policy_db, policy); @@ -1578,7 +1577,7 @@ krb5_db2_iter_policy(krb5_context kcontext, kdb5_dal_handle *dal_handle; krb5_db2_context *dbc; - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; dbc = (krb5_db2_context *) dal_handle->db_context; return osa_adb_iter_policy(dbc->policy_db, func, data); @@ -1590,7 +1589,7 @@ krb5_db2_delete_policy(krb5_context kcontext, char *policy) kdb5_dal_handle *dal_handle; krb5_db2_context *dbc; - dal_handle = (kdb5_dal_handle *) kcontext->db_context; + dal_handle = kcontext->dal_handle; dbc = (krb5_db2_context *) dal_handle->db_context; return osa_adb_destroy_policy(dbc->policy_db, policy); @@ -1615,12 +1614,12 @@ krb5_db2_promote_db(krb5_context kcontext, char *conf_section, char **db_args) krb5_clear_error_message (kcontext); { - kdb5_dal_handle *dal_handle = kcontext->db_context; + kdb5_dal_handle *dal_handle = kcontext->dal_handle; krb5_db2_context *db_ctx = dal_handle->db_context; db_name = strdup(db_ctx->db_name); } - assert(kcontext->db_context != NULL); + assert(kcontext->dal_handle != NULL); temp_db_name = gen_dbsuffix(db_name, "~"); if (temp_db_name == NULL) { status = ENOMEM; @@ -1660,7 +1659,7 @@ krb5_db2_db_rename(context, from, to) char *fromok; krb5_error_code retval; krb5_db2_context *s_context, *db_ctx; - kdb5_dal_handle *dal_handle = context->db_context; + kdb5_dal_handle *dal_handle = context->dal_handle; s_context = dal_handle->db_context; dal_handle->db_context = NULL; diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c index 7a6c6411e..f75819a14 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_policy.c @@ -56,7 +56,7 @@ static krb5_error_code init_ldap_realm (int argc, char *argv[]) { kdb5_dal_handle *dal_handle = NULL; krb5_ldap_context *ldap_context=NULL; - dal_handle = (kdb5_dal_handle *) util_context->db_context; + dal_handle = util_context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (!ldap_context) { retval = EINVAL; diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c index 1a0d9fa99..4a64143de 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c @@ -1,7 +1,7 @@ /* * kadmin/ldap_util/kdb5_ldap_realm.c * - * Copyright 1990,1991,2001, 2002 by the Massachusetts Institute of Technology. + * Copyright 1990,1991,2001, 2002, 2008 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -521,7 +521,7 @@ void kdb5_ldap_create(argc, argv) goto err_nomsg; } - dal_handle = (kdb5_dal_handle *) util_context->db_context; + dal_handle = util_context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (!ldap_context) { retval = EINVAL; @@ -923,7 +923,7 @@ void kdb5_ldap_modify(argc, argv) int subtree_changed = 0; #endif - dal_handle = (kdb5_dal_handle *) util_context->db_context; + dal_handle = util_context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (!(ldap_context)) { retval = EINVAL; @@ -1800,7 +1800,7 @@ void kdb5_ldap_view(argc, argv) krb5_ldap_context *ldap_context=NULL; int mask = 0; - dal_handle = (kdb5_dal_handle *) util_context->db_context; + dal_handle = util_context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (!(ldap_context)) { retval = EINVAL; @@ -1998,7 +1998,7 @@ void kdb5_ldap_list(argc, argv) kdb5_dal_handle *dal_handle=NULL; krb5_ldap_context *ldap_context=NULL; - dal_handle = (kdb5_dal_handle *)util_context->db_context; + dal_handle = util_context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (!(ldap_context)) { retval = EINVAL; @@ -2239,7 +2239,7 @@ kdb_ldap_create_principal (context, princ, op, pblock) retval = EINVAL; goto cleanup; } - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (!(ldap_context)) { retval = EINVAL; @@ -2431,7 +2431,7 @@ kdb5_ldap_destroy(argc, argv) printf("OK, deleting database of '%s'...\n", global_params.realm); } - dal_handle = (kdb5_dal_handle *)util_context->db_context; + dal_handle = util_context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (!(ldap_context)) { com_err(argv[0], EINVAL, "while initializing database"); diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c index 9fcc7b79d..34a2fc808 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c @@ -1,7 +1,7 @@ /* * kadmin/ldap_util/kdb5_ldap_util.c * - * (C) Copyright 1990,1991, 1996 by the Massachusetts Institute of Technology. + * (C) Copyright 1990,1991, 1996, 2008 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -579,7 +579,7 @@ int main(argc, argv) goto cleanup; } dal_handle->db_context = ldap_context; - util_context->db_context = (void *) dal_handle; + util_context->dal_handle = dal_handle; db_retval = krb5_ldap_read_server_params(util_context, conf_section, KRB5_KDB_SRV_TYPE_OTHER); if (db_retval) { diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.c b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.c index 40bde9e21..d7f63d0a8 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.c @@ -441,7 +441,7 @@ krb5_error_code krb5_ldap_open(krb5_context context, t_ptr++; } - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; dal_handle->db_context = ldap_context; status = krb5_ldap_read_server_params(context, conf_section, mode & 0x0300); if (status) { diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h index 4cd137067..918c6bcf3 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap.h @@ -77,11 +77,11 @@ extern struct timeval timelimit; #define IGNORE_STATUS 0 #define CHECK_STATUS 1 -#define SETUP_CONTEXT() if (context == NULL || context->db_context == NULL \ - || ((kdb5_dal_handle *)context->db_context)->db_context == NULL) { \ +#define SETUP_CONTEXT() if (context == NULL || context->dal_handle == NULL \ + || context->dal_handle->db_context == NULL) { \ return EINVAL; \ } \ - dal_handle = (kdb5_dal_handle *)context->db_context; \ + dal_handle = context->dal_handle; \ ldap_context = (krb5_ldap_context *) dal_handle->db_context; \ if (ldap_context == NULL || ldap_context->server_info_list == NULL) \ return KRB5_KDB_DBNOTINITED; 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 343705efc..8494681a1 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c @@ -338,11 +338,11 @@ krb5_ldap_close(krb5_context context) krb5_ldap_context *ldap_context=NULL; if (context == NULL || - context->db_context == NULL || - ((kdb5_dal_handle *)context->db_context)->db_context == NULL) + context->dal_handle == NULL || + context->dal_handle->db_context == NULL) return 0; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; dal_handle->db_context = NULL; diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_create.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_create.c index 8c60c177d..124396f3f 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_create.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_create.c @@ -250,7 +250,7 @@ krb5_ldap_create (krb5_context context, char *conf_section, char **db_args) t_ptr++; } - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; dal_handle->db_context = (kdb5_dal_handle *) ldap_context; status = krb5_ldap_read_server_params(context, conf_section, KRB5_KDB_SRV_TYPE_ADMIN); diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_fetch_mkey.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_fetch_mkey.c index c159f0014..9a364192a 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_fetch_mkey.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_fetch_mkey.c @@ -47,7 +47,7 @@ krb5_ldap_get_mkey (context, key) /* Clear the global error string */ krb5_clear_error_message(context); - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (ldap_context == NULL || ldap_context->lrparams == NULL) @@ -75,7 +75,7 @@ krb5_ldap_set_mkey (context, pwd, key) /* Clear the global error string */ krb5_clear_error_message(context); - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; if (ldap_context == NULL || ldap_context->lrparams == NULL) diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c index 11c5caae3..818b2e55c 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c @@ -152,7 +152,7 @@ krb5_ldap_read_server_params(context, conf_section, srv_type) krb5_ldap_context *ldap_context=NULL; krb5_ldap_server_info ***server_info=NULL; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; /* copy the conf_section into ldap_context for later use */ diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c index 7926484c7..7819ddd95 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c @@ -102,7 +102,7 @@ krb5_ldap_get_principal(context, searchfor, entries, nentries, more) if (searchfor == NULL) return EINVAL; - dal_handle = (kdb5_dal_handle *) context->db_context; + dal_handle = context->dal_handle; ldap_context = (krb5_ldap_context *) dal_handle->db_context; CHECK_LDAP_HANDLE(ldap_context);