Blame SOURCES/xinetd-2.3.14-ident-bind.patch

01101d
448069: xinetd: socket bind: Invalid argument (errno = 22) when using USERID on ipv6
01101d
01101d
Use right size of addresses in bind() call. Also use getpeername addresses when
01101d
connecting to ident service to prevent address family mismatch between socket(),
01101d
bind() and connect() calls.
01101d
01101d
Author: Jan Safranek <jsafrane@redhat.com>
01101d
Reviewed-By: Adam Tkac <atkac@redhat.com>
01101d
01101d
diff -up xinetd-2.3.14/xinetd/ident.c.orig xinetd-2.3.14/xinetd/ident.c
01101d
--- xinetd-2.3.14/xinetd/ident.c.orig	2008-05-29 16:30:19.000000000 +0200
01101d
+++ xinetd-2.3.14/xinetd/ident.c	2008-05-29 16:29:57.000000000 +0200
01101d
@@ -97,7 +98,13 @@ idresult_e log_remote_user( const struct
01101d
    }
01101d
 
01101d
    CLEAR( sin_contact );
01101d
-   sin_remote = *CONN_XADDRESS( SERVER_CONNECTION( serp ) ) ;
01101d
+
01101d
+   sin_len = sizeof( sin_remote );
01101d
+   if ( getpeername( SERVER_FD( serp ), &sin_remote.sa, &sin_len ) == -1 )
01101d
+   {
01101d
+      msg( LOG_ERR, func, "(%d) getpeername: %m", getpid() ) ;
01101d
+      return( IDR_ERROR ) ;
01101d
+   }
01101d
    sin_contact = sin_remote;
01101d
    memcpy( &sin_bind, &sin_local, sizeof(sin_bind) ) ;
01101d
    local_port = 0;
01101d
@@ -121,7 +128,13 @@ idresult_e log_remote_user( const struct
01101d
       msg( LOG_ERR, func, "socket creation: %m" ) ;
01101d
       return( IDR_ERROR ) ;
01101d
    }
01101d
-   if ( bind(sd, &sin_bind.sa, sizeof(sin_bind.sa)) == -1 )
01101d
+
01101d
+   if ( sin_bind.sa.sa_family == AF_INET ) 
01101d
+      sin_len = sizeof( sin_bind.sa_in ) ;
01101d
+   else
01101d
+      sin_len = sizeof( sin_bind.sa_in6 ) ;
01101d
+
01101d
+   if ( bind(sd, &sin_bind.sa, sin_len) == -1 )
01101d
    { 
01101d
       msg( LOG_ERR, func, "socket bind: %m" ) ;
01101d
       (void) Sclose( sd ) ;