From 2b66b4902d08776d09ca65d18a036610e387ab43 Mon Sep 17 00:00:00 2001 From: Christian Schoenebeck Date: Wed, 17 Sep 2014 21:03:59 +0200 Subject: [PATCH] xinetd: socket bind: Invalid argument (errno = 22) when using USERID on ipv6 copied from trunk Signed-off-by: Christian Schoenebeck --- net/xinetd/patches/004-ident-bind.patch | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 net/xinetd/patches/004-ident-bind.patch diff --git a/net/xinetd/patches/004-ident-bind.patch b/net/xinetd/patches/004-ident-bind.patch new file mode 100644 index 0000000000..ddabab8a1f --- /dev/null +++ b/net/xinetd/patches/004-ident-bind.patch @@ -0,0 +1,42 @@ +xinetd: socket bind: Invalid argument (errno = 22) when using USERID on ipv6 + +Use right size of addresses in bind() call. Also use getpeername addresses when +connecting to ident service to prevent address family mismatch between socket(), +bind() and connect() calls. + +Author: Jan Safranek +Reviewed-By: Adam Tkac + +#diff -up xinetd-2.3.14/xinetd/ident.c.orig xinetd-2.3.14/xinetd/ident.c +--- a/xinetd/ident.c ++++ b/xinetd/ident.c +@@ -97,7 +98,13 @@ idresult_e log_remote_user( const struct + } + + CLEAR( sin_contact ); +- sin_remote = *CONN_XADDRESS( SERVER_CONNECTION( serp ) ) ; ++ ++ sin_len = sizeof( sin_remote ); ++ if ( getpeername( SERVER_FD( serp ), &sin_remote.sa, &sin_len ) == -1 ) ++ { ++ msg( LOG_ERR, func, "(%d) getpeername: %m", getpid() ) ; ++ return( IDR_ERROR ) ; ++ } + sin_contact = sin_remote; + memcpy( &sin_bind, &sin_local, sizeof(sin_bind) ) ; + local_port = 0; +@@ -121,7 +128,13 @@ idresult_e log_remote_user( const struct + msg( LOG_ERR, func, "socket creation: %m" ) ; + return( IDR_ERROR ) ; + } +- if ( bind(sd, &sin_bind.sa, sizeof(sin_bind.sa)) == -1 ) ++ ++ if ( sin_bind.sa.sa_family == AF_INET ) ++ sin_len = sizeof( sin_bind.sa_in ) ; ++ else ++ sin_len = sizeof( sin_bind.sa_in6 ) ; ++ ++ if ( bind(sd, &sin_bind.sa, sin_len) == -1 ) + { + msg( LOG_ERR, func, "socket bind: %m" ) ; + (void) Sclose( sd ) ; -- 2.30.2