Received: from pch.mit.edu (PCH.MIT.EDU [18.7.21.90]) by krbdev.mit.edu (8.9.3p2) with ESMTP id PAA01697; Thu, 14 Jul 2005 15:43:14 -0400 (EDT) Received: from pch.mit.edu (pch.mit.edu [127.0.0.1]) by pch.mit.edu (8.12.8p2/8.12.8) with ESMTP id j6EJgZWn004333 for ; Thu, 14 Jul 2005 15:42:35 -0400 Received: from pacific-carrier-annex.mit.edu (PACIFIC-CARRIER-ANNEX.MIT.EDU [18.7.21.83]) by pch.mit.edu (8.12.8p2/8.12.8) with ESMTP id j6E61pWn009559 for ; Thu, 14 Jul 2005 02:01:52 -0400 Received: from porthos.spock.org (porthos.spock.org [204.97.176.45]) j6E61mus002221 for ; Thu, 14 Jul 2005 02:01:49 -0400 (EDT) Received: from porthos.spock.org (0@localhost [127.0.0.1]) EF600Q3T-B7F8823j6E61m8h050165F7T for ; Thu, 14 Jul 2005 02:01:48 -0400 (EDT) (envelope-from jon@porthos.spock.org) Received: (from jon@localhost) by porthos.spock.org (8.12.11/8.12.9/Submit) id j6E61mPM050164 for krb5-bugs@mit.edu; Thu, 14 Jul 2005 02:01:48 -0400 (EDT) (envelope-from jon) Date: Thu, 14 Jul 2005 02:01:48 -0400 From: Jonathan Chen To: krb5-bugs@mit.edu Message-Id: <20050714060148.GN58936@porthos.spock.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: telnet/1.1x X-Spam-Score: 0 X-Spam-Flag: NO X-Scanned-BY: MIMEDefang 2.42 X-Mailman-Approved-At: Thu, 14 Jul 2005 15:39:00 -0400 Subject: KRB 1.4.1 AIX 5.2 fixes X-Beenthere: krb5-bugs-incoming@mailman.mit.edu X-Mailman-Version: 2.1 Precedence: list Sender: krb5-bugs-incoming-bounces@PCH.mit.edu Errors-To: krb5-bugs-incoming-bounces@PCH.mit.edu X-RT-Original-Encoding: us-ascii Content-Length: 4734 Due to all the wonderful "features" of AIX, Kerberos doesn't work well on AIX 5.2. The following patch attempts to fix some of the issues: - the select() API in AIX is unusual. The 16 high bits of the first argument is special, so select(0x00010000, ...) doesn't work. Since 8*sizeof(fd_set) == 0x10000 is used as the first argument in serveral places, things break. - AIX loves to return a sockaddr_in6 structure when you getpeername() on an inet4 socket. However, special error-checking "features" will throw back an error if you pass that sockaddr_in6 structure back to connect(). I love AIX. - fake-addrinfo isn't needed for AIX 5.1+ Also, please note RT Ticket# 2902 that resolves crashes on res_ninit(). All of the problems should be present in krb5-1.4-current as well, and all the problems except the fake-addrinfo should also be in krb5-current. Without further ado, here's the useful part: diff -ru krb5-1.4.1.orig/src/appl/bsd/krlogin.c krb5-1.4.1/src/appl/bsd/krlogin.c --- krb5-1.4.1.orig/src/appl/bsd/krlogin.c 2003-05-09 20:00:58.000000000 -0400 +++ krb5-1.4.1/src/appl/bsd/krlogin.c 2005-07-14 01:39:27.000000000 -0400 @@ -1101,7 +1101,7 @@ for (;;) { FD_ZERO(&waitread); FD_SET(0, &waitread); - n = select(8*sizeof(waitread), &waitread, 0, 0, 0, 0); + n = select(1, &waitread, 0, 0, 0, 0); if (n < 0 && errno == EINTR) continue; if (n > 0) diff -ru krb5-1.4.1.orig/src/appl/bsd/krlogind.c krb5-1.4.1/src/appl/bsd/krlogind.c --- krb5-1.4.1.orig/src/appl/bsd/krlogind.c 2005-04-07 17:17:25.000000000 -0400 +++ krb5-1.4.1/src/appl/bsd/krlogind.c 2005-07-14 01:39:31.000000000 -0400 @@ -1045,7 +1045,7 @@ } } - if (select(8*sizeof(ibits), &ibits, &obits, &ebits, 0) < 0) { + if (select(((p>f)?p:f)+1, &ibits, &obits, &ebits, 0) < 0) { if (errno == EINTR) continue; fatalperror(f, "select"); diff -ru krb5-1.4.1.orig/src/appl/bsd/krsh.c krb5-1.4.1/src/appl/bsd/krsh.c --- krb5-1.4.1.orig/src/appl/bsd/krsh.c 2004-05-24 15:43:17.000000000 -0400 +++ krb5-1.4.1/src/appl/bsd/krsh.c 2005-07-14 01:39:36.000000000 -0400 @@ -512,7 +512,7 @@ rewrite: FD_ZERO(&rembits); FD_SET(rem, &rembits); - if (select(8*sizeof(rembits), 0, &rembits, 0, 0) < 0) { + if (select(rem+1, 0, &rembits, 0, 0) < 0) { if (errno != EINTR) { perror("select"); exit(1); @@ -550,7 +550,7 @@ FD_SET(rem, &readfrom); do { ready = readfrom; - if (select(8*sizeof(ready), &ready, 0, 0, 0) < 0) { + if (select(((rfd2>rem)?rfd2:rem)+1, &ready, 0, 0, 0) < 0) { if (errno != EINTR) { perror("select"); exit(1); diff -ru krb5-1.4.1.orig/src/appl/bsd/krshd.c krb5-1.4.1/src/appl/bsd/krshd.c --- krb5-1.4.1.orig/src/appl/bsd/krshd.c 2005-04-07 17:17:25.000000000 -0400 +++ krb5-1.4.1/src/appl/bsd/krshd.c 2005-07-14 01:35:09.000000000 -0400 @@ -440,6 +440,15 @@ fd = 0; } +#ifdef KRB5_USE_INET6 + if (((struct sockaddr*)&from)->sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sa2sin6(&from)->sin6_addr)) { + sa2sin(&from)->sin_len = sizeof(struct sockaddr_in); + sa2sin(&from)->sin_family = AF_INET; + sa2sin(&from)->sin_port = sa2sin6(&from)->sin6_port; + memcpy(&(sa2sin(&from)->sin_addr.s_addr), &(sa2sin6(&from)->sin6_addr.u6_addr.u6_addr8[12]), 4); + } +#endif + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof (on)) < 0) syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m"); @@ -1198,6 +1207,7 @@ goto signout_please; } if (pid) { + int maxfd; #ifdef POSIX_SIGNALS sa.sa_handler = cleanup; (void)sigaction(SIGINT, &sa, (struct sigaction *)0); @@ -1231,11 +1241,15 @@ FD_ZERO(&readfrom); FD_SET(f, &readfrom); + maxfd = f; if(port) { FD_SET(s, &readfrom); + if (f > maxfd) maxfd = s; FD_SET(pv[0], &readfrom); + if (pv[0] > maxfd) maxfd = pv[0]; } FD_SET(pw[0], &readfrom); + if (pw[0] > maxfd) maxfd = pw[0]; /* read from f, write to px[1] -- child stdin */ /* read from s, signal child */ @@ -1244,7 +1258,7 @@ do { ready = readfrom; - if (select(8*sizeof(ready), &ready, (fd_set *)0, + if (select(maxfd+1, &ready, (fd_set *)0, (fd_set *)0, (struct timeval *)0) < 0) { if (errno == EINTR) { continue; --- krb5-1.4/src/include/fake-addrinfo.h~ 2005-03-04 18:19:30.000000000 -0500 +++ krb5-1.4/src/include/fake-addrinfo.h 2005-03-04 18:19:57.000000000 -0500 @@ -135,7 +135,7 @@ #define FAI_CACHE #endif -#if (defined (__linux__) && defined(HAVE_GETADDRINFO)) || defined (_AIX) +#if (defined (__linux__) && defined(HAVE_GETADDRINFO)) || (defined (_AIX) && !defined(_AIXVERSION_510)) /* See comments below. */ # define WRAP_GETADDRINFO #endif