Follow-up Comment #30, bug #15559 (project freeciv):

>From x11_create_display_inet() of openssh-5.6p1/channels.c:



                for (ai = aitop; ai; ai = ai->ai_next) {
                        if (ai->ai_family != AF_INET && ai->ai_family != 
AF_INET6)
                                continue;
                        sock = socket(ai->ai_family, ai->ai_socktype,
                            ai->ai_protocol);
                        if (sock < 0) {
                                if ((errno != EINVAL) && (errno != EAFNOSUPPORT)
#ifdef EPFNOSUPPORT
                                    && (errno != EPFNOSUPPORT)
#endif 
                                    ) {
                                        error("socket: %.100s", 
strerror(errno));
                                        freeaddrinfo(aitop);
                                        return -1;
                                } else {
                                        debug("x11_create_display_inet: Socket 
family %d not supported",
                                                 ai->ai_family);
                                        continue;
                                }
                        }
                        if (ai->ai_family == AF_INET6)
                                sock_set_v6only(sock);
                        if (x11_use_localhost)
                                channel_set_reuseaddr(sock);
                        if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
                                debug2("bind port %d: %.100s", port, 
strerror(errno));
                                close(sock);

                                for (n = 0; n < num_socks; n++) {
                                        close(socks[n]);
                                }
                                num_socks = 0;
                                break;
                        }
                        socks[num_socks++] = sock;
                        if (num_socks == NUM_SOCKS)
                                break;
                }



During X11 forwarding, if any bind() fails, then OpenSSH loops to close _all_
sockets.

This only happens during X11 forwarding! Other code at
channel_setup_fwd_listener() from channels.c, and at server_listen() from
sshd.c, seems to allow bind() to fail.

----

>From openssh-5.6p1/misc.c:



void
sock_set_v6only(int s)
{
#ifdef IPV6_V6ONLY
        int on = 1;

        debug3("%s: set socket %d IPV6_V6ONLY", __func__, s);
        if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1)
                error("setsockopt IPV6_V6ONLY: %s", strerror(errno));
#endif
}




    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?15559>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to