* locate_kdc.c (add_host_to_list): If sa_len field exists and is zero, try to
authorKen Raeburn <raeburn@mit.edu>
Wed, 17 Oct 2001 22:29:52 +0000 (22:29 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 17 Oct 2001 22:29:52 +0000 (22:29 +0000)
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
src/lib/krb5/os/locate_kdc.c
src/lib/krb5/os/sendto_kdc.c

index 183cd6a6379d360e7344e2fc20a6f9bbe4f94f25..fdb247c6ee24b452349fa3610b827a7d2ffbbb0a 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-17  Ken Raeburn  <raeburn@mit.edu>
+
+       * 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  <epeisach@mit.edu>
 
        * localaddr.c (krb5_os_localaddr_profile): Cast argument to
index 9908bae687b5af2ff049b3a28c89fbdeeac12fe5..0d619d2ff29bbbef243289e870224f2dd1bfd476 100644 (file)
@@ -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);
index 45e6d00b3c4e914e98070e364cd1dee5795ba870..182d35ced0da79dd1b30ccf23a1e56bdd891c486 100644 (file)
@@ -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;