From 1d29c70a8c63bd534baa941c103de84b62a608e8 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 19 Nov 2004 22:12:50 +0000 Subject: [PATCH] * locate_kdc.c (krb5int_add_host_to_list): If debugging, log the requested family and socket type. If AI_NUMERICSERV is defined, set it in ai_flags. If getaddrinfo returns an error with debugging enabled, log the error. (krb5_locate_srv_conf_1): When logging an error from add_host_to_list, include the corresponding error string. * t_locate_kdc.c: Include port-sockets.h, instead of sys/socket.h, netdb.h, netinet/in.h, and arpa/inet.h. * Makefile.in ($(OUTPRE)t_locate_kdc.exe): New target. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16899 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 13 +++++++++++++ src/lib/krb5/os/Makefile.in | 4 ++++ src/lib/krb5/os/locate_kdc.c | 19 ++++++++++++++----- src/lib/krb5/os/t_locate_kdc.c | 6 +----- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index ea1a5a757..be64fbe79 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,16 @@ +2004-11-19 Ken Raeburn + + * locate_kdc.c (krb5int_add_host_to_list): If debugging, log the + requested family and socket type. If AI_NUMERICSERV is defined, + set it in ai_flags. If getaddrinfo returns an error with + debugging enabled, log the error. + (krb5_locate_srv_conf_1): When logging an error from + add_host_to_list, include the corresponding error string. + + * t_locate_kdc.c: Include port-sockets.h, instead of sys/socket.h, + netdb.h, netinet/in.h, and arpa/inet.h. + * Makefile.in ($(OUTPRE)t_locate_kdc.exe): New target. + 2004-10-20 Ken Raeburn * locate_kdc.c: Include stdarg.h. diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in index 5bbd25b60..1becee6f0 100644 --- a/src/lib/krb5/os/Makefile.in +++ b/src/lib/krb5/os/Makefile.in @@ -185,6 +185,10 @@ t_locate_kdc: t_locate_kdc.o $(CC_LINK) $(ALL_CFLAGS) -o t_locate_kdc t_locate_kdc.o \ $(KRB5_BASE_LIBS) t_locate_kdc.o: t_locate_kdc.c locate_kdc.c +$(OUTPRE)t_locate_kdc.exe: $(OUTPRE)t_locate_kdc.obj \ + $(OUTPRE)dnssrv.obj $(OUTPRE)dnsglue.obj \ + $(KLIB) $(PLIB) $(CLIB) $(SLIB) + link $(EXE_LINKOPTS) -out:$@ $** ws2_32.lib $(DNSLIBS) LCLINT=lclint LCLINTOPTS= -warnposix \ diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 25334ddb9..dfc45cd23 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -260,17 +260,24 @@ krb5int_add_host_to_list (struct addrlist *lp, const char *hostname, int err; char portbuf[10], secportbuf[10]; - Tprintf ("adding hostname %s, ports %d,%d\n", hostname, - ntohs (port), ntohs (secport)); + Tprintf ("adding hostname %s, ports %d,%d, family %d, socktype %d\n", + hostname, ntohs (port), ntohs (secport), + family, socktype); memset(&hint, 0, sizeof(hint)); hint.ai_family = family; hint.ai_socktype = socktype; +#ifdef AI_NUMERICSERV + hint.ai_flags = AI_NUMERICSERV; +#endif sprintf(portbuf, "%d", ntohs(port)); sprintf(secportbuf, "%d", ntohs(secport)); err = getaddrinfo (hostname, portbuf, &hint, &addrs); - if (err) + if (err) { + Tprintf ("\tgetaddrinfo(\"%s\", \"%s\", ...)\n\treturns %d: %s\n", + hostname, portbuf, err, gai_strerror (err)); return translate_ai_error (err); + } anext = 0; for (a = addrs; a != 0 && err == 0; a = anext) { anext = a->ai_next; @@ -460,7 +467,8 @@ krb5_locate_srv_conf_1(krb5_context context, const krb5_data *realm, SOCK_STREAM, family); } if (code) { - Tprintf ("error %d returned from add_host_to_list\n", code); + Tprintf ("error %d (%s) returned from add_host_to_list\n", code, + error_message (code)); if (hostlist) profile_free_list (hostlist); if (masterlist) @@ -534,8 +542,9 @@ krb5_locate_srv_dns_1 (const krb5_data *realm, (strcmp("_tcp", protocol) ? SOCK_DGRAM : SOCK_STREAM), family); - if (code) + if (code) { break; + } if (entry == head) { free(entry->host); free(entry); diff --git a/src/lib/krb5/os/t_locate_kdc.c b/src/lib/krb5/os/t_locate_kdc.c index 03dac07ef..7d5d554fa 100644 --- a/src/lib/krb5/os/t_locate_kdc.c +++ b/src/lib/krb5/os/t_locate_kdc.c @@ -1,11 +1,7 @@ #include #include #include -#include -#include -#include -#include - +#include "port-sockets.h" #include #define TEST -- 2.26.2