return GSS_S_COMPLETE;
}
-static krb5_error_code
-gssEapGetDefaultRealm(krb5_context krbContext, char **defaultRealm)
+static char *
+gssEapGetDefaultRealm(krb5_context krbContext)
{
- *defaultRealm = NULL;
+ char *defaultRealm = NULL;
krb5_appdefault_string(krbContext, "eap_gss",
- NULL, "default_realm", "", defaultRealm);
+ NULL, "default_realm", "", &defaultRealm);
- if (*defaultRealm != NULL && (*defaultRealm)[0] == '\0') {
- GSSEAP_FREE(*defaultRealm);
- *defaultRealm = NULL;
- }
-
- return (*defaultRealm != NULL) ? 0 : KRB5_CONFIG_NODEFREALM;
+ return defaultRealm;
}
static OM_uint32
host++;
}
- gssEapGetDefaultRealm(krbContext, &realm);
+ realm = gssEapGetDefaultRealm(krbContext);
code = krb5_build_principal(krbContext,
&krbPrinc,
/*
* Import an EAP name, possibly appending the default GSS EAP realm,
- * and taking care to avoid appending the default Kerberos realm.
*/
static OM_uint32
importEapNameFlags(OM_uint32 *minor,
/*
* First, attempt to parse the name on the assumption that it includes
- * a qualifying realm.
+ * a qualifying realm. This allows us to avoid accidentally appending
+ * the default Kerberos realm to an unqualified name. (A bug in MIT
+ * Kerberos prevents the default realm being set to an empty value.)
*/
code = krb5_parse_name_flags(krbContext, nameString,
KRB5_PRINCIPAL_PARSE_REQUIRE_REALM, &krbPrinc);
char *defaultRealm = NULL;
int parseFlags = 0;
- /*
- * We need an explicit appdefaults check because, at least with MIT
- * Kerberos, setting the context realm to NULL will reset it to the
- * default Kerberos realm after the second call to get_default_realm.
- * We want to make sure that the default Kerberos realm does not end
- * up accidentally appended to an unqualified name.
- */
+ /* Possibly append the default EAP realm if required */
if (importFlags & IMPORT_FLAG_DEFAULT_REALM)
- gssEapGetDefaultRealm(krbContext, &defaultRealm);
+ defaultRealm = gssEapGetDefaultRealm(krbContext);
- if (defaultRealm == NULL)
+ /* If no default realm, leave the realm empty in the parsed name */
+ if (defaultRealm == NULL || defaultRealm[0] == '\0')
parseFlags |= KRB5_PRINCIPAL_PARSE_NO_REALM;
code = krb5_parse_name_flags(krbContext, nameString, parseFlags, &krbPrinc);
+#ifdef HAVE_HEIMDAL_VERSION
+ if (code == 0 && KRB_PRINC_REALM(krbPrinc) == NULL) {
+ KRB_PRINC_REALM(krbPrinc) = GSSEAP_CALLOC(1, sizeof(char));
+ if (KRB_PRINC_REALM(krbPrinc) == NULL)
+ code = ENOMEM;
+ }
+#endif
+
if (defaultRealm != NULL)
GSSEAP_FREE(defaultRealm);
}
*/
#ifdef HAVE_HEIMDAL_VERSION
if (KRB_PRINC_REALM(name->krbPrincipal) == NULL ||
- KRB_PRINC_REALM(name->krBPrincipal)[0] == '\0')
+ KRB_PRINC_REALM(name->krbPrincipal)[0] == '\0')
#else
if (KRB_PRINC_REALM(name->krbPrincipal)->length == 0)
#endif
return GSS_S_COMPLETE;
}
+
+OM_uint32
+gssEapCompareName(OM_uint32 *minor,
+ gss_name_t name1,
+ gss_name_t name2,
+ int *name_equal)
+{
+ krb5_context krbContext;
+
+ *minor = 0;
+
+ if (name1 == GSS_C_NO_NAME && name2 == GSS_C_NO_NAME) {
+ *name_equal = 1;
+ } else if (name1 != GSS_C_NO_NAME && name2 != GSS_C_NO_NAME) {
+ GSSEAP_KRB_INIT(&krbContext);
+
+ /* krbPrincipal is immutable, so lock not required */
+ *name_equal = krb5_principal_compare(krbContext,
+ name1->krbPrincipal,
+ name2->krbPrincipal);
+ }
+
+ return GSS_S_COMPLETE;
+}