From 42f2519b507bcb70157039a390529bf4b5df4d9c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 21 Sep 2005 10:17:56 +0000 Subject: r10382: In the absence of client support for the full KDC-side canonicalisation code, I've hacked Heimdal to use the default realm if no other realm can be determined for a given host. Andrew Bartlett (This used to be commit 0f0b0021b7728ce75ca0060003a3d08264ead810) --- source4/heimdal/lib/krb5/get_host_realm.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'source4/heimdal') diff --git a/source4/heimdal/lib/krb5/get_host_realm.c b/source4/heimdal/lib/krb5/get_host_realm.c index feb01f0036..78684f20a9 100644 --- a/source4/heimdal/lib/krb5/get_host_realm.c +++ b/source4/heimdal/lib/krb5/get_host_realm.c @@ -187,15 +187,18 @@ _krb5_get_host_realm_int (krb5_context context, return 0; } } - p = strchr(host, '.'); - if(p != NULL) { - p++; - *realms = malloc(2 * sizeof(krb5_realm)); - if (*realms == NULL) { + + *realms = malloc(2 * sizeof(krb5_realm)); + if (*realms == NULL) { krb5_set_error_string(context, "malloc: out of memory"); return ENOMEM; - } + } + + (*realms)[1] = NULL; + p = strchr(host, '.'); + if(p != NULL) { + p++; (*realms)[0] = strdup(p); if((*realms)[0] == NULL) { free(*realms); @@ -203,11 +206,21 @@ _krb5_get_host_realm_int (krb5_context context, return ENOMEM; } strupr((*realms)[0]); - (*realms)[1] = NULL; - return 0; + } else { + krb5_error_code ret; + ret = krb5_get_default_realm(context, &(*realms)[0]); + if(ret) { + free(*realms); + krb5_set_error_string(context, "malloc: out of memory"); + return ENOMEM; + } + if((*realms)[0] == NULL) { + free(*realms); + krb5_set_error_string(context, "unable to find realm of host %s", host); + return KRB5_ERR_HOST_REALM_UNKNOWN; + } } - krb5_set_error_string(context, "unable to find realm of host %s", host); - return KRB5_ERR_HOST_REALM_UNKNOWN; + return 0; } /* -- cgit