You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

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