svn rev #23806: branches/krb5-1-8/src/lib/krb5/os/

tlyu@MIT.EDU tlyu at MIT.EDU
Mon Mar 15 19:50:41 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=23806
Commit By: tlyu
Log Message:
ticket: 6661
version_fixed: 1.8.1
status: resolved

pull up r23767 from trunk

 ------------------------------------------------------------------------
 r23767 | ghudson | 2010-03-05 14:19:42 -0500 (Fri, 05 Mar 2010) | 7 lines

 ticket: 6661
 target_version: 1.8.1
 tags: pullup

 Add IPv6 support to changepw.c (reverting r21004 since it is no longer
 necessary).  Patch from Submit Bose <sbose at redhat.com>.


Changed Files:
U   branches/krb5-1-8/src/lib/krb5/os/changepw.c
Modified: branches/krb5-1-8/src/lib/krb5/os/changepw.c
===================================================================
--- branches/krb5-1-8/src/lib/krb5/os/changepw.c	2010-03-15 18:53:02 UTC (rev 23805)
+++ branches/krb5-1-8/src/lib/krb5/os/changepw.c	2010-03-15 23:50:40 UTC (rev 23806)
@@ -65,20 +65,23 @@
     int sockType = (useTcp ? SOCK_STREAM : SOCK_DGRAM);
 
     code = krb5int_locate_server (context, realm, addrlist,
-                                  locate_service_kpasswd, sockType, AF_INET);
+                                  locate_service_kpasswd, sockType, AF_UNSPEC);
 
     if (code == KRB5_REALM_CANT_RESOLVE || code == KRB5_REALM_UNKNOWN) {
         code = krb5int_locate_server (context, realm, addrlist,
                                       locate_service_kadmin, SOCK_STREAM,
-                                      AF_INET);
+                                      AF_UNSPEC);
         if (!code) {
             /* Success with admin_server but now we need to change the
                port number to use DEFAULT_KPASSWD_PORT and the socktype.  */
             size_t i;
             for (i=0; i<addrlist->naddrs; i++) {
                 struct addrinfo *a = addrlist->addrs[i].ai;
+                krb5_ui_2 kpasswd_port = htons(DEFAULT_KPASSWD_PORT);
                 if (a->ai_family == AF_INET)
-                    sa2sin (a->ai_addr)->sin_port = htons(DEFAULT_KPASSWD_PORT);
+                    sa2sin (a->ai_addr)->sin_port = kpasswd_port;
+                if (a->ai_family == AF_INET6)
+                    sa2sin6 (a->ai_addr)->sin6_port = kpasswd_port;
                 if (sockType != SOCK_STREAM)
                     a->ai_socktype = sockType;
             }
@@ -131,10 +134,16 @@
     /* some brain-dead OS's don't return useful information from
      * the getsockname call.  Namely, windows and solaris.  */
 
-    if (ss2sin(&local_addr)->sin_addr.s_addr != 0) {
+    if (local_addr.ss_family == AF_INET &&
+        ss2sin(&local_addr)->sin_addr.s_addr != 0) {
         local_kaddr.addrtype = ADDRTYPE_INET;
         local_kaddr.length = sizeof(ss2sin(&local_addr)->sin_addr);
         local_kaddr.contents = (krb5_octet *) &ss2sin(&local_addr)->sin_addr;
+    } else if (local_addr.ss_family == AF_INET6 &&
+               ss2sin6(&local_addr)->sin6_addr.s6_addr != 0) {
+        local_kaddr.addrtype = ADDRTYPE_INET6;
+        local_kaddr.length = sizeof(ss2sin6(&local_addr)->sin6_addr);
+        local_kaddr.contents = (krb5_octet *) &ss2sin6(&local_addr)->sin6_addr;
     } else {
         krb5_address **addrs;
 
@@ -278,9 +287,19 @@
             break;
         }
 
-        remote_kaddr.addrtype = ADDRTYPE_INET;
-        remote_kaddr.length = sizeof(ss2sin(&remote_addr)->sin_addr);
-        remote_kaddr.contents = (krb5_octet *) &ss2sin(&remote_addr)->sin_addr;
+        if (remote_addr.ss_family == AF_INET) {
+            remote_kaddr.addrtype = ADDRTYPE_INET;
+            remote_kaddr.length = sizeof(ss2sin(&remote_addr)->sin_addr);
+            remote_kaddr.contents =
+                (krb5_octet *) &ss2sin(&remote_addr)->sin_addr;
+        } else if (remote_addr.ss_family == AF_INET6) {
+            remote_kaddr.addrtype = ADDRTYPE_INET6;
+            remote_kaddr.length = sizeof(ss2sin6(&remote_addr)->sin6_addr);
+            remote_kaddr.contents =
+                (krb5_octet *) &ss2sin6(&remote_addr)->sin6_addr;
+        } else {
+            break;
+        }
 
         if ((code = krb5_auth_con_setaddrs(callback_ctx.context,
                                            callback_ctx.auth_context,




More information about the cvs-krb5 mailing list