2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software and its
|
|
|
|
* documentation for any purpose and without fee is hereby granted, provided
|
|
|
|
* that the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of N.C.D. not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. N.C.D. makes no representations about the
|
|
|
|
* suitability of this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#include <X11/Xwinsock.h>
|
2015-09-16 13:10:19 -06:00
|
|
|
#define XSERV_t
|
|
|
|
#define TRANS_SERVER
|
|
|
|
#define TRANS_REOPEN
|
|
|
|
#include <X11/Xtrans/Xtrans.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/Xos.h>
|
|
|
|
|
|
|
|
#if !defined(WIN32)
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xmd.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "osdep.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "opaque.h"
|
2009-09-06 13:44:18 -06:00
|
|
|
#include "site.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
#define XSERV_t
|
|
|
|
#define TRANS_SERVER
|
|
|
|
#define TRANS_REOPEN
|
|
|
|
#include <X11/Xtrans/Xtrans.h>
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef XDMCP
|
|
|
|
#undef REQUEST
|
|
|
|
|
|
|
|
#ifdef XDMCP_NO_IPV6
|
|
|
|
#undef IPv6
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/Xdmcp.h>
|
|
|
|
|
|
|
|
#define X_INCLUDE_NETDB_H
|
|
|
|
#include <X11/Xos_r.h>
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static const char *defaultDisplayClass = COMPILEDDISPLAYCLASS;
|
|
|
|
|
|
|
|
static int xdmcpSocket, sessionSocket;
|
|
|
|
static xdmcp_states state;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
static int xdmcpSocket6;
|
2006-11-26 11:13:41 -07:00
|
|
|
static struct sockaddr_storage req_sockaddr;
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
static struct sockaddr_in req_sockaddr;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
static int req_socklen;
|
|
|
|
static CARD32 SessionID;
|
|
|
|
static int timeOutRtx;
|
|
|
|
static CARD16 DisplayNumber;
|
|
|
|
static xdmcp_states XDM_INIT_STATE = XDM_OFF;
|
2017-12-08 08:01:59 -07:00
|
|
|
static OsTimerPtr xdmcp_timer;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef HASXDMAUTH
|
2012-06-10 07:21:05 -06:00
|
|
|
static char *xdmAuthCookie;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static XdmcpBuffer buffer;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
|
|
|
|
static struct addrinfo *mgrAddr;
|
|
|
|
static struct addrinfo *mgrAddrFirst;
|
|
|
|
|
|
|
|
#define SOCKADDR_TYPE struct sockaddr_storage
|
|
|
|
#define SOCKADDR_FAMILY(s) ((struct sockaddr *)&(s))->sa_family
|
|
|
|
|
|
|
|
#ifdef BSD44SOCKETS
|
|
|
|
#define SOCKLEN_FIELD(s) ((struct sockaddr *)&(s))->sa_len
|
|
|
|
#define SOCKLEN_TYPE unsigned char
|
|
|
|
#else
|
|
|
|
#define SOCKLEN_TYPE unsigned int
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define SOCKADDR_TYPE struct sockaddr_in
|
|
|
|
#define SOCKADDR_FAMILY(s) (s).sin_family
|
|
|
|
|
|
|
|
#ifdef BSD44SOCKETS
|
|
|
|
#define SOCKLEN_FIELD(s) (s).sin_len
|
|
|
|
#define SOCKLEN_TYPE unsigned char
|
|
|
|
#else
|
|
|
|
#define SOCKLEN_TYPE size_t
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static SOCKADDR_TYPE ManagerAddress;
|
|
|
|
static SOCKADDR_TYPE FromAddress;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#ifdef SOCKLEN_FIELD
|
|
|
|
#define ManagerAddressLen SOCKLEN_FIELD(ManagerAddress)
|
|
|
|
#define FromAddressLen SOCKLEN_FIELD(FromAddress)
|
|
|
|
#else
|
|
|
|
static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
static struct multicastinfo {
|
2012-06-10 07:21:05 -06:00
|
|
|
struct multicastinfo *next;
|
|
|
|
struct addrinfo *ai;
|
|
|
|
int hops;
|
2006-11-26 11:13:41 -07:00
|
|
|
} *mcastlist;
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void XdmcpAddHost(const struct sockaddr *from,
|
|
|
|
int fromlen,
|
|
|
|
ARRAY8Ptr AuthenticationName,
|
|
|
|
ARRAY8Ptr hostname, ARRAY8Ptr status);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void XdmcpSelectHost(const struct sockaddr *host_sockaddr,
|
|
|
|
int host_len, ARRAY8Ptr AuthenticationName);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void get_xdmcp_sock(void);
|
|
|
|
|
|
|
|
static void send_query_msg(void);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void recv_willing_msg(struct sockaddr *from,
|
|
|
|
int fromlen,
|
|
|
|
unsigned length);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void send_request_msg(void);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void recv_accept_msg(unsigned length);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void recv_decline_msg(unsigned length);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void send_manage_msg(void);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void recv_refuse_msg(unsigned length);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void recv_failed_msg(unsigned length);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void send_keepalive_msg(void);
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void recv_alive_msg(unsigned length );
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void XdmcpFatal(const char *type,
|
|
|
|
ARRAY8Ptr status);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void XdmcpWarning(const char *str);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void get_manager_by_name(int argc,
|
|
|
|
char **argv,
|
|
|
|
int i);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void get_fromaddr_by_name(int argc,
|
|
|
|
char **argv,
|
|
|
|
int i);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2014-09-27 11:52:59 -06:00
|
|
|
static int get_mcast_options(int argc,
|
|
|
|
char **argv,
|
|
|
|
int i);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
|
2014-09-27 11:52:59 -06:00
|
|
|
static void receive_packet(int socketfd);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void send_packet(void);
|
|
|
|
|
|
|
|
static void timeout(void);
|
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
static void XdmcpSocketNotify(int fd, int ready, void *data);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
static CARD32 XdmcpTimerNotify(OsTimerPtr timer, CARD32 time, void *arg);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 12:04:00 -07:00
|
|
|
/*
|
|
|
|
* Register the Manufacturer display ID
|
|
|
|
*/
|
|
|
|
|
|
|
|
static ARRAY8 ManufacturerDisplayID;
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpRegisterManufacturerDisplayID(const char *name, int length)
|
2007-11-24 12:04:00 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDisposeARRAY8(&ManufacturerDisplayID);
|
|
|
|
if (!XdmcpAllocARRAY8(&ManufacturerDisplayID, length))
|
|
|
|
return;
|
2007-11-24 12:04:00 -07:00
|
|
|
for (i = 0; i < length; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
ManufacturerDisplayID.data[i] = (CARD8) name[i];
|
2007-11-24 12:04:00 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static unsigned short xdm_udp_port = XDM_UDP_PORT;
|
|
|
|
static Bool OneSession = FALSE;
|
|
|
|
static const char *xdm_from = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpUseMsg(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ErrorF("-query host-name contact named host for XDMCP\n");
|
|
|
|
ErrorF("-broadcast broadcast for XDMCP\n");
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
ErrorF("-multicast [addr [hops]] IPv6 multicast for XDMCP\n");
|
|
|
|
#endif
|
|
|
|
ErrorF("-indirect host-name contact named host for indirect XDMCP\n");
|
|
|
|
ErrorF("-port port-num UDP port number to send messages to\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF
|
|
|
|
("-from local-address specify the local address to connect from\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
ErrorF("-once Terminate server after one session\n");
|
|
|
|
ErrorF("-class display-class specify display class to send in manage\n");
|
|
|
|
#ifdef HASXDMAUTH
|
|
|
|
ErrorF("-cookie xdm-auth-bits specify the magic cookie for XDMCP\n");
|
|
|
|
#endif
|
|
|
|
ErrorF("-displayID display-id manufacturer display ID for request\n");
|
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
static void
|
|
|
|
XdmcpDefaultListen(void)
|
|
|
|
{
|
|
|
|
/* Even when configured --disable-listen-tcp, we should listen on tcp in
|
|
|
|
XDMCP modes */
|
|
|
|
_XSERVTransListen("tcp");
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
2006-11-26 11:13:41 -07:00
|
|
|
XdmcpOptions(int argc, char **argv, int i)
|
|
|
|
{
|
|
|
|
if (strcmp(argv[i], "-query") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
get_manager_by_name(argc, argv, i++);
|
|
|
|
XDM_INIT_STATE = XDM_QUERY;
|
|
|
|
AccessUsingXdmcp();
|
2015-09-16 13:10:19 -06:00
|
|
|
XdmcpDefaultListen();
|
2012-06-10 07:21:05 -06:00
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (strcmp(argv[i], "-broadcast") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XDM_INIT_STATE = XDM_BROADCAST;
|
|
|
|
AccessUsingXdmcp();
|
2015-09-16 13:10:19 -06:00
|
|
|
XdmcpDefaultListen();
|
2012-06-10 07:21:05 -06:00
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if (strcmp(argv[i], "-multicast") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
i = get_mcast_options(argc, argv, ++i);
|
|
|
|
XDM_INIT_STATE = XDM_MULTICAST;
|
|
|
|
AccessUsingXdmcp();
|
2015-09-16 13:10:19 -06:00
|
|
|
XdmcpDefaultListen();
|
2012-06-10 07:21:05 -06:00
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (strcmp(argv[i], "-indirect") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
get_manager_by_name(argc, argv, i++);
|
|
|
|
XDM_INIT_STATE = XDM_INDIRECT;
|
|
|
|
AccessUsingXdmcp();
|
2015-09-16 13:10:19 -06:00
|
|
|
XdmcpDefaultListen();
|
2012-06-10 07:21:05 -06:00
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (strcmp(argv[i], "-port") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (++i == argc) {
|
|
|
|
FatalError("Xserver: missing port number in command line\n");
|
|
|
|
}
|
|
|
|
xdm_udp_port = (unsigned short) atoi(argv[i]);
|
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (strcmp(argv[i], "-from") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
get_fromaddr_by_name(argc, argv, ++i);
|
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (strcmp(argv[i], "-once") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
OneSession = TRUE;
|
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (strcmp(argv[i], "-class") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (++i == argc) {
|
|
|
|
FatalError("Xserver: missing class name in command line\n");
|
|
|
|
}
|
|
|
|
defaultDisplayClass = argv[i];
|
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#ifdef HASXDMAUTH
|
|
|
|
if (strcmp(argv[i], "-cookie") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (++i == argc) {
|
|
|
|
FatalError("Xserver: missing cookie data in command line\n");
|
|
|
|
}
|
|
|
|
xdmAuthCookie = argv[i];
|
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (strcmp(argv[i], "-displayID") == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (++i == argc) {
|
|
|
|
FatalError("Xserver: missing displayID in command line\n");
|
|
|
|
}
|
|
|
|
XdmcpRegisterManufacturerDisplayID(argv[i], strlen(argv[i]));
|
|
|
|
return i + 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
return i;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This section is a collection of routines for
|
|
|
|
* registering server-specific data with the XDMCP
|
|
|
|
* state machine.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save all broadcast addresses away so BroadcastQuery
|
|
|
|
* packets get sent everywhere
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_BROADCAST 10
|
|
|
|
|
|
|
|
/* This stays sockaddr_in since IPv6 doesn't support broadcast */
|
2012-06-10 07:21:05 -06:00
|
|
|
static struct sockaddr_in BroadcastAddresses[MAX_BROADCAST];
|
|
|
|
static int NumBroadcastAddresses;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpRegisterBroadcastAddress(const struct sockaddr_in *addr)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
struct sockaddr_in *bcast;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (NumBroadcastAddresses >= MAX_BROADCAST)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
bcast = &BroadcastAddresses[NumBroadcastAddresses++];
|
2012-06-10 07:21:05 -06:00
|
|
|
memset(bcast, 0, sizeof(struct sockaddr_in));
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef BSD44SOCKETS
|
|
|
|
bcast->sin_len = addr->sin_len;
|
|
|
|
#endif
|
|
|
|
bcast->sin_family = addr->sin_family;
|
2012-06-10 07:21:05 -06:00
|
|
|
bcast->sin_port = htons(xdm_udp_port);
|
2006-11-26 11:13:41 -07:00
|
|
|
bcast->sin_addr = addr->sin_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Each authentication type is registered here; Validator
|
|
|
|
* will be called to check all access attempts using
|
|
|
|
* the specified authentication type
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static ARRAYofARRAY8 AuthenticationNames, AuthenticationDatas;
|
2006-11-26 11:13:41 -07:00
|
|
|
typedef struct _AuthenticationFuncs {
|
2012-06-10 07:21:05 -06:00
|
|
|
ValidatorFunc Validator;
|
|
|
|
GeneratorFunc Generator;
|
|
|
|
AddAuthorFunc AddAuth;
|
2006-11-26 11:13:41 -07:00
|
|
|
} AuthenticationFuncsRec, *AuthenticationFuncsPtr;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static AuthenticationFuncsPtr AuthenticationFuncsList;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpRegisterAuthentication(const char *name,
|
|
|
|
int namelen,
|
|
|
|
const char *data,
|
|
|
|
int datalen,
|
|
|
|
ValidatorFunc Validator,
|
|
|
|
GeneratorFunc Generator, AddAuthorFunc AddAuth)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
ARRAY8 AuthenticationName, AuthenticationData;
|
|
|
|
static AuthenticationFuncsPtr newFuncs;
|
|
|
|
|
|
|
|
if (!XdmcpAllocARRAY8(&AuthenticationName, namelen))
|
|
|
|
return;
|
|
|
|
if (!XdmcpAllocARRAY8(&AuthenticationData, datalen)) {
|
|
|
|
XdmcpDisposeARRAY8(&AuthenticationName);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
for (i = 0; i < namelen; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
AuthenticationName.data[i] = name[i];
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < datalen; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
AuthenticationData.data[i] = data[i];
|
|
|
|
if (!(XdmcpReallocARRAYofARRAY8(&AuthenticationNames,
|
|
|
|
AuthenticationNames.length + 1) &&
|
|
|
|
XdmcpReallocARRAYofARRAY8(&AuthenticationDatas,
|
|
|
|
AuthenticationDatas.length + 1) &&
|
|
|
|
(newFuncs =
|
|
|
|
malloc((AuthenticationNames.length +
|
|
|
|
1) * sizeof(AuthenticationFuncsRec))))) {
|
|
|
|
XdmcpDisposeARRAY8(&AuthenticationName);
|
|
|
|
XdmcpDisposeARRAY8(&AuthenticationData);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
for (i = 0; i < AuthenticationNames.length - 1; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
newFuncs[i] = AuthenticationFuncsList[i];
|
|
|
|
newFuncs[AuthenticationNames.length - 1].Validator = Validator;
|
|
|
|
newFuncs[AuthenticationNames.length - 1].Generator = Generator;
|
|
|
|
newFuncs[AuthenticationNames.length - 1].AddAuth = AddAuth;
|
2010-12-05 08:36:02 -07:00
|
|
|
free(AuthenticationFuncsList);
|
2006-11-26 11:13:41 -07:00
|
|
|
AuthenticationFuncsList = newFuncs;
|
2012-06-10 07:21:05 -06:00
|
|
|
AuthenticationNames.data[AuthenticationNames.length - 1] =
|
|
|
|
AuthenticationName;
|
|
|
|
AuthenticationDatas.data[AuthenticationDatas.length - 1] =
|
|
|
|
AuthenticationData;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select the authentication type to be used; this is
|
|
|
|
* set by the manager of the host to be connected to.
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static ARRAY8 noAuthenticationName = { (CARD16) 0, (CARD8Ptr) 0 };
|
|
|
|
static ARRAY8 noAuthenticationData = { (CARD16) 0, (CARD8Ptr) 0 };
|
|
|
|
|
|
|
|
static ARRAY8Ptr AuthenticationName = &noAuthenticationName;
|
|
|
|
static ARRAY8Ptr AuthenticationData = &noAuthenticationData;
|
|
|
|
static AuthenticationFuncsPtr AuthenticationFuncs;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 12:04:00 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpSetAuthentication(const ARRAY8Ptr name)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
for (i = 0; i < AuthenticationNames.length; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XdmcpARRAY8Equal(&AuthenticationNames.data[i], name)) {
|
|
|
|
AuthenticationName = &AuthenticationNames.data[i];
|
|
|
|
AuthenticationData = &AuthenticationDatas.data[i];
|
|
|
|
AuthenticationFuncs = &AuthenticationFuncsList[i];
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register the host address for the display
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static ARRAY16 ConnectionTypes;
|
|
|
|
static ARRAYofARRAY8 ConnectionAddresses;
|
|
|
|
static long xdmcpGeneration;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpRegisterConnection(int type, const char *address, int addrlen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
CARD8 *newAddress;
|
|
|
|
|
|
|
|
if (xdmcpGeneration != serverGeneration) {
|
|
|
|
XdmcpDisposeARRAY16(&ConnectionTypes);
|
|
|
|
XdmcpDisposeARRAYofARRAY8(&ConnectionAddresses);
|
|
|
|
xdmcpGeneration = serverGeneration;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (xdm_from != NULL) { /* Only register the requested address */
|
|
|
|
const void *regAddr = address;
|
|
|
|
const void *fromAddr = NULL;
|
|
|
|
int regAddrlen = addrlen;
|
|
|
|
|
|
|
|
if (addrlen == sizeof(struct in_addr)) {
|
|
|
|
if (SOCKADDR_FAMILY(FromAddress) == AF_INET) {
|
|
|
|
fromAddr = &((struct sockaddr_in *) &FromAddress)->sin_addr;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET6) &&
|
|
|
|
IN6_IS_ADDR_V4MAPPED(&
|
|
|
|
((struct sockaddr_in6 *)
|
|
|
|
&FromAddress)->sin6_addr)) {
|
|
|
|
fromAddr =
|
|
|
|
&((struct sockaddr_in6 *) &FromAddress)->sin6_addr.
|
|
|
|
s6_addr[12];
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (addrlen == sizeof(struct in6_addr)) {
|
|
|
|
if (SOCKADDR_FAMILY(FromAddress) == AF_INET6) {
|
|
|
|
fromAddr = &((struct sockaddr_in6 *) &FromAddress)->sin6_addr;
|
|
|
|
}
|
|
|
|
else if ((SOCKADDR_FAMILY(FromAddress) == AF_INET) &&
|
|
|
|
IN6_IS_ADDR_V4MAPPED((const struct in6_addr *) address)) {
|
|
|
|
fromAddr = &((struct sockaddr_in *) &FromAddress)->sin_addr;
|
|
|
|
regAddr =
|
2019-03-19 15:19:54 -06:00
|
|
|
&((struct sockaddr_in6 *) address)->sin6_addr.s6_addr[12];
|
2012-06-10 07:21:05 -06:00
|
|
|
regAddrlen = sizeof(struct in_addr);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!fromAddr || memcmp(regAddr, fromAddr, regAddrlen) != 0) {
|
|
|
|
return;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
if (ConnectionAddresses.length + 1 == 256)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
newAddress = malloc(addrlen * sizeof(CARD8));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!newAddress)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
if (!XdmcpReallocARRAY16(&ConnectionTypes, ConnectionTypes.length + 1)) {
|
|
|
|
free(newAddress);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!XdmcpReallocARRAYofARRAY8(&ConnectionAddresses,
|
|
|
|
ConnectionAddresses.length + 1)) {
|
|
|
|
free(newAddress);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
ConnectionTypes.data[ConnectionTypes.length - 1] = (CARD16) type;
|
|
|
|
for (i = 0; i < addrlen; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
newAddress[i] = address[i];
|
|
|
|
ConnectionAddresses.data[ConnectionAddresses.length - 1].data = newAddress;
|
|
|
|
ConnectionAddresses.data[ConnectionAddresses.length - 1].length = addrlen;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register an Authorization Name. XDMCP advertises this list
|
|
|
|
* to the manager.
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static ARRAYofARRAY8 AuthorizationNames;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpRegisterAuthorizations(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDisposeARRAYofARRAY8(&AuthorizationNames);
|
|
|
|
RegisterAuthorizations();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpRegisterAuthorization(const char *name, int namelen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ARRAY8 authName;
|
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
authName.data = malloc(namelen * sizeof(CARD8));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!authName.data)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
if (!XdmcpReallocARRAYofARRAY8
|
|
|
|
(&AuthorizationNames, AuthorizationNames.length + 1)) {
|
|
|
|
free(authName.data);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
for (i = 0; i < namelen; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
authName.data[i] = (CARD8) name[i];
|
2006-11-26 11:13:41 -07:00
|
|
|
authName.length = namelen;
|
2012-06-10 07:21:05 -06:00
|
|
|
AuthorizationNames.data[AuthorizationNames.length - 1] = authName;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register the DisplayClass string
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static ARRAY8 DisplayClass;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 12:04:00 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpRegisterDisplayClass(const char *name, int length)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDisposeARRAY8(&DisplayClass);
|
|
|
|
if (!XdmcpAllocARRAY8(&DisplayClass, length))
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < length; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
DisplayClass.data[i] = (CARD8) name[i];
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
static void
|
|
|
|
xdmcp_start(void)
|
|
|
|
{
|
|
|
|
timeOutRtx = 0;
|
|
|
|
get_xdmcp_sock();
|
|
|
|
if (xdmcpSocket >= 0)
|
|
|
|
SetNotifyFd(xdmcpSocket, XdmcpSocketNotify, X_NOTIFY_READ, NULL);
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if (xdmcpSocket6 >= 0)
|
|
|
|
SetNotifyFd(xdmcpSocket6, XdmcpSocketNotify, X_NOTIFY_READ, NULL);
|
|
|
|
#endif
|
|
|
|
xdmcp_timer = TimerSet(NULL, 0, 0, XdmcpTimerNotify, NULL);
|
|
|
|
send_packet();
|
|
|
|
}
|
|
|
|
|
2015-09-16 13:10:19 -06:00
|
|
|
/*
|
2006-11-26 11:13:41 -07:00
|
|
|
* initialize XDMCP; create the socket, compute the display
|
|
|
|
* number, set up the state machine
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
XdmcpInit(void)
|
|
|
|
{
|
|
|
|
state = XDM_INIT_STATE;
|
|
|
|
#ifdef HASXDMAUTH
|
|
|
|
if (xdmAuthCookie)
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmAuthenticationInit(xdmAuthCookie, strlen(xdmAuthCookie));
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (state != XDM_OFF) {
|
|
|
|
XdmcpRegisterAuthorizations();
|
|
|
|
XdmcpRegisterDisplayClass(defaultDisplayClass,
|
|
|
|
strlen(defaultDisplayClass));
|
|
|
|
AccessUsingXdmcp();
|
|
|
|
DisplayNumber = (CARD16) atoi(display);
|
2017-12-08 08:01:59 -07:00
|
|
|
xdmcp_start();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpReset(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
state = XDM_INIT_STATE;
|
2017-12-08 08:01:59 -07:00
|
|
|
if (state != XDM_OFF)
|
|
|
|
xdmcp_start();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Called whenever a new connection is created; notices the
|
|
|
|
* first connection and saves it to terminate the session
|
|
|
|
* when it is closed
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
XdmcpOpenDisplay(int sock)
|
|
|
|
{
|
|
|
|
if (state != XDM_AWAIT_MANAGE_RESPONSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
state = XDM_RUN_SESSION;
|
2017-12-08 08:01:59 -07:00
|
|
|
TimerSet(xdmcp_timer, 0, XDM_DEF_DORMANCY * 1000, XdmcpTimerNotify, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
sessionSocket = sock;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
void
|
2006-11-26 11:13:41 -07:00
|
|
|
XdmcpCloseDisplay(int sock)
|
|
|
|
{
|
|
|
|
if ((state != XDM_RUN_SESSION && state != XDM_AWAIT_ALIVE_RESPONSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
|| sessionSocket != sock)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
state = XDM_INIT_STATE;
|
|
|
|
if (OneSession)
|
2012-06-10 07:21:05 -06:00
|
|
|
dispatchException |= DE_TERMINATE;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
dispatchException |= DE_RESET;
|
2006-11-26 11:13:41 -07:00
|
|
|
isItTimeToYield = TRUE;
|
|
|
|
}
|
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
static void
|
|
|
|
XdmcpSocketNotify(int fd, int ready, void *data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (state == XDM_OFF)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2017-12-08 08:01:59 -07:00
|
|
|
receive_packet(fd);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2017-12-08 08:01:59 -07:00
|
|
|
static CARD32
|
|
|
|
XdmcpTimerNotify(OsTimerPtr timer, CARD32 time, void *arg)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2017-12-08 08:01:59 -07:00
|
|
|
if (state == XDM_RUN_SESSION) {
|
|
|
|
state = XDM_KEEPALIVE;
|
|
|
|
send_packet();
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2017-12-08 08:01:59 -07:00
|
|
|
else
|
|
|
|
timeout();
|
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This routine should be called from the routine that drives the
|
|
|
|
* user's host menu when the user selects a host
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpSelectHost(const struct sockaddr *host_sockaddr,
|
2014-09-27 11:52:59 -06:00
|
|
|
int host_len, ARRAY8Ptr auth_name)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
state = XDM_START_CONNECTION;
|
|
|
|
memmove(&req_sockaddr, host_sockaddr, host_len);
|
|
|
|
req_socklen = host_len;
|
2014-09-27 11:52:59 -06:00
|
|
|
XdmcpSetAuthentication(auth_name);
|
2006-11-26 11:13:41 -07:00
|
|
|
send_packet();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* !!! this routine should be replaced by a routine that adds
|
|
|
|
* the host to the user's host menu. the current version just
|
|
|
|
* selects the first host to respond with willing message.
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/*ARGSUSED*/ static void
|
|
|
|
XdmcpAddHost(const struct sockaddr *from,
|
|
|
|
int fromlen,
|
2014-09-27 11:52:59 -06:00
|
|
|
ARRAY8Ptr auth_name, ARRAY8Ptr hostname, ARRAY8Ptr status)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2014-09-27 11:52:59 -06:00
|
|
|
XdmcpSelectHost(from, fromlen, auth_name);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A message is queued on the socket; read it and
|
|
|
|
* do the appropriate thing
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static ARRAY8 UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
receive_packet(int socketfd)
|
|
|
|
{
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
struct sockaddr_storage from;
|
|
|
|
#else
|
|
|
|
struct sockaddr_in from;
|
|
|
|
#endif
|
|
|
|
int fromlen = sizeof(from);
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpHeader header;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* read message off socket */
|
2013-06-07 11:28:45 -06:00
|
|
|
if (!XdmcpFill(socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* reset retransmission backoff */
|
|
|
|
timeOutRtx = 0;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!XdmcpReadHeader(&buffer, &header))
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (header.version != XDM_PROTOCOL_VERSION)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
switch (header.opcode) {
|
|
|
|
case WILLING:
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case UNWILLING:
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpFatal("Manager unwilling", &UnwillingMessage);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case ACCEPT:
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_accept_msg(header.length);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case DECLINE:
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_decline_msg(header.length);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case REFUSE:
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_refuse_msg(header.length);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case FAILED:
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_failed_msg(header.length);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case ALIVE:
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_alive_msg(header.length);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send the appropriate message given the current state
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_packet(void)
|
|
|
|
{
|
|
|
|
int rtx;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
switch (state) {
|
|
|
|
case XDM_QUERY:
|
|
|
|
case XDM_BROADCAST:
|
|
|
|
case XDM_INDIRECT:
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
case XDM_MULTICAST:
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
send_query_msg();
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_START_CONNECTION:
|
2012-06-10 07:21:05 -06:00
|
|
|
send_request_msg();
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_MANAGE:
|
2012-06-10 07:21:05 -06:00
|
|
|
send_manage_msg();
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_KEEPALIVE:
|
2012-06-10 07:21:05 -06:00
|
|
|
send_keepalive_msg();
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
rtx = (XDM_MIN_RTX << timeOutRtx);
|
|
|
|
if (rtx > XDM_MAX_RTX)
|
2012-06-10 07:21:05 -06:00
|
|
|
rtx = XDM_MAX_RTX;
|
2017-12-08 08:01:59 -07:00
|
|
|
TimerSet(xdmcp_timer, 0, rtx * 1000, XdmcpTimerNotify, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The session is declared dead for some reason; too many
|
|
|
|
* timeouts, or Keepalive failure.
|
|
|
|
*/
|
|
|
|
|
2007-11-24 12:04:00 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDeadSession(const char *reason)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ErrorF("XDM: %s, declaring session dead\n", reason);
|
2006-11-26 11:13:41 -07:00
|
|
|
state = XDM_INIT_STATE;
|
|
|
|
isItTimeToYield = TRUE;
|
2018-02-18 10:16:37 -07:00
|
|
|
dispatchException |= (OneSession ? DE_TERMINATE : DE_RESET);
|
2017-12-08 08:01:59 -07:00
|
|
|
TimerCancel(xdmcp_timer);
|
2006-11-26 11:13:41 -07:00
|
|
|
timeOutRtx = 0;
|
|
|
|
send_packet();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Timeout waiting for an XDMCP response.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
timeout(void)
|
|
|
|
{
|
|
|
|
timeOutRtx++;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (state == XDM_AWAIT_ALIVE_RESPONSE && timeOutRtx >= XDM_KA_RTX_LIMIT) {
|
|
|
|
XdmcpDeadSession("too many keepalive retransmissions");
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (timeOutRtx >= XDM_RTX_LIMIT) {
|
|
|
|
/* Quit if "-once" specified, otherwise reset and try again. */
|
2006-11-26 11:13:41 -07:00
|
|
|
if (OneSession) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dispatchException |= DE_TERMINATE;
|
|
|
|
ErrorF("XDM: too many retransmissions\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
XdmcpDeadSession("too many retransmissions");
|
|
|
|
}
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Try next address */
|
|
|
|
for (mgrAddr = mgrAddr->ai_next;; mgrAddr = mgrAddr->ai_next) {
|
|
|
|
if (mgrAddr == NULL) {
|
|
|
|
mgrAddr = mgrAddrFirst;
|
|
|
|
}
|
|
|
|
if (mgrAddr->ai_family == AF_INET || mgrAddr->ai_family == AF_INET6)
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifndef SIN6_LEN
|
2012-06-10 07:21:05 -06:00
|
|
|
ManagerAddressLen = mgrAddr->ai_addrlen;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case XDM_COLLECT_QUERY:
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_QUERY;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_COLLECT_BROADCAST_QUERY:
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_BROADCAST;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
case XDM_COLLECT_MULTICAST_QUERY:
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_MULTICAST;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
case XDM_COLLECT_INDIRECT_QUERY:
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_INDIRECT;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_AWAIT_REQUEST_RESPONSE:
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_START_CONNECTION;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_AWAIT_MANAGE_RESPONSE:
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_MANAGE;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_AWAIT_ALIVE_RESPONSE:
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_KEEPALIVE;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
send_packet();
|
|
|
|
}
|
|
|
|
|
2007-11-24 12:04:00 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpCheckAuthentication(ARRAY8Ptr Name, ARRAY8Ptr Data, int packet_type)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return (XdmcpARRAY8Equal(Name, AuthenticationName) &&
|
|
|
|
(AuthenticationName->length == 0 ||
|
|
|
|
(*AuthenticationFuncs->Validator) (AuthenticationData, Data,
|
|
|
|
packet_type)));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 12:04:00 -07:00
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpAddAuthorization(ARRAY8Ptr name, ARRAY8Ptr data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
AddAuthorFunc AddAuth;
|
|
|
|
|
|
|
|
if (AuthenticationFuncs && AuthenticationFuncs->AddAuth)
|
2012-06-10 07:21:05 -06:00
|
|
|
AddAuth = AuthenticationFuncs->AddAuth;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
AddAuth = AddAuthorization;
|
|
|
|
return (*AddAuth) ((unsigned short) name->length,
|
|
|
|
(char *) name->data,
|
|
|
|
(unsigned short) data->length, (char *) data->data);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* from here to the end of this file are routines private
|
|
|
|
* to the state machine.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_xdmcp_sock(void)
|
|
|
|
{
|
|
|
|
int soopts = 1;
|
|
|
|
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpWarning("INET6 UDP socket creation failed");
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpWarning("UDP socket creation failed");
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef SO_BROADCAST
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (setsockopt(xdmcpSocket, SOL_SOCKET, SO_BROADCAST, (char *) &soopts,
|
|
|
|
sizeof(soopts)) < 0)
|
|
|
|
XdmcpWarning("UDP set broadcast socket-option failed");
|
|
|
|
#endif /* SO_BROADCAST */
|
2006-11-26 11:13:41 -07:00
|
|
|
if (xdmcpSocket >= 0 && xdm_from != NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (bind(xdmcpSocket, (struct sockaddr *) &FromAddress,
|
|
|
|
FromAddressLen) < 0) {
|
|
|
|
FatalError("Xserver: failed to bind to -from address: %s\n",
|
|
|
|
xdm_from);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_query_msg(void)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpHeader header;
|
|
|
|
Bool broadcast = FALSE;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool multicast = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
int socketfd = xdmcpSocket;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
header.version = XDM_PROTOCOL_VERSION;
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (state) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_QUERY:
|
2012-06-10 07:21:05 -06:00
|
|
|
header.opcode = (CARD16) QUERY;
|
|
|
|
state = XDM_COLLECT_QUERY;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
case XDM_BROADCAST:
|
2012-06-10 07:21:05 -06:00
|
|
|
header.opcode = (CARD16) BROADCAST_QUERY;
|
|
|
|
state = XDM_COLLECT_BROADCAST_QUERY;
|
|
|
|
broadcast = TRUE;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
case XDM_MULTICAST:
|
2012-06-10 07:21:05 -06:00
|
|
|
header.opcode = (CARD16) BROADCAST_QUERY;
|
|
|
|
state = XDM_COLLECT_MULTICAST_QUERY;
|
|
|
|
multicast = TRUE;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
case XDM_INDIRECT:
|
2012-06-10 07:21:05 -06:00
|
|
|
header.opcode = (CARD16) INDIRECT_QUERY;
|
|
|
|
state = XDM_COLLECT_INDIRECT_QUERY;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
header.length = 1;
|
|
|
|
for (i = 0; i < AuthenticationNames.length; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
header.length += 2 + AuthenticationNames.data[i].length;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpWriteHeader(&buffer, &header);
|
|
|
|
XdmcpWriteARRAYofARRAY8(&buffer, &AuthenticationNames);
|
|
|
|
if (broadcast) {
|
|
|
|
for (i = 0; i < NumBroadcastAddresses; i++)
|
|
|
|
XdmcpFlush(xdmcpSocket, &buffer,
|
2013-06-07 11:28:45 -06:00
|
|
|
(XdmcpNetaddr) &BroadcastAddresses[i],
|
2012-06-10 07:21:05 -06:00
|
|
|
sizeof(struct sockaddr_in));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (multicast) {
|
|
|
|
struct multicastinfo *mcl;
|
|
|
|
struct addrinfo *ai;
|
|
|
|
|
|
|
|
for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) {
|
|
|
|
for (ai = mcl->ai; ai != NULL; ai = ai->ai_next) {
|
|
|
|
if (ai->ai_family == AF_INET) {
|
|
|
|
unsigned char hopflag = (unsigned char) mcl->hops;
|
|
|
|
|
|
|
|
socketfd = xdmcpSocket;
|
|
|
|
setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
|
|
|
|
&hopflag, sizeof(hopflag));
|
|
|
|
}
|
|
|
|
else if (ai->ai_family == AF_INET6) {
|
|
|
|
int hopflag6 = mcl->hops;
|
|
|
|
|
|
|
|
socketfd = xdmcpSocket6;
|
|
|
|
setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
|
|
|
|
&hopflag6, sizeof(hopflag6));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
XdmcpFlush(socketfd, &buffer,
|
|
|
|
(XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (SOCKADDR_FAMILY(ManagerAddress) == AF_INET6)
|
|
|
|
socketfd = xdmcpSocket6;
|
|
|
|
#endif
|
2013-06-07 11:28:45 -06:00
|
|
|
XdmcpFlush(socketfd, &buffer, (XdmcpNetaddr) &ManagerAddress,
|
2012-06-10 07:21:05 -06:00
|
|
|
ManagerAddressLen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_willing_msg(struct sockaddr *from, int fromlen, unsigned length)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ARRAY8 authenticationName;
|
|
|
|
ARRAY8 hostname;
|
|
|
|
ARRAY8 status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
authenticationName.data = 0;
|
|
|
|
hostname.data = 0;
|
|
|
|
status.data = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XdmcpReadARRAY8(&buffer, &authenticationName) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &hostname) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &status)) {
|
|
|
|
if (length == 6 + authenticationName.length +
|
|
|
|
hostname.length + status.length) {
|
|
|
|
switch (state) {
|
|
|
|
case XDM_COLLECT_QUERY:
|
|
|
|
XdmcpSelectHost(from, fromlen, &authenticationName);
|
|
|
|
break;
|
|
|
|
case XDM_COLLECT_BROADCAST_QUERY:
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
case XDM_COLLECT_MULTICAST_QUERY:
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
case XDM_COLLECT_INDIRECT_QUERY:
|
|
|
|
XdmcpAddHost(from, fromlen, &authenticationName, &hostname,
|
|
|
|
&status);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDisposeARRAY8(&authenticationName);
|
|
|
|
XdmcpDisposeARRAY8(&hostname);
|
|
|
|
XdmcpDisposeARRAY8(&status);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_request_msg(void)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpHeader header;
|
|
|
|
int length;
|
|
|
|
int i;
|
|
|
|
CARD16 XdmcpConnectionType;
|
|
|
|
ARRAY8 authenticationData;
|
|
|
|
int socketfd = xdmcpSocket;
|
|
|
|
|
|
|
|
switch (SOCKADDR_FAMILY(ManagerAddress)) {
|
|
|
|
case AF_INET:
|
|
|
|
XdmcpConnectionType = FamilyInternet;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
case AF_INET6:
|
|
|
|
XdmcpConnectionType = FamilyInternet6;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
default:
|
|
|
|
XdmcpConnectionType = 0xffff;
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
header.version = XDM_PROTOCOL_VERSION;
|
|
|
|
header.opcode = (CARD16) REQUEST;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
length = 2; /* display number */
|
|
|
|
length += 1 + 2 * ConnectionTypes.length; /* connection types */
|
|
|
|
length += 1; /* connection addresses */
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < ConnectionAddresses.length; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
length += 2 + ConnectionAddresses.data[i].length;
|
2006-11-26 11:13:41 -07:00
|
|
|
authenticationData.length = 0;
|
|
|
|
authenticationData.data = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (AuthenticationFuncs) {
|
|
|
|
(*AuthenticationFuncs->Generator) (AuthenticationData,
|
|
|
|
&authenticationData, REQUEST);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
length += 2 + AuthenticationName->length; /* authentication name */
|
|
|
|
length += 2 + authenticationData.length; /* authentication data */
|
|
|
|
length += 1; /* authorization names */
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < AuthorizationNames.length; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
length += 2 + AuthorizationNames.data[i].length;
|
|
|
|
length += 2 + ManufacturerDisplayID.length; /* display ID */
|
2006-11-26 11:13:41 -07:00
|
|
|
header.length = length;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!XdmcpWriteHeader(&buffer, &header)) {
|
|
|
|
XdmcpDisposeARRAY8(&authenticationData);
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpWriteCARD16(&buffer, DisplayNumber);
|
|
|
|
XdmcpWriteCARD8(&buffer, ConnectionTypes.length);
|
|
|
|
|
|
|
|
/* The connection array is send reordered, so that connections of */
|
|
|
|
/* the same address type as the XDMCP manager connection are send */
|
|
|
|
/* first. This works around a bug in xdm. mario@klebsch.de */
|
|
|
|
for (i = 0; i < (int) ConnectionTypes.length; i++)
|
|
|
|
if (ConnectionTypes.data[i] == XdmcpConnectionType)
|
|
|
|
XdmcpWriteCARD16(&buffer, ConnectionTypes.data[i]);
|
|
|
|
for (i = 0; i < (int) ConnectionTypes.length; i++)
|
|
|
|
if (ConnectionTypes.data[i] != XdmcpConnectionType)
|
|
|
|
XdmcpWriteCARD16(&buffer, ConnectionTypes.data[i]);
|
|
|
|
|
|
|
|
XdmcpWriteCARD8(&buffer, ConnectionAddresses.length);
|
|
|
|
for (i = 0; i < (int) ConnectionAddresses.length; i++)
|
|
|
|
if ((i < ConnectionTypes.length) &&
|
|
|
|
(ConnectionTypes.data[i] == XdmcpConnectionType))
|
|
|
|
XdmcpWriteARRAY8(&buffer, &ConnectionAddresses.data[i]);
|
|
|
|
for (i = 0; i < (int) ConnectionAddresses.length; i++)
|
|
|
|
if ((i >= ConnectionTypes.length) ||
|
|
|
|
(ConnectionTypes.data[i] != XdmcpConnectionType))
|
|
|
|
XdmcpWriteARRAY8(&buffer, &ConnectionAddresses.data[i]);
|
|
|
|
|
|
|
|
XdmcpWriteARRAY8(&buffer, AuthenticationName);
|
|
|
|
XdmcpWriteARRAY8(&buffer, &authenticationData);
|
|
|
|
XdmcpDisposeARRAY8(&authenticationData);
|
|
|
|
XdmcpWriteARRAYofARRAY8(&buffer, &AuthorizationNames);
|
|
|
|
XdmcpWriteARRAY8(&buffer, &ManufacturerDisplayID);
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
socketfd = xdmcpSocket6;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XdmcpFlush(socketfd, &buffer,
|
2013-06-07 11:28:45 -06:00
|
|
|
(XdmcpNetaddr) &req_sockaddr, req_socklen))
|
2012-06-10 07:21:05 -06:00
|
|
|
state = XDM_AWAIT_REQUEST_RESPONSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
recv_accept_msg(unsigned length)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CARD32 AcceptSessionID;
|
|
|
|
ARRAY8 AcceptAuthenticationName, AcceptAuthenticationData;
|
|
|
|
ARRAY8 AcceptAuthorizationName, AcceptAuthorizationData;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (state != XDM_AWAIT_REQUEST_RESPONSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
AcceptAuthenticationName.data = 0;
|
|
|
|
AcceptAuthenticationData.data = 0;
|
|
|
|
AcceptAuthorizationName.data = 0;
|
|
|
|
AcceptAuthorizationData.data = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XdmcpReadCARD32(&buffer, &AcceptSessionID) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &AcceptAuthenticationName) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &AcceptAuthenticationData) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &AcceptAuthorizationName) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &AcceptAuthorizationData)) {
|
|
|
|
if (length == 12 + AcceptAuthenticationName.length +
|
|
|
|
AcceptAuthenticationData.length +
|
|
|
|
AcceptAuthorizationName.length + AcceptAuthorizationData.length) {
|
|
|
|
if (!XdmcpCheckAuthentication(&AcceptAuthenticationName,
|
|
|
|
&AcceptAuthenticationData, ACCEPT)) {
|
|
|
|
XdmcpFatal("Authentication Failure", &AcceptAuthenticationName);
|
|
|
|
}
|
|
|
|
/* permit access control manipulations from this host */
|
|
|
|
AugmentSelf(&req_sockaddr, req_socklen);
|
|
|
|
/* if the authorization specified in the packet fails
|
|
|
|
* to be acceptable, enable the local addresses
|
|
|
|
*/
|
|
|
|
if (!XdmcpAddAuthorization(&AcceptAuthorizationName,
|
|
|
|
&AcceptAuthorizationData)) {
|
|
|
|
AddLocalHosts();
|
|
|
|
}
|
|
|
|
SessionID = AcceptSessionID;
|
|
|
|
state = XDM_MANAGE;
|
|
|
|
send_packet();
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDisposeARRAY8(&AcceptAuthenticationName);
|
|
|
|
XdmcpDisposeARRAY8(&AcceptAuthenticationData);
|
|
|
|
XdmcpDisposeARRAY8(&AcceptAuthorizationName);
|
|
|
|
XdmcpDisposeARRAY8(&AcceptAuthorizationData);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
recv_decline_msg(unsigned length)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ARRAY8 status, DeclineAuthenticationName, DeclineAuthenticationData;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
status.data = 0;
|
|
|
|
DeclineAuthenticationName.data = 0;
|
|
|
|
DeclineAuthenticationData.data = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XdmcpReadARRAY8(&buffer, &status) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &DeclineAuthenticationName) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &DeclineAuthenticationData)) {
|
|
|
|
if (length == 6 + status.length +
|
|
|
|
DeclineAuthenticationName.length +
|
|
|
|
DeclineAuthenticationData.length &&
|
|
|
|
XdmcpCheckAuthentication(&DeclineAuthenticationName,
|
|
|
|
&DeclineAuthenticationData, DECLINE)) {
|
|
|
|
XdmcpFatal("Session declined", &status);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDisposeARRAY8(&status);
|
|
|
|
XdmcpDisposeARRAY8(&DeclineAuthenticationName);
|
|
|
|
XdmcpDisposeARRAY8(&DeclineAuthenticationData);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_manage_msg(void)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpHeader header;
|
2006-11-26 11:13:41 -07:00
|
|
|
int socketfd = xdmcpSocket;
|
|
|
|
|
|
|
|
header.version = XDM_PROTOCOL_VERSION;
|
|
|
|
header.opcode = (CARD16) MANAGE;
|
|
|
|
header.length = 8 + DisplayClass.length;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!XdmcpWriteHeader(&buffer, &header))
|
|
|
|
return;
|
|
|
|
XdmcpWriteCARD32(&buffer, SessionID);
|
|
|
|
XdmcpWriteCARD16(&buffer, DisplayNumber);
|
|
|
|
XdmcpWriteARRAY8(&buffer, &DisplayClass);
|
2006-11-26 11:13:41 -07:00
|
|
|
state = XDM_AWAIT_MANAGE_RESPONSE;
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
socketfd = xdmcpSocket6;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2013-06-07 11:28:45 -06:00
|
|
|
XdmcpFlush(socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
recv_refuse_msg(unsigned length)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CARD32 RefusedSessionID;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (state != XDM_AWAIT_MANAGE_RESPONSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (length != 4)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
if (XdmcpReadCARD32(&buffer, &RefusedSessionID)) {
|
|
|
|
if (RefusedSessionID == SessionID) {
|
|
|
|
state = XDM_START_CONNECTION;
|
|
|
|
send_packet();
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
recv_failed_msg(unsigned length)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CARD32 FailedSessionID;
|
|
|
|
ARRAY8 status;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (state != XDM_AWAIT_MANAGE_RESPONSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
status.data = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (XdmcpReadCARD32(&buffer, &FailedSessionID) &&
|
|
|
|
XdmcpReadARRAY8(&buffer, &status)) {
|
|
|
|
if (length == 6 + status.length && SessionID == FailedSessionID) {
|
|
|
|
XdmcpFatal("Session failed", &status);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpDisposeARRAY8(&status);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
send_keepalive_msg(void)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpHeader header;
|
2006-11-26 11:13:41 -07:00
|
|
|
int socketfd = xdmcpSocket;
|
|
|
|
|
|
|
|
header.version = XDM_PROTOCOL_VERSION;
|
|
|
|
header.opcode = (CARD16) KEEPALIVE;
|
|
|
|
header.length = 6;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
XdmcpWriteHeader(&buffer, &header);
|
|
|
|
XdmcpWriteCARD16(&buffer, DisplayNumber);
|
|
|
|
XdmcpWriteCARD32(&buffer, SessionID);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
state = XDM_AWAIT_ALIVE_RESPONSE;
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if (SOCKADDR_FAMILY(req_sockaddr) == AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
socketfd = xdmcpSocket6;
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2013-06-07 11:28:45 -06:00
|
|
|
XdmcpFlush(socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
recv_alive_msg(unsigned length)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CARD8 SessionRunning;
|
|
|
|
CARD32 AliveSessionID;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (state != XDM_AWAIT_ALIVE_RESPONSE)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (length != 5)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
if (XdmcpReadCARD8(&buffer, &SessionRunning) &&
|
|
|
|
XdmcpReadCARD32(&buffer, &AliveSessionID)) {
|
|
|
|
if (SessionRunning && AliveSessionID == SessionID) {
|
|
|
|
state = XDM_RUN_SESSION;
|
2017-12-08 08:01:59 -07:00
|
|
|
TimerSet(xdmcp_timer, 0, XDM_DEF_DORMANCY * 1000, XdmcpTimerNotify, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
XdmcpDeadSession("Alive response indicates session dead");
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-07 09:48:51 -07:00
|
|
|
_X_NORETURN
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
XdmcpFatal(const char *type, ARRAY8Ptr status)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
FatalError("XDMCP fatal error: %s %*.*s\n", type,
|
|
|
|
status->length, status->length, status->data);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
2010-12-05 08:36:02 -07:00
|
|
|
XdmcpWarning(const char *str)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ErrorF("XDMCP warning: %s\n", str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
get_addr_by_name(const char *argtype,
|
|
|
|
const char *namestr,
|
|
|
|
int port,
|
|
|
|
int socktype, SOCKADDR_TYPE * addr, SOCKLEN_TYPE * addrlen
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
, struct addrinfo **aip, struct addrinfo **aifirstp
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
struct addrinfo *ai;
|
|
|
|
struct addrinfo hints;
|
|
|
|
char portstr[6];
|
|
|
|
char *pport = portstr;
|
|
|
|
int gaierr;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
memset(&hints, 0, sizeof(hints));
|
2006-11-26 11:13:41 -07:00
|
|
|
hints.ai_socktype = socktype;
|
|
|
|
|
|
|
|
if (port == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pport = NULL;
|
|
|
|
}
|
|
|
|
else if (port > 0 && port < 65535) {
|
|
|
|
snprintf(portstr, sizeof(portstr), "%d", port);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FatalError("Xserver: port out of range: %d\n", port);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*aifirstp != NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
freeaddrinfo(*aifirstp);
|
|
|
|
*aifirstp = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) {
|
|
|
|
if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) {
|
|
|
|
FatalError("Xserver: %s host %s not on supported network type\n",
|
|
|
|
argtype, namestr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aip = ai;
|
|
|
|
*addrlen = ai->ai_addrlen;
|
|
|
|
memcpy(addr, ai->ai_addr, ai->ai_addrlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FatalError("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype,
|
|
|
|
namestr);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
#else
|
|
|
|
struct hostent *hep;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
|
|
|
|
_Xgethostbynameparams hparams;
|
|
|
|
#endif
|
2011-11-05 07:32:40 -06:00
|
|
|
#if defined(WIN32) && defined(TCPCONN)
|
2012-06-10 07:21:05 -06:00
|
|
|
_XSERVTransWSAStartup();
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!(hep = _XGethostbyname(namestr, hparams))) {
|
|
|
|
FatalError("Xserver: %s unknown host: %s\n", argtype, namestr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (hep->h_length == sizeof(struct in_addr)) {
|
|
|
|
memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
|
|
|
|
*addrlen = sizeof(struct sockaddr_in);
|
|
|
|
addr->sin_family = AF_INET;
|
|
|
|
addr->sin_port = htons(port);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
FatalError("Xserver: %s host on strange network %s\n", argtype,
|
|
|
|
namestr);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
get_manager_by_name(int argc, char **argv, int i)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((i + 1) == argc) {
|
|
|
|
FatalError("Xserver: missing %s host name in command line\n", argv[i]);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
get_addr_by_name(argv[i], argv[i + 1], xdm_udp_port, SOCK_DGRAM,
|
|
|
|
&ManagerAddress, &ManagerAddressLen
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
, &mgrAddr, &mgrAddrFirst
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
get_fromaddr_by_name(int argc, char **argv, int i)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
struct addrinfo *ai = NULL;
|
|
|
|
struct addrinfo *aifirst = NULL;
|
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
if (i == argc) {
|
|
|
|
FatalError("Xserver: missing -from host name in command line\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-06-10 07:21:05 -06:00
|
|
|
, &ai, &aifirst
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
);
|
2006-11-26 11:13:41 -07:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
if (aifirst != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
freeaddrinfo(aifirst);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
|
|
|
xdm_from = argv[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
get_mcast_options(int argc, char **argv, int i)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *address = XDM_DEFAULT_MCAST_ADDR6;
|
2006-11-26 11:13:41 -07:00
|
|
|
int hopcount = 1;
|
|
|
|
struct addrinfo hints;
|
|
|
|
char portstr[6];
|
|
|
|
int gaierr;
|
|
|
|
struct addrinfo *ai, *firstai;
|
|
|
|
|
|
|
|
if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
|
2012-06-10 07:21:05 -06:00
|
|
|
address = argv[i++];
|
|
|
|
if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
|
|
|
|
hopcount = strtol(argv[i++], NULL, 10);
|
|
|
|
if ((hopcount < 1) || (hopcount > 255)) {
|
|
|
|
FatalError("Xserver: multicast hop count out of range: %d\n",
|
|
|
|
hopcount);
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xdm_udp_port > 0 && xdm_udp_port < 65535) {
|
2012-06-10 07:21:05 -06:00
|
|
|
snprintf(portstr, sizeof(portstr), "%d", xdm_udp_port);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FatalError("Xserver: port out of range: %d\n", xdm_udp_port);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
memset(&hints, 0, sizeof(hints));
|
2006-11-26 11:13:41 -07:00
|
|
|
hints.ai_socktype = SOCK_DGRAM;
|
|
|
|
|
|
|
|
if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (ai = firstai; ai != NULL; ai = ai->ai_next) {
|
|
|
|
if (((ai->ai_family == AF_INET) &&
|
|
|
|
IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr)
|
|
|
|
->sin_addr.s_addr))
|
|
|
|
|| ((ai->ai_family == AF_INET6) &&
|
|
|
|
IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr)
|
|
|
|
->sin6_addr)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ai == NULL) {
|
|
|
|
FatalError("Xserver: address not supported multicast type %s\n",
|
|
|
|
address);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct multicastinfo *mcastinfo, *mcl;
|
|
|
|
|
|
|
|
mcastinfo = malloc(sizeof(struct multicastinfo));
|
|
|
|
mcastinfo->next = NULL;
|
|
|
|
mcastinfo->ai = firstai;
|
|
|
|
mcastinfo->hops = hopcount;
|
|
|
|
|
|
|
|
if (mcastlist == NULL) {
|
|
|
|
mcastlist = mcastinfo;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) {
|
|
|
|
/* Do nothing - just find end of list */
|
|
|
|
}
|
|
|
|
mcl->next = mcastinfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FatalError("Xserver: %s: %s\n", gai_strerror(gaierr), address);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
2012-06-10 07:21:05 -06:00
|
|
|
static int xdmcp_non_empty; /* avoid complaint by ranlib */
|
|
|
|
#endif /* XDMCP */
|