bmh10 / rpms / openssh

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