From 825128ac38f51df74659c43b70369814a1ae2eff Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 23 Jul 1999 03:24:30 +0000 Subject: [PATCH] Add profile support for libdefaults dns_fallback git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11589 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/locate_kdc.c | 93 +++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 6666426e0..ee81f6c08 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -545,56 +545,73 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs, master_index, nmasters) * We always try the local file first */ - code = krb5_locate_srv_conf(context, realm, "kdc", addr_pp, naddrs, + code = krb5_locate_srv_conf(context, realm, "kdc", addr_pp, naddrs, master_index, nmasters); #ifdef KRB5_DNS_LOOKUP if (code) { - code = krb5_locate_srv_dns(realm, "_kerberos", "_udp", - addr_pp, naddrs); - if ( master_index && nmasters ) { - - code = krb5_locate_srv_dns(realm, "_kerberos-adm", "_tcp", - &admin_addr_p, &nadmin_addrs); - if ( code ) { - free(*addr_pp); - *addr_pp = NULL; + int use_dns=0; + char * string=NULL; + krb5_error_code code2; /* preserve error code from krb5_locate_srv_conf */ + + code2 = profile_get_string(context->profile, "libdefaults", + "dns_fallback", 0, + context->profile_in_memory?"1":"0", + &string); + if ( code2 ) + return(code2); + + if ( string ) { + use_dns = krb5_conf_boolean(string); + free(string); + } + if ( use_dns ) { + code = krb5_locate_srv_dns(realm, "_kerberos", "_udp", + addr_pp, naddrs); + if ( master_index && nmasters ) { + + code = krb5_locate_srv_dns(realm, "_kerberos-adm", "_tcp", + &admin_addr_p, &nadmin_addrs); + if ( code ) { + free(*addr_pp); + *addr_pp = NULL; + *naddrs = 0; + return(code); + } + + kdc_addr_p = *addr_pp; + nkdc_addrs = *naddrs; + *naddrs = 0; - return(code); - } + *addr_pp = (struct sockaddr *) malloc(sizeof(*kdc_addr_p)); + if ( *addr_pp == NULL ) { + free(kdc_addr_p); + free(admin_addr_p); + return ENOMEM; + } - kdc_addr_p = *addr_pp; - nkdc_addrs = *naddrs; + for ( i=0; i