(gss_krb5_import_ccache): Instead of making a copy of the ccache, make

a reference by getting the name and resolving the name. This way the
cache is shared, this flipp side is of course that if someone calls
krb5_cc_destroy the cache is lost for everyone.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16267 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-10-31 16:02:08 +00:00
parent d4a3ad2adf
commit 4cc93f5d2e
2 changed files with 54 additions and 40 deletions

View File

@@ -108,37 +108,44 @@ gss_krb5_import_ccache(OM_uint32 *minor_status,
ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
&handle->mechanisms);
if (ret != GSS_S_COMPLETE) {
gssapi_krb5_set_error_string ();
krb5_free_principal(gssapi_krb5_context, handle->principal);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
}
kret = krb5_cc_gen_new(gssapi_krb5_context,
&krb5_mcc_ops,
&handle->ccache);
if (kret) {
gssapi_krb5_set_error_string ();
gss_release_oid_set(NULL, &handle->mechanisms);
krb5_free_principal(gssapi_krb5_context, handle->principal);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
{
const char *type, *name;
char *str;
type = krb5_cc_get_type(gssapi_krb5_context, in);
name = krb5_cc_get_name(gssapi_krb5_context, in);
if (asprintf(&str, "%s:%s", type, name) == -1) {
krb5_set_error_string(gssapi_krb5_context,
"malloc - out of memory");
kret = ENOMEM;
goto out;
}
kret = krb5_cc_resolve(gssapi_krb5_context, str, &handle->ccache);
free(str);
if (kret)
goto out;
}
kret = krb5_cc_copy_cache(gssapi_krb5_context, in, handle->ccache);
if (kret) {
gssapi_krb5_set_error_string ();
gss_release_oid_set(NULL, &handle->mechanisms);
krb5_free_principal(gssapi_krb5_context, handle->principal);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
}
*minor_status = 0;
*cred = handle;
return GSS_S_COMPLETE;
out:
gssapi_krb5_set_error_string ();
if (handle->principal)
krb5_free_principal(gssapi_krb5_context, handle->principal);
HEIMDAL_MUTEX_destroy(&handle->cred_id_mutex);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
}

View File

@@ -108,37 +108,44 @@ gss_krb5_import_ccache(OM_uint32 *minor_status,
ret = gss_add_oid_set_member(minor_status, GSS_KRB5_MECHANISM,
&handle->mechanisms);
if (ret != GSS_S_COMPLETE) {
gssapi_krb5_set_error_string ();
krb5_free_principal(gssapi_krb5_context, handle->principal);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
}
kret = krb5_cc_gen_new(gssapi_krb5_context,
&krb5_mcc_ops,
&handle->ccache);
if (kret) {
gssapi_krb5_set_error_string ();
gss_release_oid_set(NULL, &handle->mechanisms);
krb5_free_principal(gssapi_krb5_context, handle->principal);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
{
const char *type, *name;
char *str;
type = krb5_cc_get_type(gssapi_krb5_context, in);
name = krb5_cc_get_name(gssapi_krb5_context, in);
if (asprintf(&str, "%s:%s", type, name) == -1) {
krb5_set_error_string(gssapi_krb5_context,
"malloc - out of memory");
kret = ENOMEM;
goto out;
}
kret = krb5_cc_resolve(gssapi_krb5_context, str, &handle->ccache);
free(str);
if (kret)
goto out;
}
kret = krb5_cc_copy_cache(gssapi_krb5_context, in, handle->ccache);
if (kret) {
gssapi_krb5_set_error_string ();
gss_release_oid_set(NULL, &handle->mechanisms);
krb5_free_principal(gssapi_krb5_context, handle->principal);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
}
*minor_status = 0;
*cred = handle;
return GSS_S_COMPLETE;
out:
gssapi_krb5_set_error_string ();
if (handle->principal)
krb5_free_principal(gssapi_krb5_context, handle->principal);
HEIMDAL_MUTEX_destroy(&handle->cred_id_mutex);
free(handle);
*minor_status = kret;
return GSS_S_FAILURE;
}