bmh10 / rpms / openssh

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