(gss_set_cred_option): support the case where *cred_handle == NULL
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17735 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -39,19 +39,55 @@ gss_set_cred_option (OM_uint32 *minor_status,
|
|||||||
const gss_OID object,
|
const gss_OID object,
|
||||||
const gss_buffer_t value)
|
const gss_buffer_t value)
|
||||||
{
|
{
|
||||||
struct _gss_cred *cred = (struct _gss_cred *) cred_handle;
|
struct _gss_cred *cred = (struct _gss_cred *) *cred_handle;
|
||||||
OM_uint32 major_status = GSS_S_COMPLETE;
|
OM_uint32 major_status = GSS_S_COMPLETE;
|
||||||
struct _gss_mechanism_cred *mc;
|
struct _gss_mechanism_cred *mc;
|
||||||
gssapi_mech_interface m;
|
|
||||||
int one_ok = 0;
|
int one_ok = 0;
|
||||||
|
|
||||||
*minor_status = 0;
|
*minor_status = 0;
|
||||||
|
|
||||||
|
if (cred == NULL) {
|
||||||
|
struct _gss_mech_switch *m;
|
||||||
|
|
||||||
|
cred = malloc(sizeof(*cred));
|
||||||
if (cred == NULL)
|
if (cred == NULL)
|
||||||
return GSS_S_NO_CRED;
|
return GSS_S_FAILURE;
|
||||||
|
|
||||||
|
cred->gc_usage = GSS_C_BOTH; /* XXX */
|
||||||
|
SLIST_INIT(&cred->gc_mc);
|
||||||
|
|
||||||
|
SLIST_FOREACH(m, &_gss_mechs, gm_link) {
|
||||||
|
|
||||||
|
if (m->gm_mech.gm_set_cred_option == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mc = malloc(sizeof(*mc));
|
||||||
|
if (mc == NULL) {
|
||||||
|
/* XXX free the other mc's */
|
||||||
|
return GSS_S_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
mc->gmc_mech = &m->gm_mech;
|
||||||
|
mc->gmc_mech_oid = &m->gm_mech_oid;
|
||||||
|
mc->gmc_cred = GSS_C_NO_CREDENTIAL;
|
||||||
|
|
||||||
|
major_status = m->gm_mech.gm_set_cred_option(minor_status,
|
||||||
|
&mc->gmc_cred, object, value);
|
||||||
|
|
||||||
|
if (major_status) {
|
||||||
|
free(mc);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
one_ok = 1;
|
||||||
|
SLIST_INSERT_HEAD(&cred->gc_mc, mc, gmc_link);
|
||||||
|
}
|
||||||
|
if (one_ok)
|
||||||
|
*cred_handle = (gss_cred_id_t)cred;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
gssapi_mech_interface m;
|
||||||
|
|
||||||
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
|
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
|
||||||
|
|
||||||
m = mc->gmc_mech;
|
m = mc->gmc_mech;
|
||||||
|
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
@@ -65,6 +101,7 @@ gss_set_cred_option (OM_uint32 *minor_status,
|
|||||||
if (major_status == GSS_S_BAD_MECH)
|
if (major_status == GSS_S_BAD_MECH)
|
||||||
one_ok = 1;
|
one_ok = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (one_ok) {
|
if (one_ok) {
|
||||||
*minor_status = 0;
|
*minor_status = 0;
|
||||||
return GSS_S_COMPLETE;
|
return GSS_S_COMPLETE;
|
||||||
|
Reference in New Issue
Block a user