xinetd: socket bind: Invalid argument (errno = 22) when using USERID on ipv6
authorChristian Schoenebeck <christian.schoenebeck@gmail.com>
Fri, 15 Aug 2014 12:11:43 +0000 (14:11 +0200)
committerJonathan McCrohan <jmccrohan@gmail.com>
Sat, 16 Aug 2014 16:47:08 +0000 (17:47 +0100)
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.

---
Christian Schoenebeck via github pull request #205:
Reported for a long time in the web. Still exists in the current sources.
Already reported and offert on TRAC Ticket #15821.

You can find a lot of entries on "Google" about the reported problem.
I got the same error on my WNDR3800 and von VirtualBox X86.
I copied the patch to my local trunk build system and recompiled.
The problem was fixed.

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
Signed-off-by: Jonathan McCrohan <jmccrohan@gmail.com>
net/xinetd/Makefile
net/xinetd/patches/004-ident-bind.patch [new file with mode: 0644]

index b459f1b84781a00bfe984d34f1af7f984d0f1f3a..65c5368c915438a978dacde2bd63b9af4d1b840f 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=xinetd
 PKG_VERSION:=2.3.15
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://www.xinetd.org
diff --git a/net/xinetd/patches/004-ident-bind.patch b/net/xinetd/patches/004-ident-bind.patch
new file mode 100644 (file)
index 0000000..ddabab8
--- /dev/null
@@ -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 <jsafrane@redhat.com>
+Reviewed-By: Adam Tkac <atkac@redhat.com>
+
+#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 ) ;