lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

004-ident-bind.patch (1443B)


      1 xinetd: socket bind: Invalid argument (errno = 22) when using USERID on ipv6
      2 
      3 Use right size of addresses in bind() call. Also use getpeername addresses when
      4 connecting to ident service to prevent address family mismatch between socket(),
      5 bind() and connect() calls.
      6 
      7 Author: Jan Safranek <jsafrane@redhat.com>
      8 Reviewed-By: Adam Tkac <atkac@redhat.com>
      9 
     10 #diff -up xinetd-2.3.14/xinetd/ident.c.orig xinetd-2.3.14/xinetd/ident.c
     11 --- a/xinetd/ident.c
     12 +++ b/xinetd/ident.c
     13 @@ -97,7 +97,13 @@ idresult_e log_remote_user( const struct
     14     }
     15  
     16     CLEAR( sin_contact );
     17 -   sin_remote = *CONN_XADDRESS( SERVER_CONNECTION( serp ) ) ;
     18 +
     19 +   sin_len = sizeof( sin_remote );
     20 +   if ( getpeername( SERVER_FD( serp ), &sin_remote.sa, &sin_len ) == -1 )
     21 +   {
     22 +      msg( LOG_ERR, func, "(%d) getpeername: %m", getpid() ) ;
     23 +      return( IDR_ERROR ) ;
     24 +   }
     25     sin_contact = sin_remote;
     26     memcpy( &sin_bind, &sin_local, sizeof(sin_bind) ) ;
     27     local_port = 0;
     28 @@ -127,7 +133,13 @@ idresult_e log_remote_user( const struct
     29        msg( LOG_ERR, func, "socket creation: %m" ) ;
     30        return( IDR_ERROR ) ;
     31     }
     32 -   if ( bind(sd, &sin_bind.sa, sizeof(sin_bind.sa)) == -1 )
     33 +
     34 +   if ( sin_bind.sa.sa_family == AF_INET ) 
     35 +      sin_len = sizeof( sin_bind.sa_in ) ;
     36 +   else
     37 +      sin_len = sizeof( sin_bind.sa_in6 ) ;
     38 +
     39 +   if ( bind(sd, &sin_bind.sa, sin_len) == -1 )
     40     { 
     41        msg( LOG_ERR, func, "socket bind: %m" ) ;
     42        (void) Sclose( sd ) ;