krb5: krb5_cc_ops backward compatibility and extensibility

The krb5_cc_ops structure is an extensible structure to which new
functionality has been added over the years.

Version zero was the original.  It included all functions up to
and including get_default_name().

Version one added set_default().

Version two added lastchange().

Version three added set_kdc_offset() and get_kdc_offset().

Version four broke compatibility by modifying the signatures
of get_name() and resolve().   This was in change
7bf4d76e75 ("krb5: Improve cccol sub
naming; add gss_store_cred_into2()").

Version five restores the original signatures of get_name()
and resolve() and introduces get_name_2() and resolve_2() that
provide the additional cccol functionality.

This change

 * introduces version five
 * documents which functions are part of each version
 * replaces KRB5_CC_OPS_VERSION with KRB5_CC_OPS_VERSION_0,
   KRB5_CC_OPS_VERSION_1, KRB5_CC_OPS_VERSION_2, KRB5_CC_OPS_VERSION_3,
   and KRB5_CC_OPS_VERSION_5.  KRB5_CC_OPS_VERSION_4 is skipped
   because of the aforementioned breakage.
 * compatibility logic is added to permit ccache plugins to implement
   any of version one, two, three, five or a future version.
 * all in-tree krb5_cc_ops implementations are updated to version 5.

Change-Id: Iadfce01d10834bc6151939e4d9d196f03001626e
This commit is contained in:
Jeffrey Altman
2020-05-27 22:19:13 -04:00
committed by Nico Williams
parent 33bb2479b9
commit d84512b8d2
10 changed files with 156 additions and 109 deletions

View File

@@ -67,11 +67,11 @@ struct fcc_cursor {
#define FCC_CURSOR(C) ((struct fcc_cursor*)(C))
static krb5_error_code KRB5_CALLCONV
fcc_get_name(krb5_context context,
krb5_ccache id,
const char **name,
const char **colname,
const char **sub)
fcc_get_name_2(krb5_context context,
krb5_ccache id,
const char **name,
const char **colname,
const char **sub)
{
if (FCACHE(id) == NULL)
return KRB5_CC_NOTFOUND;
@@ -196,7 +196,7 @@ fcc_lock(krb5_context context, krb5_ccache id,
if (exclusive == FALSE)
return 0;
ret = fcc_get_name(context, id, &name, NULL, NULL);
ret = fcc_get_name_2(context, id, &name, NULL, NULL);
if (ret == 0)
ret = _krb5_xlock(context, fd, exclusive, name);
return ret;
@@ -214,10 +214,10 @@ fcc_get_default_name(krb5_context, char **);
#define FILESUBSEPCHR ((FILESUBSEP)[0])
static krb5_error_code KRB5_CALLCONV
fcc_resolve(krb5_context context,
krb5_ccache *id,
const char *res,
const char *sub)
fcc_resolve_2(krb5_context context,
krb5_ccache *id,
const char *res,
const char *sub)
{
krb5_fcache *f;
char *freeme = NULL;
@@ -1662,10 +1662,10 @@ fcc_get_kdc_offset(krb5_context context, krb5_ccache id, krb5_deltat *kdc_offset
*/
KRB5_LIB_VARIABLE const krb5_cc_ops krb5_fcc_ops = {
KRB5_CC_OPS_VERSION,
KRB5_CC_OPS_VERSION_5,
"FILE",
fcc_get_name,
fcc_resolve,
NULL,
NULL,
fcc_gen_new,
fcc_initialize,
fcc_destroy,
@@ -1687,5 +1687,7 @@ KRB5_LIB_VARIABLE const krb5_cc_ops krb5_fcc_ops = {
fcc_set_default_cache,
fcc_lastchange,
fcc_set_kdc_offset,
fcc_get_kdc_offset
fcc_get_kdc_offset,
fcc_get_name_2,
fcc_resolve_2
};