Author: abartlet
Date: 2005-09-21 10:17:56 +0000 (Wed, 21 Sep 2005)
New Revision: 10382

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10382

Log:
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

Modified:
   branches/SAMBA_4_0/source/heimdal/lib/krb5/get_host_realm.c


Changeset:
Modified: branches/SAMBA_4_0/source/heimdal/lib/krb5/get_host_realm.c
===================================================================
--- branches/SAMBA_4_0/source/heimdal/lib/krb5/get_host_realm.c 2005-09-21 
09:27:17 UTC (rev 10381)
+++ branches/SAMBA_4_0/source/heimdal/lib/krb5/get_host_realm.c 2005-09-21 
10:17:56 UTC (rev 10382)
@@ -187,27 +187,40 @@
                return 0;
        }
     }
+
+    *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 = malloc(2 * sizeof(krb5_realm));
-       if (*realms == NULL) {
+       (*realms)[0] = strdup(p);
+       if((*realms)[0] == NULL) {
+           free(*realms);
            krb5_set_error_string(context, "malloc: out of memory");
            return ENOMEM;
        }
-
-       (*realms)[0] = strdup(p);
-       if((*realms)[0] == NULL) {
+       strupr((*realms)[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;
        }
-       strupr((*realms)[0]);
-       (*realms)[1] = NULL;
-       return 0;
+       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;
 }
 
 /*

Reply via email to