X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=util_krb.c;h=abc9e6190fb48f64f3458150a297f0c8613f62f6;hb=refs%2Fheads%2Fjson-name;hp=1a47cab1ead6f33cddb5aa6b388a910f9c77e5c9;hpb=aa40dd8de138c5a2fcd49023bb6ccac925735c0b;p=mech_eap.orig diff --git a/util_krb.c b/util_krb.c index 1a47cab..abc9e61 100644 --- a/util_krb.c +++ b/util_krb.c @@ -54,6 +54,40 @@ createKrbContextKey(void) GSSEAP_KEY_CREATE(&krbContextKey, destroyKrbContext); } +static krb5_error_code +initKrbContext(krb5_context *pKrbContext) +{ + krb5_context krbContext; + krb5_error_code code; + char *defaultRealm = NULL; + + *pKrbContext = NULL; + + code = krb5_init_context(&krbContext); + if (code != 0) + goto cleanup; + + krb5_appdefault_string(krbContext, "eap_gss", + NULL, "default_realm", "", &defaultRealm); + + if (defaultRealm != NULL && defaultRealm[0] != '\0') { + code = krb5_set_default_realm(krbContext, defaultRealm); + if (code != 0) + goto cleanup; + } + + *pKrbContext = krbContext; + +cleanup: + if (code != 0 && krbContext != NULL) + krb5_free_context(krbContext); + + if (defaultRealm != NULL) + GSSEAP_FREE(defaultRealm); + + return code; +} + OM_uint32 gssEapKerberosInit(OM_uint32 *minor, krb5_context *context) { @@ -63,7 +97,7 @@ gssEapKerberosInit(OM_uint32 *minor, krb5_context *context) *context = GSSEAP_GETSPECIFIC(krbContextKey); if (*context == NULL) { - *minor = krb5_init_context(context); + *minor = initKrbContext(context); if (*minor == 0) { if (GSSEAP_SETSPECIFIC(krbContextKey, *context) != 0) { *minor = errno; @@ -370,7 +404,12 @@ krbBlockSize(krb5_context krbContext, } krb5_error_code -krbEnctypeToString(krb5_context krbContext, +krbEnctypeToString( +#ifdef HAVE_HEIMDAL_VERSION + krb5_context krbContext, +#else + krb5_context krbContext GSSEAP_UNUSED, +#endif krb5_enctype enctype, const char *prefix, gss_buffer_t string)