heimdal: update to lorikeet-heimdal rev 801
[metze/samba/wip.git] / source / heimdal / lib / krb5 / krbhst.c
index 094fd4f9c64d9e88f596bbcdbf1526c25030f5f8..3514a026b74baa41d20329bb291c9d153674fc4d 100644 (file)
@@ -35,7 +35,7 @@
 #include <resolve.h>
 #include "locate_plugin.h"
 
-RCSID("$Id: krbhst.c 21457 2007-07-10 12:53:25Z lha $");
+RCSID("$Id: krbhst.c 23447 2008-07-27 12:09:05Z lha $");
 
 static int
 string_to_proto(const char *string)
@@ -72,7 +72,8 @@ srv_find_realm(krb5_context context, krb5_krbhst_info ***res, int *count,
 
     proto_num = string_to_proto(proto);
     if(proto_num < 0) {
-       krb5_set_error_string(context, "unknown protocol `%s'", proto);
+       krb5_set_error_message(context, EINVAL,
+                              "unknown protocol `%s'", proto);
        return EINVAL;
     }
 
@@ -96,7 +97,7 @@ srv_find_realm(krb5_context context, krb5_krbhst_info ***res, int *count,
     *res = malloc(num_srv * sizeof(**res));
     if(*res == NULL) {
        dns_free_data(r);
-       krb5_set_error_string(context, "malloc: out of memory");
+       krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
        return ENOMEM;
     }
 
@@ -247,7 +248,7 @@ _krb5_krbhost_info_move(krb5_context context,
     /* trailing NUL is included in structure */
     *to = calloc(1, sizeof(**to) + hostnamelen); 
     if(*to == NULL) {
-       krb5_set_error_string(context, "malloc - out of memory");
+       krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
        return ENOMEM;
     }
 
@@ -522,7 +523,8 @@ plugin_get_hosts(krb5_context context,
     struct krb5_plugin *list = NULL, *e;
     krb5_error_code ret;
 
-    ret = _krb5_plugin_find(context, PLUGIN_TYPE_DATA, "resolve", &list);
+    ret = _krb5_plugin_find(context, PLUGIN_TYPE_DATA,
+                           KRB5_PLUGIN_LOCATE, &list);
     if(ret != 0 || list == NULL)
        return;
 
@@ -539,8 +541,9 @@ plugin_get_hosts(krb5_context context,
        (*service->init)(context, &ctx);
        ret = (*service->lookup)(ctx, type, kd->realm, 0, 0, add_locate, kd);
        (*service->fini)(ctx);
-       if (ret) {
-           krb5_set_error_string(context, "Plugin failed to lookup");
+       if (ret && ret != KRB5_PLUGIN_NO_HANDLE) {
+           krb5_set_error_message(context, ret, 
+                                  "Locate plugin failed to lookup: %d", ret);
            break;
        }
     }
@@ -832,7 +835,7 @@ krb5_krbhst_init_flags(krb5_context context,
        def_port = ntohs(krb5_getportbyname (context, "krb524", "udp", 4444));
        break;
     default:
-       krb5_set_error_string(context, "unknown krbhst type (%u)", type);
+       krb5_set_error_message(context, ENOTTY, "unknown krbhst type (%u)", type);
        return ENOTTY;
     }
     if((kd = common_init(context, realm, flags)) == NULL)
@@ -920,7 +923,8 @@ gethostlist(krb5_context context, const char *realm,
     while(krb5_krbhst_next(context, handle, &hostinfo) == 0)
        nhost++;
     if(nhost == 0) {
-       krb5_set_error_string(context, "No KDC found for realm %s", realm);
+       krb5_set_error_message(context, KRB5_KDC_UNREACH, 
+                              "No KDC found for realm %s", realm);
        return KRB5_KDC_UNREACH;
     }
     *hostlist = calloc(nhost + 1, sizeof(**hostlist));