krb5: Restore FILE as the default ccache type
This commit is contained in:
@@ -225,24 +225,6 @@ allocate_ccache(krb5_context context,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
is_possible_path_name(const char * name)
|
|
||||||
{
|
|
||||||
const char * colon;
|
|
||||||
|
|
||||||
if ((colon = strchr(name, ':')) == NULL)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
/* <drive letter>:\path\to\cache ? */
|
|
||||||
|
|
||||||
if (colon == name + 1 &&
|
|
||||||
strchr(colon + 1, ':') == NULL)
|
|
||||||
return TRUE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find and allocate a ccache in `id' from the specification in `residual'.
|
* Find and allocate a ccache in `id' from the specification in `residual'.
|
||||||
@@ -278,13 +260,7 @@ krb5_cc_resolve(krb5_context context,
|
|||||||
id);
|
id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_possible_path_name(name))
|
|
||||||
return allocate_ccache(context, &krb5_fcc_ops, name, NULL, id);
|
return allocate_ccache(context, &krb5_fcc_ops, name, NULL, id);
|
||||||
else {
|
|
||||||
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,
|
|
||||||
N_("unknown ccache type %s", "name"), name);
|
|
||||||
return KRB5_CC_UNKNOWN_TYPE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
@@ -295,11 +271,12 @@ get_default_cc_type(krb5_context context, int simple)
|
|||||||
krb5_config_get_string_default(context, NULL,
|
krb5_config_get_string_default(context, NULL,
|
||||||
secure_getenv("KRB5CCTYPE"),
|
secure_getenv("KRB5CCTYPE"),
|
||||||
"libdefaults", "default_cc_type", NULL);
|
"libdefaults", "default_cc_type", NULL);
|
||||||
|
const char *def_cccol =
|
||||||
if (!simple &&
|
krb5_config_get_string(context, NULL, "libdefaults",
|
||||||
(def_ccname = krb5_cc_default_name(context))) {
|
"default_cc_collection", NULL);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
if (!simple && (def_ccname = krb5_cc_default_name(context))) {
|
||||||
for (i = 0; i < context->num_cc_ops && context->cc_ops[i]->prefix; i++) {
|
for (i = 0; i < context->num_cc_ops && context->cc_ops[i]->prefix; i++) {
|
||||||
size_t prefix_len = strlen(context->cc_ops[i]->prefix);
|
size_t prefix_len = strlen(context->cc_ops[i]->prefix);
|
||||||
|
|
||||||
@@ -307,10 +284,17 @@ get_default_cc_type(krb5_context context, int simple)
|
|||||||
def_ccname[prefix_len] == ':')
|
def_ccname[prefix_len] == ':')
|
||||||
return context->cc_ops[i]->prefix;
|
return context->cc_ops[i]->prefix;
|
||||||
}
|
}
|
||||||
if (is_possible_path_name(def_ccname))
|
|
||||||
return "FILE";
|
|
||||||
}
|
}
|
||||||
return def_cctype ? def_cctype : "DIR";
|
if (!def_cctype && def_cccol) {
|
||||||
|
for (i = 0; i < context->num_cc_ops && context->cc_ops[i]->prefix; i++) {
|
||||||
|
size_t prefix_len = strlen(context->cc_ops[i]->prefix);
|
||||||
|
|
||||||
|
if (!strncmp(context->cc_ops[i]->prefix, def_cccol, prefix_len) &&
|
||||||
|
def_cccol[prefix_len] == ':')
|
||||||
|
return context->cc_ops[i]->prefix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return def_cctype ? def_cctype : "FILE";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,7 +342,7 @@ krb5_cc_resolve_sub(krb5_context context,
|
|||||||
|
|
||||||
if (!cctype) {
|
if (!cctype) {
|
||||||
const char *def_cctype = get_default_cc_type(context, 0);
|
const char *def_cctype = get_default_cc_type(context, 0);
|
||||||
int might_be_path = collection && is_possible_path_name(collection);
|
int might_be_path = collection != NULL;
|
||||||
|
|
||||||
if (def_cctype)
|
if (def_cctype)
|
||||||
cctype = def_cctype;
|
cctype = def_cctype;
|
||||||
@@ -453,6 +437,9 @@ krb5_cc_new_unique(krb5_context context, const char *type,
|
|||||||
const krb5_cc_ops *ops;
|
const krb5_cc_ops *ops;
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
|
|
||||||
|
if (type == NULL)
|
||||||
|
type = get_default_cc_type(context, 1);
|
||||||
|
|
||||||
ops = krb5_cc_get_prefix_ops(context, type);
|
ops = krb5_cc_get_prefix_ops(context, type);
|
||||||
if (ops == NULL) {
|
if (ops == NULL) {
|
||||||
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,
|
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,
|
||||||
|
@@ -779,9 +779,10 @@ dcc_get_default_name(krb5_context context, char **str)
|
|||||||
"libdefaults", "default_cc_collection",
|
"libdefaults", "default_cc_collection",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* What if def_cc_colname does not start with DIR:? We tolerate it. */
|
/* [libdefaults] default_cc_collection is for testing */
|
||||||
return _krb5_expand_default_cc_name(context, def_cc_colname,
|
if (strncmp(def_cc_colname, "DIR:", sizeof("DIR:") - 1))
|
||||||
str);
|
def_cc_colname = KRB5_DEFAULT_CCNAME_DIR;
|
||||||
|
return _krb5_expand_default_cc_name(context, def_cc_colname, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static krb5_error_code KRB5_CALLCONV
|
static krb5_error_code KRB5_CALLCONV
|
||||||
|
Reference in New Issue
Block a user