summaryrefslogtreecommitdiff
path: root/x11/gdm/patches/patch-ap
blob: 24c32a2cb71d674a261aeb5e1d8ff215ec631e8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
$NetBSD: patch-ap,v 1.1 2007/11/30 20:08:39 drochner Exp $

--- ./daemon/gdm-xdmcp-manager.c.orig	2007-11-27 00:12:29.000000000 +0100
+++ ./daemon/gdm-xdmcp-manager.c
@@ -63,7 +63,7 @@
  * On Sun, we need to define allow_severity and deny_severity to link
  * against libwrap.
  */
-#ifdef __sun
+#if defined(__sun) || defined(__NetBSD__)
 #include <syslog.h>
 int allow_severity = LOG_INFO;
 int deny_severity = LOG_WARNING;
@@ -369,12 +369,14 @@ ai_flags_str (struct addrinfo *ai)
 		if (ai->ai_flags & AI_NUMERICSERV) {
 			g_string_append (str, "numserv ");
 		}
+#if 0
 		if (ai->ai_flags & AI_V4MAPPED) {
 			g_string_append (str, "v4mapped ");
 		}
 		if (ai->ai_flags & AI_ALL) {
 			g_string_append (str, "all ");
 		}
+#endif
 	}
 	return g_string_free (str, FALSE);
 }
@@ -404,6 +406,14 @@ create_socket (struct addrinfo *ai)
 		return sock;
 	}
 
+#if defined(__NetBSD__) && ENABLE_IPV6
+	/* NetBSD defaults to V6ONLY */
+	{
+	int no = 0;
+	setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no));
+	}
+#endif
+
 	if (bind (sock, ai->ai_addr, ai->ai_addrlen) < 0) {
 		g_warning ("bind: %s", g_strerror (errno));
 		close (sock);
@@ -1259,7 +1269,9 @@ create_sa_from_request (ARRAY8 *req_addr
 
 	memset (&hints, 0, sizeof (hints));
 	hints.ai_family = family;
+#if !defined(__NetBSD__) || defined(AI_V4MAPPED)
 	hints.ai_flags = AI_V4MAPPED; /* this should convert IPv4 address to IPv6 if needed */
+#endif
 	if ((gaierr = getaddrinfo (host, serv, &hints, &ai_list)) != 0) {
 		g_warning ("Unable get address: %s", gai_strerror (gaierr));
 		return FALSE;
@@ -1278,6 +1290,20 @@ create_sa_from_request (ARRAY8 *req_addr
 
 	freeaddrinfo (ai_list);
 
+#if defined(__NetBSD__) && !defined(AI_V4MAPPED)
+	if (!found && family == AF_INET6 && req_addr->length == 4 && sap) {
+		struct sockaddr_in6 *sa = g_malloc(sizeof(struct sockaddr_in6));
+		memset(sa, 0, sizeof(struct sockaddr_in6));
+		sa->sin6_len = sizeof(struct sockaddr_in6);
+		sa->sin6_family = AF_INET6;
+		sa->sin6_port = port;
+		memset(&sa->sin6_addr.s6_addr[10], 0xff, 2);
+		memcpy(&sa->sin6_addr.s6_addr[12], req_addr->data, 4);
+		*sap = sa;
+		found = TRUE;
+	}
+#endif
+
 	return found;
 }