vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month 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) {
DistroBaker d029bb
 				debug2_f("bind port %d: %.100s", port,
DistroBaker d029bb
 				    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;