[gdm] xdmcp: disable IPV6_V6ONLY for ipv6 listening sockets



commit 4398357421555b0edae3f7b8b7f7256854e6bcf8
Author: Julien Cristau <jcristau debian org>
Date:   Mon Apr 26 19:42:16 2010 +0200

    xdmcp: disable IPV6_V6ONLY for ipv6 listening sockets
    
    This allows ipv4 connections mapped to ipv6, in case the system default
    is backwards.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=544730

 daemon/gdm-xdmcp-display-factory.c           |    8 ++++++++
 gui/simple-chooser/gdm-host-chooser-widget.c |    7 +++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gdm-xdmcp-display-factory.c b/daemon/gdm-xdmcp-display-factory.c
index 791bba3..116cc97 100644
--- a/daemon/gdm-xdmcp-display-factory.c
+++ b/daemon/gdm-xdmcp-display-factory.c
@@ -411,6 +411,14 @@ create_socket (struct addrinfo *ai)
                 return sock;
         }
 
+#if defined(ENABLE_IPV6) && defined(IPV6_V6ONLY)
+	if (ai->ai_family == AF_INET6) {
+		int zero = 0;
+		if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &zero, sizeof(zero)) < 0)
+			g_warning("setsockopt(IPV6_V6ONLY): %s", g_strerror(errno));
+	}
+#endif
+
         if (bind (sock, ai->ai_addr, ai->ai_addrlen) < 0) {
                 g_warning ("bind: %s", g_strerror (errno));
                 close (sock);
diff --git a/gui/simple-chooser/gdm-host-chooser-widget.c b/gui/simple-chooser/gdm-host-chooser-widget.c
index e694728..0c8f46c 100644
--- a/gui/simple-chooser/gdm-host-chooser-widget.c
+++ b/gui/simple-chooser/gdm-host-chooser-widget.c
@@ -544,6 +544,13 @@ xdmcp_init (GdmHostChooserWidget *widget)
         widget->priv->socket_fd = socket (AF_INET6, SOCK_DGRAM, 0);
         if (widget->priv->socket_fd != -1) {
                 widget->priv->have_ipv6 = TRUE;
+#ifdef IPV6_V6ONLY
+		{
+			int zero = 0;
+			if (setsockopt(widget->priv->socket_fd, IPPROTO_IPV6, IPV6_V6ONLY, &zero, sizeof(zero)) < 0)
+				g_warning("setsockopt(IPV6_V6ONLY): %s", g_strerror(errno));
+		}
+#endif
         }
 #endif
         if (! widget->priv->have_ipv6) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]