kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
0d83e7
diff --git a/channels.c b/channels.c
0d83e7
--- a/channels.c
0d83e7
+++ b/channels.c
0d83e7
@@ -3933,16 +3933,26 @@ x11_create_display_inet(int x11_display_
0d83e7
 			if (ai->ai_family == AF_INET6)
0d83e7
 				sock_set_v6only(sock);
0d83e7
 			if (x11_use_localhost)
0d83e7
 				set_reuseaddr(sock);
0d83e7
 			if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
0d83e7
 				debug2("%s: bind port %d: %.100s", __func__,
0d83e7
 				    port, strerror(errno));
0d83e7
 				close(sock);
0d83e7
+
0d83e7
+				/* do not remove successfully opened
0d83e7
+				 * sockets if the request failed because
0d83e7
+				 * the protocol IPv4/6 is not available
0d83e7
+				 * (e.g. IPv6 may be disabled while being
0d83e7
+				 * supported)
0d83e7
+				 */
0d83e7
+				if (EADDRNOTAVAIL == errno)
0d83e7
+    					continue;
0d83e7
+
0d83e7
 				for (n = 0; n < num_socks; n++)
0d83e7
 					close(socks[n]);
0d83e7
 				num_socks = 0;
0d83e7
 				break;
0d83e7
 			}
0d83e7
 			socks[num_socks++] = sock;
0d83e7
 			if (num_socks == NUM_SOCKS)
0d83e7
 				break;