diff options
Diffstat (limited to 'source4/heimdal/lib/krb5/get_host_realm.c')
-rw-r--r-- | source4/heimdal/lib/krb5/get_host_realm.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/source4/heimdal/lib/krb5/get_host_realm.c b/source4/heimdal/lib/krb5/get_host_realm.c index d9c5bd5dc1..feb01f0036 100644 --- a/source4/heimdal/lib/krb5/get_host_realm.c +++ b/source4/heimdal/lib/krb5/get_host_realm.c @@ -34,7 +34,7 @@ #include "krb5_locl.h" #include <resolve.h> -RCSID("$Id: get_host_realm.c,v 1.34 2005/04/19 18:52:51 lha Exp $"); +RCSID("$Id: get_host_realm.c,v 1.35 2005/08/23 08:14:02 lha Exp $"); /* To automagically find the correct realm of a host (without * [domain_realm] in krb5.conf) add a text record for your domain with @@ -94,30 +94,41 @@ dns_find_realm(krb5_context context, const char *domain, krb5_realm **realms) { - static char *default_labels[] = { "_kerberos", NULL }; + static const char *default_labels[] = { "_kerberos", NULL }; char dom[MAXHOSTNAMELEN]; struct dns_reply *r; - char **labels; + const char **labels; + char **config_labels; int i, ret; - labels = krb5_config_get_strings(context, NULL, "libdefaults", - "dns_lookup_realm_labels", NULL); - if(labels == NULL) + config_labels = krb5_config_get_strings(context, NULL, "libdefaults", + "dns_lookup_realm_labels", NULL); + if(config_labels != NULL) + labels = (const char **)config_labels; + else labels = default_labels; if(*domain == '.') domain++; for (i = 0; labels[i] != NULL; i++) { ret = snprintf(dom, sizeof(dom), "%s.%s.", labels[i], domain); - if(ret < 0 || ret >= sizeof(dom)) + if(ret < 0 || ret >= sizeof(dom)) { + if (config_labels) + krb5_config_free_strings(config_labels); return -1; + } r = dns_lookup(dom, "TXT"); if(r != NULL) { ret = copy_txt_to_realms (r->head, realms); dns_free_data(r); - if(ret == 0) + if(ret == 0) { + if (config_labels) + krb5_config_free_strings(config_labels); return 0; + } } } + if (config_labels) + krb5_config_free_strings(config_labels); return -1; } |