From f16f8a03176fdace1509c546eb8783b737c95436 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Wed, 17 Oct 2001 22:29:52 +0000 Subject: [PATCH] * locate_kdc.c (add_host_to_list): If sa_len field exists and is zero, try to fill it in. Another AIX 4.3.3 bug workaround. * sendto_kdc.c (krb5_sendto_kdc) [DEBUG]: More fprintf calls for tracing. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13816 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 8 +++++++ src/lib/krb5/os/locate_kdc.c | 18 +++++++++++++- src/lib/krb5/os/sendto_kdc.c | 46 ++++++++++++++++++++++++++++++++---- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 183cd6a63..fdb247c6e 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,11 @@ +2001-10-17 Ken Raeburn + + * locate_kdc.c (add_host_to_list): If sa_len field exists and is + zero, try to fill it in. Another AIX 4.3.3 bug workaround. + + * sendto_kdc.c (krb5_sendto_kdc) [DEBUG]: More fprintf calls for + tracing through. + 2001-10-10 Ezra Peisach * localaddr.c (krb5_os_localaddr_profile): Cast argument to diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 9908bae68..0d619d2ff 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -279,9 +279,25 @@ add_host_to_list (struct addrlist *lp, const char *hostname, if (err) return translate_ai_error (err); for (a = addrs; a; a = a->ai_next) { - /* AIX 4.3.3 is broken. */ + /* AIX 4.3.3 libc is broken. */ if (a->ai_addr->sa_family == 0) a->ai_addr->sa_family = a->ai_family; +#ifdef HAVE_SA_LEN + if (a->ai_addr->sa_len == 0) + switch (a->ai_addr->sa_family) { + case AF_INET: + a->ai_addr->sa_len = sizeof (struct sockaddr_in); + break; +#ifdef KRB5_USE_INET6 + case AF_INET6: + a->ai_addr->sa_len = sizeof (struct sockaddr_in6); + break; +#endif + default: + /* oh well, we lose */ + break; + } +#endif set_port_num (a->ai_addr, port); err = add_addrinfo_to_list (lp, a); diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c index 45e6d00b3..182d35ced 100644 --- a/src/lib/krb5/os/sendto_kdc.c +++ b/src/lib/krb5/os/sendto_kdc.c @@ -134,10 +134,32 @@ krb5_sendto_kdc (context, message, realm, reply, use_master) * protocol exists to support a particular socket type * within a given protocol family. */ +#ifdef DEBUG + fprintf (stderr, "getting dgram socket in family %d...", + addrs.addrs[host]->sa_family); +#endif socklist[host] = socket(addrs.addrs[host]->sa_family, SOCK_DGRAM, 0); - if (socklist[host] == INVALID_SOCKET) + if (socklist[host] == INVALID_SOCKET) { +#ifdef DEBUG + perror ("socket"); + fprintf (stderr, "af was %d\n", addrs.addrs[host]->sa_family); +#endif continue; /* try other hosts */ + } +#ifdef DEBUG + { + char addrbuf[NI_MAXHOST], portbuf[NI_MAXSERV]; + if (0 != getnameinfo (addrs.addrs[host], + socklen (addrs.addrs[host]), + addrbuf, sizeof (addrbuf), + portbuf, sizeof (portbuf), + NI_NUMERICHOST | NI_NUMERICSERV)) + strcpy (addrbuf, "??"), strcpy (portbuf, "??"); + fprintf (stderr, " fd %d; connecting to %s port %s...", + socklist[host], addrbuf, portbuf); + } +#endif /* have a socket to send/recv from */ /* On BSD systems, a connected UDP socket will get connection refused and net unreachable errors while an unconnected @@ -145,13 +167,27 @@ krb5_sendto_kdc (context, message, realm, reply, use_master) sendto, recvfrom. The connect here may return an error if the destination host is known to be unreachable. */ if (connect(socklist[host], - addrs.addrs[host], socklen(addrs.addrs[host])) == SOCKET_ERROR) - continue; + addrs.addrs[host], socklen(addrs.addrs[host])) == SOCKET_ERROR) { +#ifdef DEBUG + perror ("connect"); +#endif + continue; + } } +#ifdef DEBUG + fprintf (stderr, "sending..."); +#endif if (send(socklist[host], message->data, (int) message->length, 0) - != message->length) - continue; + != message->length) { +#ifdef DEBUG + perror ("sendto"); +#endif + continue; + } +#ifdef DEBUG + fprintf (stderr, "\n"); +#endif retry: waitlen.tv_usec = 0; waitlen.tv_sec = timeout; -- 2.26.2