From: Theodore Tso Date: Tue, 29 Sep 1992 13:59:28 +0000 (+0000) Subject: Added support for secondary Kerberos port X-Git-Tag: krb5-1.0-beta2~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=738e8ef49a6d36c863a88a30a971af4edc85a542;p=krb5.git Added support for secondary Kerberos port git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2427 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index ee42fb049..a79620638 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -47,6 +47,7 @@ static char rcsid_locate_kdc_c[] = #ifdef KRB5_USE_INET extern char *krb5_kdc_udp_portname; +extern char *krb5_kdc_sec_udp_portname; #endif /* @@ -68,6 +69,7 @@ krb5_locate_kdc(realm, addr_pp, naddrs) struct servent *sp; #ifdef KRB5_USE_INET u_short udpport = 0; /* 0 is an invalid UDP port #. */ + u_short sec_udpport = 0; /* 0 is an invalid UDP port #. */ #endif hostlist = 0; @@ -78,16 +80,30 @@ krb5_locate_kdc(realm, addr_pp, naddrs) #ifdef KRB5_USE_INET if (sp = getservbyname(krb5_kdc_udp_portname, "udp")) udpport = sp->s_port; + if (krb5_kdc_sec_udp_portname) + if (sp = getservbyname(krb5_kdc_sec_udp_portname, "udp")) { +#ifdef KRB5_TRY_SECONDARY_PORT_FIRST + sec_udpport = udpport; + udpport = sp->s_port; +#else + sec_udpport = sp->s_port; +#endif + } #endif - for (i=0; hostlist[i]; i++) - ; - count = i; + count = 0; + while (hostlist[count]) + count++; if (count == 0) { *naddrs = 0; return 0; } + +#ifdef KRB5_USE_INET + if (sec_udpport) + count = count * 2; +#endif addr_p = (struct sockaddr *)malloc (sizeof (struct sockaddr) * count); @@ -112,6 +128,17 @@ krb5_locate_kdc(realm, addr_pp, naddrs) realloc ((char *)addr_p, sizeof(struct sockaddr) * count); } + if (sec_udpport) { + addr_p[out] = addr_p[out-1]; + sin_p = (struct sockaddr_in *) &addr_p[out++]; + sin_p->sin_port = sec_udpport; + if (out >= count) { + count *= 2; + addr_p = (struct sockaddr *) + realloc ((char *)addr_p, + sizeof(struct sockaddr) * count); + } + } } break; #endif