This patch fixes several problems arising if XOrg is compiled with IPv6 support, but the (linux) kernel does not support IPv6. Note: The original code for UpdateListener in xc/programs/xdm/socket.c could not possibly work for "addr == NULL || addr->length == 0" because &in resp. &in6 were used outside the domain of validity of these structures. Similarly all_query_respond in xc/programs/xdm/xdmcp.c couldn't possibly work due to some FamilyInternet(6) vs. AF_INET(6) confusion. Note: I have reported this patch to XFree86 and it has been fixed there about a year ago! PLEASE PLEASE PLEASE: Find a better way to coordinate things between XOrg and XFree86. I'm quite sure there are zillions of bugs fixed in XOrg but still present in XFree86 and vice versa. diff -ur XOrg-6.8.2.orig/xc/programs/xdm/auth.c XOrg-6.8.2/xc/programs/xdm/auth.c --- XOrg-6.8.2.orig/xc/programs/xdm/auth.c 2004-04-23 21:54:42.000000000 +0200 +++ XOrg-6.8.2/xc/programs/xdm/auth.c 2005-04-02 21:59:51.000000000 +0200 @@ -1183,9 +1183,9 @@ #ifdef TCPCONN #if defined(IPv6) && defined(AF_INET6) fd = socket (AF_INET6, SOCK_STREAM, 0); -#else - fd = socket (AF_INET, SOCK_STREAM, 0); + if (fd < 0) #endif + fd = socket (AF_INET, SOCK_STREAM, 0); DefineSelf (fd, file, auth); close (fd); #endif diff -ur XOrg-6.8.2.orig/xc/programs/xdm/socket.c XOrg-6.8.2/xc/programs/xdm/socket.c --- XOrg-6.8.2.orig/xc/programs/xdm/socket.c 2004-07-06 02:44:39.000000000 +0200 +++ XOrg-6.8.2/xc/programs/xdm/socket.c 2005-04-02 22:07:30.000000000 +0200 @@ -302,22 +302,24 @@ UpdateListener(ARRAY8Ptr addr, void **closure) { struct socklist *s; - ARRAY8 tmpaddr; *closure = NULL; if (addr == NULL || addr->length == 0) { + ARRAY8 tmpaddr; + struct in_addr in; #if defined(IPv6) && defined(AF_INET6) struct in6_addr in6 = in6addr_any; tmpaddr.length = sizeof(in6); tmpaddr.data = (CARD8Ptr) &in6; -#else - struct in_addr in; + UpdateListener(&tmpaddr, closure); + if (*closure) return; +#endif in.s_addr = htonl (INADDR_ANY); tmpaddr.length = sizeof(in); tmpaddr.data = (CARD8Ptr) ∈ -#endif - addr = &tmpaddr; + UpdateListener(&tmpaddr, closure); + return; } s = FindInList(listensocks, addr); @@ -375,12 +377,12 @@ (op == JOIN_MCAST_GROUP) ? "join" : "drop", inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr), errno); - return; } else if (debugLevel > 0) { Debug ("XDMCP socket multicast %s to %s succeeded\n", (op == JOIN_MCAST_GROUP) ? "join" : "drop", inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr)); } + return; } #if defined(IPv6) && defined(AF_INET6) #ifndef IPV6_JOIN_GROUP @@ -413,7 +415,6 @@ LogError ("XDMCP socket multicast %s to %s failed, errno %d\n", (op == JOIN_MCAST_GROUP) ? "join" : "drop", addrbuf, saveerr); - return; } else if (debugLevel > 0) { char addrbuf[INET6_ADDRSTRLEN]; @@ -424,6 +425,7 @@ Debug ("XDMCP socket multicast %s to %s succeeded\n", (op == JOIN_MCAST_GROUP) ? "join" : "drop", addrbuf); } + return; } #endif } diff -ur XOrg-6.8.2.orig/xc/programs/xdm/xdmcp.c XOrg-6.8.2/xc/programs/xdm/xdmcp.c --- XOrg-6.8.2.orig/xc/programs/xdm/xdmcp.c 2004-08-07 21:22:01.000000000 +0200 +++ XOrg-6.8.2/xc/programs/xdm/xdmcp.c 2005-04-02 22:18:25.000000000 +0200 @@ -262,12 +262,15 @@ if (debugLevel > 0) { #if defined(IPv6) && defined(AF_INET6) void *ipaddr; - if (family == AF_INET6) { + int af_type; + if (family == FamilyInternet6) { ipaddr = & ((struct sockaddr_in6 *) from)->sin6_addr; + af_type = AF_INET6; } else { ipaddr = & ((struct sockaddr_in *) from)->sin_addr; + af_type = AF_INET; } - addrstring = inet_ntop(family, ipaddr, addrbuf, sizeof(addrbuf)); + addrstring = inet_ntop(af_type, ipaddr, addrbuf, sizeof(addrbuf)); #else addrstring = inet_ntoa(((struct sockaddr_in *)from)->sin_addr); #endif @@ -1397,7 +1400,7 @@ CARD16 connectionType, ARRAY8Ptr connectionAddress) { - char *name = 0; + char *name = NULL; switch (connectionType) { @@ -1434,7 +1437,7 @@ if ((af_type == nai->ai_family) && (connectionAddress->length == nai->ai_addrlen) && (memcmp(connectionAddress->data,nai->ai_addr, - nai->ai_addrlen) != 0) ) { + nai->ai_addrlen) == 0) ) { break; } }