(gss_inquire_cred): handle cred_handle beeing GSS_C_NO_CREDENTIAL and
use the default cred then. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12624 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -44,6 +44,7 @@ OM_uint32 gss_inquire_cred
|
|||||||
gss_OID_set * mechanisms
|
gss_OID_set * mechanisms
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
gss_cred_id_t cred;
|
||||||
OM_uint32 ret;
|
OM_uint32 ret;
|
||||||
|
|
||||||
*minor_status = 0;
|
*minor_status = 0;
|
||||||
@@ -54,61 +55,68 @@ OM_uint32 gss_inquire_cred
|
|||||||
*mechanisms = GSS_C_NO_OID_SET;
|
*mechanisms = GSS_C_NO_OID_SET;
|
||||||
|
|
||||||
if (cred_handle == GSS_C_NO_CREDENTIAL) {
|
if (cred_handle == GSS_C_NO_CREDENTIAL) {
|
||||||
return GSS_S_FAILURE;
|
ret = gss_acquire_cred(minor_status,
|
||||||
}
|
GSS_C_NO_NAME,
|
||||||
|
GSS_C_INDEFINITE,
|
||||||
|
GSS_C_NO_OID_SET,
|
||||||
|
GSS_C_BOTH,
|
||||||
|
&cred,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
} else
|
||||||
|
cred = (gss_cred_id_t)cred_handle;
|
||||||
|
|
||||||
HEIMDAL_MUTEX_lock(&cred_handle->cred_id_mutex);
|
HEIMDAL_MUTEX_lock(&cred->cred_id_mutex);
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
if (cred_handle->principal != NULL) {
|
if (cred->principal != NULL) {
|
||||||
ret = gss_duplicate_name(minor_status, cred_handle->principal,
|
ret = gss_duplicate_name(minor_status, cred->principal,
|
||||||
name);
|
name);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
} else if (cred->usage == GSS_C_ACCEPT) {
|
||||||
}
|
|
||||||
} else if (cred_handle->usage == GSS_C_ACCEPT) {
|
|
||||||
*minor_status = krb5_sname_to_principal(gssapi_krb5_context, NULL,
|
*minor_status = krb5_sname_to_principal(gssapi_krb5_context, NULL,
|
||||||
NULL, KRB5_NT_SRV_HST, name);
|
NULL, KRB5_NT_SRV_HST, name);
|
||||||
if (*minor_status) {
|
if (*minor_status) {
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
ret = GSS_S_FAILURE;
|
||||||
return GSS_S_FAILURE;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*minor_status = krb5_get_default_principal(gssapi_krb5_context,
|
*minor_status = krb5_get_default_principal(gssapi_krb5_context,
|
||||||
name);
|
name);
|
||||||
if (*minor_status) {
|
if (*minor_status) {
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
ret = GSS_S_FAILURE;
|
||||||
return GSS_S_FAILURE;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lifetime != NULL) {
|
if (lifetime != NULL) {
|
||||||
ret = gssapi_lifetime_left(minor_status,
|
ret = gssapi_lifetime_left(minor_status,
|
||||||
cred_handle->lifetime,
|
cred->lifetime,
|
||||||
lifetime);
|
lifetime);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cred_usage != NULL) {
|
|
||||||
*cred_usage = cred_handle->usage;
|
|
||||||
}
|
}
|
||||||
|
if (cred_usage != NULL)
|
||||||
|
*cred_usage = cred->usage;
|
||||||
|
|
||||||
if (mechanisms != NULL) {
|
if (mechanisms != NULL) {
|
||||||
ret = gss_create_empty_oid_set(minor_status, mechanisms);
|
ret = gss_create_empty_oid_set(minor_status, mechanisms);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = gss_add_oid_set_member(minor_status,
|
ret = gss_add_oid_set_member(minor_status,
|
||||||
&cred_handle->mechanisms->elements[0],
|
&cred->mechanisms->elements[0],
|
||||||
mechanisms);
|
mechanisms);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
ret = GSS_S_COMPLETE;
|
||||||
return GSS_S_COMPLETE;
|
out:
|
||||||
|
if (cred_handle == GSS_C_NO_CREDENTIAL)
|
||||||
|
ret = gss_release_cred(minor_status, &cred);
|
||||||
|
|
||||||
|
HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ OM_uint32 gss_inquire_cred
|
|||||||
gss_OID_set * mechanisms
|
gss_OID_set * mechanisms
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
gss_cred_id_t cred;
|
||||||
OM_uint32 ret;
|
OM_uint32 ret;
|
||||||
|
|
||||||
*minor_status = 0;
|
*minor_status = 0;
|
||||||
@@ -54,61 +55,68 @@ OM_uint32 gss_inquire_cred
|
|||||||
*mechanisms = GSS_C_NO_OID_SET;
|
*mechanisms = GSS_C_NO_OID_SET;
|
||||||
|
|
||||||
if (cred_handle == GSS_C_NO_CREDENTIAL) {
|
if (cred_handle == GSS_C_NO_CREDENTIAL) {
|
||||||
return GSS_S_FAILURE;
|
ret = gss_acquire_cred(minor_status,
|
||||||
}
|
GSS_C_NO_NAME,
|
||||||
|
GSS_C_INDEFINITE,
|
||||||
|
GSS_C_NO_OID_SET,
|
||||||
|
GSS_C_BOTH,
|
||||||
|
&cred,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
} else
|
||||||
|
cred = (gss_cred_id_t)cred_handle;
|
||||||
|
|
||||||
HEIMDAL_MUTEX_lock(&cred_handle->cred_id_mutex);
|
HEIMDAL_MUTEX_lock(&cred->cred_id_mutex);
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
if (cred_handle->principal != NULL) {
|
if (cred->principal != NULL) {
|
||||||
ret = gss_duplicate_name(minor_status, cred_handle->principal,
|
ret = gss_duplicate_name(minor_status, cred->principal,
|
||||||
name);
|
name);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
} else if (cred->usage == GSS_C_ACCEPT) {
|
||||||
}
|
|
||||||
} else if (cred_handle->usage == GSS_C_ACCEPT) {
|
|
||||||
*minor_status = krb5_sname_to_principal(gssapi_krb5_context, NULL,
|
*minor_status = krb5_sname_to_principal(gssapi_krb5_context, NULL,
|
||||||
NULL, KRB5_NT_SRV_HST, name);
|
NULL, KRB5_NT_SRV_HST, name);
|
||||||
if (*minor_status) {
|
if (*minor_status) {
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
ret = GSS_S_FAILURE;
|
||||||
return GSS_S_FAILURE;
|
goto out;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*minor_status = krb5_get_default_principal(gssapi_krb5_context,
|
*minor_status = krb5_get_default_principal(gssapi_krb5_context,
|
||||||
name);
|
name);
|
||||||
if (*minor_status) {
|
if (*minor_status) {
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
ret = GSS_S_FAILURE;
|
||||||
return GSS_S_FAILURE;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lifetime != NULL) {
|
if (lifetime != NULL) {
|
||||||
ret = gssapi_lifetime_left(minor_status,
|
ret = gssapi_lifetime_left(minor_status,
|
||||||
cred_handle->lifetime,
|
cred->lifetime,
|
||||||
lifetime);
|
lifetime);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cred_usage != NULL) {
|
|
||||||
*cred_usage = cred_handle->usage;
|
|
||||||
}
|
}
|
||||||
|
if (cred_usage != NULL)
|
||||||
|
*cred_usage = cred->usage;
|
||||||
|
|
||||||
if (mechanisms != NULL) {
|
if (mechanisms != NULL) {
|
||||||
ret = gss_create_empty_oid_set(minor_status, mechanisms);
|
ret = gss_create_empty_oid_set(minor_status, mechanisms);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = gss_add_oid_set_member(minor_status,
|
ret = gss_add_oid_set_member(minor_status,
|
||||||
&cred_handle->mechanisms->elements[0],
|
&cred->mechanisms->elements[0],
|
||||||
mechanisms);
|
mechanisms);
|
||||||
if (ret) {
|
if (ret)
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
goto out;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HEIMDAL_MUTEX_unlock(&cred_handle->cred_id_mutex);
|
ret = GSS_S_COMPLETE;
|
||||||
return GSS_S_COMPLETE;
|
out:
|
||||||
|
if (cred_handle == GSS_C_NO_CREDENTIAL)
|
||||||
|
ret = gss_release_cred(minor_status, &cred);
|
||||||
|
|
||||||
|
HEIMDAL_MUTEX_unlock(&cred->cred_id_mutex);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user