Reimplement GSS_KRB5_COPY_CCACHE_X to instead pass a fullname to the
credential, then resolve and copy out the content, and then close the cred. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17728 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -37,52 +37,55 @@ gss_krb5_copy_ccache(OM_uint32 *minor_status,
|
|||||||
gss_cred_id_t cred,
|
gss_cred_id_t cred,
|
||||||
krb5_ccache out)
|
krb5_ccache out)
|
||||||
{
|
{
|
||||||
krb5_context context;
|
|
||||||
OM_uint32 ret;
|
|
||||||
krb5_error_code kret;
|
|
||||||
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
|
gss_buffer_set_t data_set = GSS_C_NO_BUFFER_SET;
|
||||||
const char *prefix;
|
krb5_context context;
|
||||||
|
krb5_error_code kret;
|
||||||
|
krb5_ccache id;
|
||||||
|
OM_uint32 ret;
|
||||||
|
char *str;
|
||||||
|
|
||||||
ret = gss_inquire_cred_by_oid(minor_status,
|
ret = gss_inquire_cred_by_oid(minor_status,
|
||||||
cred,
|
cred,
|
||||||
GSS_KRB5_COPY_CCACHE_X,
|
GSS_KRB5_COPY_CCACHE_X,
|
||||||
&data_set);
|
&data_set);
|
||||||
if (ret) {
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
if (data_set == GSS_C_NO_BUFFER_SET ||
|
if (data_set == GSS_C_NO_BUFFER_SET || data_set->count != 1) {
|
||||||
data_set->count != 2) {
|
|
||||||
gss_release_buffer_set(minor_status, &data_set);
|
gss_release_buffer_set(minor_status, &data_set);
|
||||||
*minor_status = EINVAL;
|
*minor_status = EINVAL;
|
||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix = (const char *)data_set->elements[0].value;
|
|
||||||
|
|
||||||
kret = krb5_init_context(&context);
|
kret = krb5_init_context(&context);
|
||||||
if (out->ops == NULL) {
|
if (kret) {
|
||||||
*minor_status = ENOENT;
|
*minor_status = kret;
|
||||||
gss_release_buffer_set(minor_status, &data_set);
|
gss_release_buffer_set(minor_status, &data_set);
|
||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
out->ops = krb5_cc_get_prefix_ops(context, prefix);
|
kret = asprintf(&str, "%.*s", (int)data_set->elements[0].length,
|
||||||
krb5_free_context(context);
|
(char *)data_set->elements[0].value);
|
||||||
if (out->ops == NULL) {
|
|
||||||
*minor_status = ENOENT;
|
|
||||||
gss_release_buffer_set(minor_status, &data_set);
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
out->data.data = data_set->elements[1].value;
|
|
||||||
out->data.length = data_set->elements[1].length;
|
|
||||||
data_set->elements[1].value = NULL;
|
|
||||||
data_set->elements[1].length = 0;
|
|
||||||
|
|
||||||
data_set->count--;
|
|
||||||
|
|
||||||
gss_release_buffer_set(minor_status, &data_set);
|
gss_release_buffer_set(minor_status, &data_set);
|
||||||
|
if (kret == -1) {
|
||||||
|
*minor_status = ENOMEM;
|
||||||
|
return GSS_S_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
kret = krb5_cc_resolve(context, str, &id);
|
||||||
|
free(str);
|
||||||
|
if (kret) {
|
||||||
|
*minor_status = kret;
|
||||||
|
return GSS_S_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
kret = krb5_cc_copy_cache(context, id, out);
|
||||||
|
krb5_cc_close(context, id);
|
||||||
|
krb5_free_context(context);
|
||||||
|
if (kret) {
|
||||||
|
*minor_status = kret;
|
||||||
|
return GSS_S_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user