X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=set_cred_option.c;h=b42dd80be0162fe95335d573ea85b77c1b8da218;hb=6fd9f5a521f9efa7cb9dd43f90ae8f33c83c66e1;hp=09dac65e3848d177c5a595e94b39fcb57929a5f5;hpb=2726871e0ab92938b385d2a1e6deef44ecb208b8;p=mech_eap.orig diff --git a/set_cred_option.c b/set_cred_option.c index 09dac65..b42dd80 100644 --- a/set_cred_option.c +++ b/set_cred_option.c @@ -32,13 +32,117 @@ #include "gssapiP_eap.h" -#if 0 +static OM_uint32 +setCredRadiusConfig(OM_uint32 *minor, + gss_cred_id_t cred, + const gss_OID oid, + const gss_buffer_t buffer) +{ + OM_uint32 major; + gss_buffer_desc configFileBuffer = GSS_C_EMPTY_BUFFER; + + if (buffer != GSS_C_NO_BUFFER && buffer->length != 0) { + major = duplicateBuffer(minor, buffer, &configFileBuffer); + if (GSS_ERROR(major)) + return major; + } + + if (cred->radiusConfigFile != NULL) + free(cred->radiusConfigFile); + + cred->radiusConfigFile = (char *)configFileBuffer.value; + + *minor = 0; + return GSS_S_COMPLETE; +} + +static OM_uint32 +setCredFlag(OM_uint32 *minor, + gss_cred_id_t cred, + const gss_OID oid, + const gss_buffer_t buffer) +{ + OM_uint32 flags; + unsigned char *p; + + if (buffer == GSS_C_NO_BUFFER || buffer->length < 4) { + *minor = EINVAL; + return GSS_S_FAILURE; + } + + p = (unsigned char *)buffer->value; + + flags = load_uint32_be(buffer->value) & CRED_FLAG_PUBLIC_MASK; + + if (buffer->length > 4 && p[4]) + cred->flags &= ~(flags); + else + cred->flags |= flags; + + *minor = 0; + return GSS_S_COMPLETE; +} + +static struct { + gss_OID_desc oid; + OM_uint32 (*setOption)(OM_uint32 *, gss_cred_id_t cred, + const gss_OID, const gss_buffer_t); +} setCredOps[] = { + /* 1.3.6.1.4.1.5322.21.3.3.1 */ + { + { 11, "\x2B\x06\x01\x04\x01\xA9\x4A\x15\x03\x03\x01" }, + setCredRadiusConfig, + }, + /* 1.3.6.1.4.1.5322.21.3.3.2 */ + { + { 11, "\x2B\x06\x01\x04\x01\xA9\x4A\x15\x03\x03\x02" }, + setCredFlag, + }, +}; + +gss_OID GSS_EAP_CRED_SET_RADIUS_CONFIG = &setCredOps[0].oid; +gss_OID GSS_EAP_CRED_SET_CRED_FLAG = &setCredOps[1].oid; + OM_uint32 gssspi_set_cred_option(OM_uint32 *minor, - gss_cred_id_t cred, + gss_cred_id_t *cred, const gss_OID desired_object, const gss_buffer_t value) { - GSSEAP_NOT_IMPLEMENTED; + OM_uint32 major = GSS_S_UNAVAILABLE; + int i; + + if (*cred == GSS_C_NO_CREDENTIAL) + return GSS_S_UNAVAILABLE; + + for (i = 0; i < sizeof(setCredOps) / sizeof(setCredOps[0]); i++) { + if (oidEqual(&setCredOps[i].oid, desired_object)) { + major = (*setCredOps[i].setOption)(minor, *cred, + desired_object, value); + break; + } + } + + return major; +} + +#if 0 +OM_uint32 +gsseap_set_cred_flag(OM_uint32 *minor, + gss_cred_id_t cred, + OM_uint32 flag, + int clear) +{ + unsigned char buf[5]; + gss_buffer_desc value; + + value.length = sizeof(buf); + value.value = buf; + + store_uint32_be(flag, buf); + buf[4] = (clear != 0); + + return gssspi_set_cred_option(minor, cred, + GSS_EAP_CRED_SET_CRED_FLAG, &value); } #endif