Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 24445
Collapse All | Expand All

(-)4.3.0/xc/LABEL (-1 / +1 lines)
Lines 1-5 Link Here
1
		     X Window System, Version 11
1
		     X Window System, Version 11
2
			     Release 6.4
2
			     Release 6.6
3
3
4
			Portions Copyright by:
4
			Portions Copyright by:
5
5
(-)4.3.0/xc/config/cf/FreeBSD.cf (+4 lines)
Lines 489-494 Link Here
489
#endif
489
#endif
490
#endif
490
#endif
491
491
492
#if OSMajorVersion >= 4
493
#define HasIPv6 		YES
494
#endif
495
492
#ifdef i386Architecture
496
#ifdef i386Architecture
493
# define OptimizedCDebugFlags DefaultGcc2i386Opt
497
# define OptimizedCDebugFlags DefaultGcc2i386Opt
494
#else
498
#else
(-)4.3.0/xc/config/cf/NetBSD.cf (+7 lines)
Lines 648-650 Link Here
648
#ifndef UseSeparateConfDir
648
#ifndef UseSeparateConfDir
649
#define UseSeparateConfDir NO	/* We don't want appdefs in "/etc/X11". */
649
#define UseSeparateConfDir NO	/* We don't want appdefs in "/etc/X11". */
650
#endif
650
#endif
651
652
#if defined(NetBSDArchitecture) && \
653
     ((OSMajorVersion > 1) || \
654
      (OSMajorVersion == 1 && OSMinorVersion > 3))
655
#define HasDevRandom		YES
656
#define RandomDeviceFile	/dev/urandom
657
#endif
(-)4.3.0/xc/config/cf/X11.tmpl (-6 / +42 lines)
Lines 1-6 Link Here
1
XCOMM ----------------------------------------------------------------------
1
XCOMM ----------------------------------------------------------------------
2
XCOMM X Window System Build Parameters and Rules
2
XCOMM X Window System Build Parameters and Rules
3
XCOMM $Xorg: X11.tmpl,v 1.6 2000/08/17 19:41:46 cpqbld Exp $
3
XCOMM $Xorg: X11.tmpl,v 1.6 2000/08/17 19:41:46 cpqbld Exp $
4
XCOMM Updated for IPv6
4
XCOMM
5
XCOMM
5
XCOMM
6
XCOMM
6
XCOMM
7
XCOMM
Lines 761-776 Link Here
761
#ifndef FontCompilerFlags
762
#ifndef FontCompilerFlags
762
#define FontCompilerFlags -t
763
#define FontCompilerFlags -t
763
#endif
764
#endif
764
#ifndef ConnectionFlags
765
#ifndef HasIPv6
765
#if HasStreams
766
#define HasIPv6			NO
766
#define ConnectionFlags -DSTREAMSCONN
767
#endif
768
#ifndef IPv6Flags
769
#if HasIPv6
770
#define IPv6Flags -DIPv6
767
#else
771
#else
772
#define IPv6Flags
773
#endif
774
#endif
775
#ifndef DECnetFlags
768
#if HasDECnet
776
#if HasDECnet
769
#define ConnectionFlags -DTCPCONN -DUNIXCONN -DDNETCONN
777
#define DECnetFlags -DDNETCONN
770
#else
778
#else
771
#define ConnectionFlags -DTCPCONN -DUNIXCONN
779
#define DECnetFlags
772
#endif
780
#endif
773
#endif
781
#endif
782
#ifndef ConnectionFlags
783
#if HasStreams
784
#define ConnectionFlags -DSTREAMSCONN
785
#else
786
#define ConnectionFlags -DTCPCONN -DUNIXCONN DECnetFlags
787
#endif
774
#endif
788
#endif
775
#if HasStickyDirBit
789
#if HasStickyDirBit
776
STICKY_DEFINES = -DHAS_STICKY_DIR_BIT
790
STICKY_DEFINES = -DHAS_STICKY_DIR_BIT
Lines 779-785 Link Here
779
FCHOWN_DEFINES = -DHAS_FCHOWN
793
FCHOWN_DEFINES = -DHAS_FCHOWN
780
#endif
794
#endif
781
#ifndef ExtraConnectionDefs
795
#ifndef ExtraConnectionDefs
782
#define ExtraConnectionDefs $(STICKY_DEFINES) $(FCHOWN_DEFINES)
796
#define ExtraConnectionDefs $(STICKY_DEFINES) $(FCHOWN_DEFINES) IPv6Flags
783
#endif
797
#endif
784
#ifndef ProjectThreadsDefines
798
#ifndef ProjectThreadsDefines
785
#define ProjectThreadsDefines -DXTHREADS
799
#define ProjectThreadsDefines -DXTHREADS
Lines 1140-1145 Link Here
1140
#  define StrcasecmpDefines /**/
1154
#  define StrcasecmpDefines /**/
1141
# else
1155
# else
1142
#  define StrcasecmpDefines -DNEED_STRCASECMP
1156
#  define StrcasecmpDefines -DNEED_STRCASECMP
1157
# endif
1158
#endif
1159
1160
#ifndef HasDevRandom
1161
#define HasDevRandom NO
1162
#endif
1163
1164
#ifndef RandomDefines
1165
# if HasDevRandom
1166
#  ifndef RandomDeviceFile
1167
#   define RandomDeviceFile /dev/random
1168
#  endif
1169
#  ifndef ExtraRandomDefines
1170
#   ifdef PollDevRandom /* Set if can poll() /dev/random to avoid blocking */
1171
#    define ExtraRandomDefines -DPOLL_DEV_RANDOM
1172
#   else
1173
#    define ExtraRandomDefines /**/
1174
#   endif
1175
#  endif
1176
#  define RandomDefines -DDEV_RANDOM=\"RandomDeviceFile\" ExtraRandomDefines
1177
# else
1178
#  define RandomDefines /**/
1143
# endif
1179
# endif
1144
#endif
1180
#endif
1145
1181
(-)4.3.0/xc/config/cf/sun.cf (-2 / +7 lines)
Lines 1-5 Link Here
1
XCOMM platform:  $Xorg: sun.cf,v 1.4 2000/08/17 19:41:48 cpqbld Exp $
1
XCOMM platform:  $Xorg: sun.cf,v 1.4 2000/08/17 19:41:48 cpqbld Exp $
2
2
XCOMM Updated for IPv6 
3
3
4
4
5
5
Lines 302-307 Link Here
302
#define HasSecureRPC	  YES
302
#define HasSecureRPC	  YES
303
#define SetTtyGroup	  YES
303
#define SetTtyGroup	  YES
304
#define HasPutenv	  YES
304
#define HasPutenv	  YES
305
#if (OSMajorVersion > 5) || ( (OSMajorVersion == 5) && (OSMinorVersion >= 8))
306
#define HasIPv6		  YES   /* IPv6 is in SunOS 5.8 (Solaris 8) & later */
307
#define HasDevRandom	  YES	/* /dev/random is in Solaris 8 patches 	*/
308
#define PollDevRandom	  YES	/* /dev/random is poll()able on Solaris */
309
#endif
305
#if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 9))
310
#if (OSMajorVersion > 5) || ((OSMajorVersion == 5) && (OSMinorVersion >= 9))
306
# define HasIssetugid	  YES
311
# define HasIssetugid	  YES
307
#endif
312
#endif
Lines 406-412 Link Here
406
#    endif
411
#    endif
407
#   else /* OSMajorVersion >= 5*/
412
#   else /* OSMajorVersion >= 5*/
408
#    ifndef DefaultCCOptions
413
#    ifndef DefaultCCOptions
409
#     define DefaultCCOptions -Xa
414
#     define DefaultCCOptions -Xa -v
410
#    endif
415
#    endif
411
#   endif	
416
#   endif	
412
#  endif	
417
#  endif	
(-)4.3.0/xc/config/makedepend/main.c (-2 / +2 lines)
Lines 57-65 Link Here
57
57
58
/* #define DEBUG_DUMP */
58
/* #define DEBUG_DUMP */
59
#ifdef DEBUG_DUMP
59
#ifdef DEBUG_DUMP
60
#define DBG_PRINT(args...)   fprintf(args)
60
#define DBG_PRINT(a,b,c)   fprintf(a,b,c)
61
#else
61
#else
62
#define DBG_PRINT(args...)   /* empty */
62
#define DBG_PRINT(a,b,c)   /* empty */
63
#endif
63
#endif
64
64
65
#define DASH_INC_PRE    "#include \""
65
#define DASH_INC_PRE    "#include \""
(-)4.3.0/xc/include/X.h (-1 / +3 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 *	$Xorg: X.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $
2
 *	$Xorg: X.h,v 1.4 2001/02/09 02:03:22 xorgcvs Exp $
3
 *	Updated for IPv6
3
 */
4
 */
4
5
5
/* Definitions for the X window system likely to be used by applications */
6
/* Definitions for the X window system likely to be used by applications */
Lines 299-307 Link Here
299
300
300
/* protocol families */
301
/* protocol families */
301
302
302
#define FamilyInternet		0
303
#define FamilyInternet		0	/* IPv4 */
303
#define FamilyDECnet		1
304
#define FamilyDECnet		1
304
#define FamilyChaos		2
305
#define FamilyChaos		2
306
#define FamilyInternetV6	6	/* IPv6 */
305
307
306
/* Property notification */
308
/* Property notification */
307
309
(-)4.3.0/xc/include/fonts/FS.h (+1 lines)
Lines 66-71 Link Here
66
#define FamilyInternet          0
66
#define FamilyInternet          0
67
#define FamilyDECnet            1
67
#define FamilyDECnet            1
68
#define FamilyChaos             2
68
#define FamilyChaos             2
69
#define FamilyInternetV6        6
69
70
70
71
71
typedef unsigned int    FSDrawDirection;
72
typedef unsigned int    FSDrawDirection;
(-)4.3.0/xc/lib/SM/sm_genid.c (-3 / +39 lines)
Lines 1-8 Link Here
1
/* $Xorg: sm_genid.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */
1
/* $Xorg: sm_genid.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */
2
2
/* Updated for IPv6 */
3
/*
3
/*
4
4
5
Copyright 1993, 1998  The Open Group
5
Copyright 1993, 1998  The Open Group
6
Copyright 2002 Sun Microsystems, Inc.
6
7
7
Permission to use, copy, modify, distribute, and sell this software and its
8
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
documentation for any purpose is hereby granted without fee, provided that
Lines 120-126 Link Here
120
{
121
{
121
#if defined(TCPCONN) || defined(STREAMSCONN)
122
#if defined(TCPCONN) || defined(STREAMSCONN)
122
    char hostname[256];
123
    char hostname[256];
123
    char address[14];
124
    char address[64];
124
    char temp[256];
125
    char temp[256];
125
    char *id;
126
    char *id;
126
    static int sequence = 0;
127
    static int sequence = 0;
Lines 133-147 Link Here
133
    char temp[4], *ptr1, *ptr2;
134
    char temp[4], *ptr1, *ptr2;
134
    unsigned char decimal[4];
135
    unsigned char decimal[4];
135
    int i, len;
136
    int i, len;
137
    struct in_addr *haddr = NULL;
138
#ifdef IPv6
139
    struct addrinfo *ai, *first_ai;
140
    if (getaddrinfo(hostname,NULL,NULL,&ai) == 0) {
141
	for (first_ai = ai; ai != NULL; ai = ai->ai_next) {
142
	    if ( (ai->ai_family == AF_INET) || (ai->ai_family == AF_INET6) ) 
143
		break;
144
	}
145
	if (ai == NULL) {
146
	    freeaddrinfo(first_ai);
147
	    return NULL;
148
	} 
149
    } else
150
	return NULL;
151
152
    if (ai->ai_family == AF_INET6) {
153
	unsigned char *cp = (unsigned char *) &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr.s6_addr;
154
	
155
	address[0] = '6';	/* IPv6 address code */
156
	address[1] = '\0';
157
158
	for (i = 0 ; i < 16 ; i++) {
159
	    strcat(address, hex_table[cp[i]]);
160
	}
161
162
    } else { /* Fall through to IPv4 address handling */
163
	haddr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr;
164
#else
136
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
165
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
137
    _Xgethostbynameparams hparams;
166
    _Xgethostbynameparams hparams;
138
#endif
167
#endif
139
    struct hostent *hostp;
168
    struct hostent *hostp;
140
169
141
    if ((hostp = _XGethostbyname (hostname,hparams)) != NULL)
170
    if ((hostp = _XGethostbyname (hostname,hparams)) != NULL)
142
	inet_addr = inet_ntoa (*(struct in_addr *)(hostp->h_addr));
171
	haddr = (struct in_addr *)(hostp->h_addr);
143
    else
172
    else
144
	return NULL;
173
	return NULL;
174
#endif
175
176
    inet_addr = inet_ntoa (*haddr);
145
    for (i = 0, ptr1 = inet_addr; i < 3; i++)
177
    for (i = 0, ptr1 = inet_addr; i < 3; i++)
146
    {
178
    {
147
	ptr2 = strchr (ptr1, '.');
179
	ptr2 = strchr (ptr1, '.');
Lines 160-165 Link Here
160
    address[1] = '\0';
192
    address[1] = '\0';
161
    for (i = 0; i < 4; i++)
193
    for (i = 0; i < 4; i++)
162
	strcat (address, hex_table[decimal[i]]);
194
	strcat (address, hex_table[decimal[i]]);
195
#ifdef IPv6
196
    }
197
    freeaddrinfo(first_ai);
198
#endif
163
    }
199
    }
164
200
165
    sprintf (temp, "1%s%.13ld%.10ld%.4d", address, time((Time_t*)0),
201
    sprintf (temp, "1%s%.13ld%.10ld%.4d", address, time((Time_t*)0),
(-)4.3.0/xc/lib/X11/ConnDis.c (+4 lines)
Lines 692-698 Link Here
692
        AUTH           *a;
692
        AUTH           *a;
693
        XDR             xdr;
693
        XDR             xdr;
694
694
695
#if (defined(SVR4) && defined(sun))
696
        a = authdes_seccreate(servername, window, NULL, NULL);
697
#else
695
        a = (AUTH *)authdes_create(servername, window, NULL, NULL);
698
        a = (AUTH *)authdes_create(servername, window, NULL, NULL);
699
#endif
696
        if (a == (AUTH *)NULL) {
700
        if (a == (AUTH *)NULL) {
697
                perror("auth_create");
701
                perror("auth_create");
698
                return 0;
702
                return 0;
(-)4.3.0/xc/lib/X11/ICWrap.c (-4 / +4 lines)
Lines 395-403 Link Here
395
    XIC ic;
395
    XIC ic;
396
{
396
{
397
    if (ic->core.im) {
397
    if (ic->core.im) {
398
	if (*ic->methods->utf8_reset)
398
	if (ic->methods->utf8_reset)
399
	    return (*ic->methods->utf8_reset)(ic);
399
	    return (*ic->methods->utf8_reset)(ic);
400
	else if (*ic->methods->mb_reset)
400
	else if (ic->methods->mb_reset)
401
	    return (*ic->methods->mb_reset)(ic);
401
	    return (*ic->methods->mb_reset)(ic);
402
    }
402
    }
403
    return (char *)NULL;
403
    return (char *)NULL;
Lines 443-452 Link Here
443
    Status *status;
443
    Status *status;
444
{
444
{
445
    if (ic->core.im) {
445
    if (ic->core.im) {
446
	if (*ic->methods->utf8_lookup_string)
446
	if (ic->methods->utf8_lookup_string)
447
	    return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
447
	    return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
448
						   	keysym, status);
448
						   	keysym, status);
449
	else if (*ic->methods->mb_lookup_string)
449
	else if (ic->methods->mb_lookup_string)
450
	    return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
450
	    return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
451
						   	keysym, status);
451
						   	keysym, status);
452
    }
452
    }
(-)4.3.0/xc/lib/Xdmcp/Xdmcp.h (+3 lines)
Lines 46-51 Link Here
46
    XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE,
46
    XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE,
47
    XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF,
47
    XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF,
48
    XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE
48
    XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE
49
#ifdef IPv6
50
    , XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY
51
#endif
49
} xdmcp_states;
52
} xdmcp_states;
50
53
51
#ifdef NOTDEF
54
#ifdef NOTDEF
(-)4.3.0/xc/lib/xtrans/Xtrans.c (-21 / +31 lines)
Lines 1-4 Link Here
1
/* $Xorg: Xtrans.c,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
1
/* $Xorg: Xtrans.c,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
2
/* Updated for IPv6 */
2
/*
3
/*
3
4
4
Copyright 1993, 1994, 1998  The Open Group
5
Copyright 1993, 1994, 1998  The Open Group
Lines 134-140 Link Here
134
TRANS(FreeConnInfo) (XtransConnInfo ciptr)
135
TRANS(FreeConnInfo) (XtransConnInfo ciptr)
135
136
136
{
137
{
137
    PRMSG (3,"FreeConnInfo(%x)\n", ciptr, 0, 0);
138
    PRMSG (3,"FreeConnInfo(%p)\n", ciptr, 0, 0);
138
139
139
    if (ciptr->addr)
140
    if (ciptr->addr)
140
	xfree (ciptr->addr);
141
	xfree (ciptr->addr);
Lines 166-171 Link Here
166
     */
167
     */
167
168
168
    strncpy (protobuf, protocol, PROTOBUFSIZE - 1);
169
    strncpy (protobuf, protocol, PROTOBUFSIZE - 1);
170
    protobuf[PROTOBUFSIZE-1] = '\0';
169
171
170
    for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
172
    for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
171
	if (isupper (protobuf[i]))
173
	if (isupper (protobuf[i]))
Lines 198-204 Link Here
198
     * Other than fontlib, the address is a string formatted
200
     * Other than fontlib, the address is a string formatted
199
     * as "protocol/host:port".
201
     * as "protocol/host:port".
200
     *
202
     *
201
     * If the protocol part is missing, then assume INET.
203
     * If the protocol part is missing, then assume TCP.
202
     * If the protocol part and host part are missing, then assume local.
204
     * If the protocol part and host part are missing, then assume local.
203
     * If a "::" is found then assume DNET.
205
     * If a "::" is found then assume DNET.
204
     */
206
     */
Lines 220-228 Link Here
220
222
221
    _protocol = mybuf;
223
    _protocol = mybuf;
222
224
223
    if ((mybuf = strpbrk (mybuf,"/:")) == NULL)
225
224
    {
226
   if ( ((mybuf = strchr (mybuf,'/')) == NULL) &&
225
	/* adress is in a bad format */
227
      ((mybuf = strrchr (tmpptr,':')) == NULL) )
228
   {
229
	/* address is in a bad format */
226
	*protocol = NULL;
230
	*protocol = NULL;
227
	*host = NULL;
231
	*host = NULL;
228
	*port = NULL;
232
	*port = NULL;
Lines 233-239 Link Here
233
    if (*mybuf == ':')
237
    if (*mybuf == ':')
234
    {
238
    {
235
	/*
239
	/*
236
	 * If there is a hostname, then assume inet, otherwise
240
	 * If there is a hostname, then assume tcp, otherwise
237
	 * it must be local.
241
	 * it must be local.
238
	 */
242
	 */
239
	if (mybuf == tmpptr)
243
	if (mybuf == tmpptr)
Lines 243-250 Link Here
243
	}
247
	}
244
	else
248
	else
245
	{
249
	{
246
	    /* Ther is a hostname specified */
250
	    /* There is a hostname specified */
247
	    _protocol = "inet";
251
	    _protocol = "tcp";
248
	    mybuf = tmpptr;	/* reset to the begining of the host ptr */
252
	    mybuf = tmpptr;	/* reset to the begining of the host ptr */
249
	}
253
	}
250
    }
254
    }
Lines 257-267 Link Here
257
	if (strlen(_protocol) == 0)
261
	if (strlen(_protocol) == 0)
258
	{
262
	{
259
	    /*
263
	    /*
260
	     * If there is a hostname, then assume inet, otherwise
264
	     * If there is a hostname, then assume tcp, otherwise
261
	     * it must be local.
265
	     * it must be local.
262
	     */
266
	     */
263
	    if (*mybuf != ':')
267
	    if (*mybuf != ':')
264
		_protocol = "inet";
268
		_protocol = "tcp";
265
	    else
269
	    else
266
		_protocol = "local";
270
		_protocol = "local";
267
	}
271
	}
Lines 271-277 Link Here
271
275
272
    _host = mybuf;
276
    _host = mybuf;
273
277
274
    if ((mybuf = strchr (mybuf,':')) == NULL)
278
    if ((mybuf = strrchr (mybuf,':')) == NULL)
275
    {
279
    {
276
	*protocol = NULL;
280
	*protocol = NULL;
277
	*host = NULL;
281
	*host = NULL;
Lines 280-299 Link Here
280
	return 0;
284
	return 0;
281
    }
285
    }
282
286
283
    *mybuf ++= '\0';
287
    /* Check for DECnet */
284
288
285
    if (strlen(_host) == 0)
289
    if ((mybuf != _host) && (*(mybuf - 1) == ':')
290
#ifdef IPv6
291
      /* An IPv6 address can end in :: so three : in a row is assumed to be
292
	 an IPv6 host and not a DECnet node with a : in it's name */
293
      && !( (mybuf > (_host + 2)) && (*(mybuf - 2) == ':') )
294
#endif
295
	)
286
    {
296
    {
287
	TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
297
	_protocol = "dnet";
288
	_host = hostnamebuf;
298
	*(mybuf - 1) = '\0';
289
    }
299
    }
290
300
291
    /* Check for DECnet */
301
    *mybuf ++= '\0';
292
302
293
    if (*mybuf == ':')
303
    if (strlen(_host) == 0)
294
    {
304
    {
295
	_protocol = "dnet";
305
	TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
296
	mybuf++;
306
	_host = hostnamebuf;
297
    }
307
    }
298
308
299
    /* Get the port */
309
    /* Get the port */
Lines 997-1003 Link Here
997
    XtransConnInfo	ciptr, temp_ciptrs[NUMTRANS];
1007
    XtransConnInfo	ciptr, temp_ciptrs[NUMTRANS];
998
    int			status, i, j;
1008
    int			status, i, j;
999
1009
1000
    PRMSG (2,"MakeAllCOTSServerListeners(%s,%x)\n",
1010
    PRMSG (2,"MakeAllCOTSServerListeners(%s,%p)\n",
1001
	   port ? port : "NULL", ciptrs_ret, 0);
1011
	   port ? port : "NULL", ciptrs_ret, 0);
1002
1012
1003
    *count_ret = 0;
1013
    *count_ret = 0;
Lines 1099-1105 Link Here
1099
    XtransConnInfo	ciptr, temp_ciptrs[NUMTRANS];
1109
    XtransConnInfo	ciptr, temp_ciptrs[NUMTRANS];
1100
    int			status, i, j;
1110
    int			status, i, j;
1101
1111
1102
    PRMSG (2,"MakeAllCLTSServerListeners(%s,%x)\n",
1112
    PRMSG (2,"MakeAllCLTSServerListeners(%s,%p)\n",
1103
	port ? port : "NULL", ciptrs_ret, 0);
1113
	port ? port : "NULL", ciptrs_ret, 0);
1104
1114
1105
    *count_ret = 0;
1115
    *count_ret = 0;
(-)4.3.0/xc/lib/xtrans/Xtrans.h (-2 / +13 lines)
Lines 1-4 Link Here
1
/* $Xorg: Xtrans.h,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
1
/* $Xorg: Xtrans.h,v 1.4 2001/02/09 02:04:06 xorgcvs Exp $ */
2
/* Updated for IPv6 */
2
/*
3
/*
3
4
4
Copyright 1993, 1994, 1998  The Open Group
5
Copyright 1993, 1994, 1998  The Open Group
Lines 83-89 Link Here
83
static char* __xtransname = "_XSERVTrans";
84
static char* __xtransname = "_XSERVTrans";
84
#endif
85
#endif
85
#define X11_t
86
#define X11_t
86
#endif /* X11_t */
87
#endif /* XSERV_t */
87
88
88
#ifdef XIM_t
89
#ifdef XIM_t
89
#if !defined(UNIXCPP) || defined(ANSICPP)
90
#if !defined(UNIXCPP) || defined(ANSICPP)
Lines 173-184 Link Here
173
 * This structure needs to be independent of the socket/TLI interface used.
174
 * This structure needs to be independent of the socket/TLI interface used.
174
 */
175
 */
175
176
177
#ifdef IPv6
178
#include <sys/socket.h>
179
typedef struct socket_storage Xtransaddr;
180
#else
176
#define XTRANS_MAX_ADDR_LEN	128	/* large enough to hold sun_path */
181
#define XTRANS_MAX_ADDR_LEN	128	/* large enough to hold sun_path */
177
182
178
typedef	struct {
183
typedef	struct {
179
    unsigned char	addr[XTRANS_MAX_ADDR_LEN];
184
    unsigned char	addr[XTRANS_MAX_ADDR_LEN];
180
} Xtransaddr;
185
} Xtransaddr;
181
186
#endif
182
187
183
#ifdef LONG64
188
#ifdef LONG64
184
typedef int BytesReadable_t;
189
typedef int BytesReadable_t;
Lines 450-455 Link Here
450
);
455
);
451
456
452
#endif /* X11_t */
457
#endif /* X11_t */
458
459
void TRANS(FreeConnInfo) (
460
#if NeedFunctionPrototypes
461
    XtransConnInfo ciptr
462
#endif
463
);
453
464
454
#ifdef ICE_t
465
#ifdef ICE_t
455
466
(-)4.3.0/xc/lib/xtrans/Xtranssock.c (-51 / +312 lines)
Lines 1-7 Link Here
1
/* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */
1
/* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */
2
/* Updated for IPv6 */
2
/*
3
/*
3
4
4
Copyright 1993, 1994, 1998  The Open Group
5
Copyright 1993, 1994, 1998  The Open Group
6
Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
5
7
6
Permission to use, copy, modify, distribute, and sell this software and its
8
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
9
documentation for any purpose is hereby granted without fee, provided that
Lines 20-29 Link Here
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
23
OTHER DEALINGS IN THE SOFTWARE.
22
24
23
Except as contained in this notice, the name of The Open Group shall
25
Except as contained in this notice, the name of the copyright holders shall
24
not be used in advertising or otherwise to promote the sale, use or
26
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
27
other dealings in this Software without prior written authorization
26
from The Open Group.
28
from the copyright holders.
27
29
28
*/
30
*/
29
/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.56 2002/11/26 01:12:30 dawes Exp $ */
31
/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.56 2002/11/26 01:12:30 dawes Exp $ */
Lines 59-65 Link Here
59
#ifndef WIN32
61
#ifndef WIN32
60
62
61
#if defined(TCPCONN) || defined(UNIXCONN)
63
#if defined(TCPCONN) || defined(UNIXCONN)
64
#include <sys/socket.h>
62
#include <netinet/in.h>
65
#include <netinet/in.h>
66
#include <arpa/inet.h>
63
#endif
67
#endif
64
68
65
#if defined(TCPCONN) || defined(UNIXCONN)
69
#if defined(TCPCONN) || defined(UNIXCONN)
Lines 88-93 Link Here
88
#include <sys/param.h>
92
#include <sys/param.h>
89
#endif /* osf */
93
#endif /* osf */
90
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) 
94
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) 
95
#include <sys/param.h>
91
#include <machine/endian.h>
96
#include <machine/endian.h>
92
#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ */
97
#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ */
93
#include <netinet/tcp.h>
98
#include <netinet/tcp.h>
Lines 98-104 Link Here
98
#include <sys/filio.h>
103
#include <sys/filio.h>
99
#endif
104
#endif
100
105
101
#if (defined(i386) && defined(SYSV)) && !defined(sco)
106
#if (defined(i386) && defined(SYSV)) && !defined(sco)&& !defined(sun)
102
#include <net/errno.h>
107
#include <net/errno.h>
103
#endif 
108
#endif 
104
109
Lines 184-190 Link Here
184
static Sockettrans2dev Sockettrans2devtab[] = {
189
static Sockettrans2dev Sockettrans2devtab[] = {
185
#ifdef TCPCONN
190
#ifdef TCPCONN
186
    {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
191
    {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
192
#ifndef IPv6
187
    {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
193
    {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
194
#else /* IPv6 */
195
    {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
196
    {"inetv6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
197
#endif
188
#endif /* TCPCONN */
198
#endif /* TCPCONN */
189
#ifdef UNIXCONN
199
#ifdef UNIXCONN
190
    {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
200
    {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
Lines 292-305 Link Here
292
TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
302
TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
293
303
294
{
304
{
305
#ifdef IPv6
306
    struct sockaddr_storage sockname;
307
#else
295
    struct sockaddr_in 	sockname;
308
    struct sockaddr_in 	sockname;
309
#endif
296
#if defined(SVR4) || defined(SCO325)
310
#if defined(SVR4) || defined(SCO325)
297
    size_t namelen = sizeof sockname;
311
    size_t namelen = sizeof sockname;
298
#else
312
#else
299
    int namelen = sizeof sockname;
313
    int namelen = sizeof sockname;
300
#endif
314
#endif
301
315
302
    PRMSG (3,"SocketINETGetAddr(%x)\n", ciptr, 0, 0);
316
    PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0);
303
317
304
    if (getsockname (ciptr->fd,(struct sockaddr *) &sockname,
318
    if (getsockname (ciptr->fd,(struct sockaddr *) &sockname,
305
		     (void *)&namelen) < 0)
319
		     (void *)&namelen) < 0)
Lines 321-327 Link Here
321
        return -1;
335
        return -1;
322
    }
336
    }
323
337
338
#ifdef IPv6
339
    ciptr->family = sockname.ss_family;
340
#else
324
    ciptr->family = sockname.sin_family;
341
    ciptr->family = sockname.sin_family;
342
#endif
325
    ciptr->addrlen = namelen;
343
    ciptr->addrlen = namelen;
326
    memcpy (ciptr->addr, &sockname, ciptr->addrlen);
344
    memcpy (ciptr->addr, &sockname, ciptr->addrlen);
327
345
Lines 338-351 Link Here
338
TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
356
TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
339
357
340
{
358
{
359
#ifdef IPv6
360
    struct sockaddr_storage sockname;
361
#else
341
    struct sockaddr_in 	sockname;
362
    struct sockaddr_in 	sockname;
363
#endif
342
#if defined(SVR4) || defined(SCO325)
364
#if defined(SVR4) || defined(SCO325)
343
    size_t namelen = sizeof sockname;
365
    size_t namelen = sizeof sockname;
344
#else
366
#else
345
    int namelen = sizeof sockname;
367
    int namelen = sizeof sockname;
346
#endif
368
#endif
347
369
348
    PRMSG (3,"SocketINETGetPeerAddr(%x)\n", ciptr, 0, 0);
370
    PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0);
349
371
350
    if (getpeername (ciptr->fd, (struct sockaddr *) &sockname,
372
    if (getpeername (ciptr->fd, (struct sockaddr *) &sockname,
351
		     (void *)&namelen) < 0)
373
		     (void *)&namelen) < 0)
Lines 405-411 Link Here
405
    }
427
    }
406
428
407
#ifdef TCP_NODELAY
429
#ifdef TCP_NODELAY
408
    if (Sockettrans2devtab[i].family == AF_INET)
430
    if (Sockettrans2devtab[i].family == AF_INET
431
#ifdef IPv6
432
      || Sockettrans2devtab[i].family == AF_INET6
433
#endif
434
    )
409
    {
435
    {
410
	/*
436
	/*
411
	 * turn off TCP coalescence for INET sockets
437
	 * turn off TCP coalescence for INET sockets
Lines 528-537 Link Here
528
#ifdef SO_REUSEADDR
554
#ifdef SO_REUSEADDR
529
555
530
    /*
556
    /*
531
     * SO_REUSEADDR only applied to AF_INET
557
     * SO_REUSEADDR only applied to AF_INET && AF_INET6
532
     */
558
     */
533
559
534
    if (Sockettrans2devtab[i].family == AF_INET)
560
    if (Sockettrans2devtab[i].family == AF_INET
561
#ifdef IPv6
562
      || Sockettrans2devtab[i].family == AF_INET6
563
#endif
564
    )
535
    {
565
    {
536
	int one = 1;
566
	int one = 1;
537
	setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
567
	setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
Lines 749-757 Link Here
749
    int	fd = ciptr->fd;
779
    int	fd = ciptr->fd;
750
    int	retry;
780
    int	retry;
751
781
752
    PRMSG (3, "SocketCreateListener(%x,%d)\n", ciptr, fd, 0);
782
    PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0);
753
783
754
    if (Sockettrans2devtab[ciptr->index].family == AF_INET)
784
    if (Sockettrans2devtab[ciptr->index].family == AF_INET
785
#ifdef IPv6
786
      || Sockettrans2devtab[ciptr->index].family == AF_INET6
787
#endif
788
	)
755
	retry = 20;
789
	retry = 20;
756
    else
790
    else
757
	retry = 0;
791
	retry = 0;
Lines 774-780 Link Here
774
#endif /* SO_REUSEDADDR */
808
#endif /* SO_REUSEDADDR */
775
    }
809
    }
776
810
777
    if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
811
    if (Sockettrans2devtab[ciptr->index].family == AF_INET
812
#ifdef IPv6
813
      || Sockettrans2devtab[ciptr->index].family == AF_INET6
814
#endif
815
	) {
778
#ifdef SO_DONTLINGER
816
#ifdef SO_DONTLINGER
779
	setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
817
	setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
780
#else
818
#else
Lines 807-813 Link Here
807
TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port)
845
TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port)
808
846
809
{
847
{
848
#ifdef IPv6
849
    struct sockaddr_in6	sockname;
850
    in_port_t		sport;
851
#else
810
    struct sockaddr_in	sockname;
852
    struct sockaddr_in	sockname;
853
    unsigned short	sport;
854
#endif
811
    int		namelen = sizeof(sockname);
855
    int		namelen = sizeof(sockname);
812
    int		status;
856
    int		status;
813
    long	tmpport;
857
    long	tmpport;
Lines 855-861 Link Here
855
		return TRANS_CREATE_LISTENER_FAILED;
899
		return TRANS_CREATE_LISTENER_FAILED;
856
	    }
900
	    }
857
	    /* we trust getservbyname to return a valid number */
901
	    /* we trust getservbyname to return a valid number */
858
	    sockname.sin_port = htons (servp->s_port);
902
	    sport = servp->s_port;
859
	}
903
	}
860
	else
904
	else
861
	{
905
	{
Lines 869-885 Link Here
869
	    if (tmpport < 1024 || tmpport > USHRT_MAX)
913
	    if (tmpport < 1024 || tmpport > USHRT_MAX)
870
		return TRANS_CREATE_LISTENER_FAILED;
914
		return TRANS_CREATE_LISTENER_FAILED;
871
915
872
	    sockname.sin_port = htons (((unsigned short) tmpport));
916
	    sport = (unsigned short) tmpport;
873
	}
917
	}
874
    }
918
    }
875
    else
919
    else
876
	sockname.sin_port = htons (0);
920
	sport = 0;
877
921
922
    bzero(&sockname, sizeof(sockname));
923
#ifdef IPv6
924
#ifdef SIN6_LEN
925
    sockname.sin6_len = sizeof (sockname);
926
#endif
927
    sockname.sin6_family = AF_INET6;
928
    sockname.sin6_port = htons (sport);
929
    sockname.sin6_addr = in6addr_any;
930
#else
878
#ifdef BSD44SOCKETS
931
#ifdef BSD44SOCKETS
879
    sockname.sin_len = sizeof (sockname);
932
    sockname.sin_len = sizeof (sockname);
880
#endif
933
#endif
881
    sockname.sin_family = AF_INET;
934
    sockname.sin_family = AF_INET;
935
    sockname.sin_port = htons (sport);
882
    sockname.sin_addr.s_addr = htonl (INADDR_ANY);
936
    sockname.sin_addr.s_addr = htonl (INADDR_ANY);
937
#endif
883
938
884
    if ((status = TRANS(SocketCreateListener) (ciptr,
939
    if ((status = TRANS(SocketCreateListener) (ciptr,
885
	(struct sockaddr *) &sockname, namelen)) < 0)
940
	(struct sockaddr *) &sockname, namelen)) < 0)
Lines 1008-1014 Link Here
1008
    int 		status = TRANS_RESET_NOOP;
1063
    int 		status = TRANS_RESET_NOOP;
1009
    unsigned int	mode;
1064
    unsigned int	mode;
1010
1065
1011
    PRMSG (3, "SocketUNIXResetListener(%x,%d)\n", ciptr, ciptr->fd, 0);
1066
    PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0);
1012
1067
1013
    if (stat (unsock->sun_path, &statb) == -1 ||
1068
    if (stat (unsock->sun_path, &statb) == -1 ||
1014
        ((statb.st_mode & S_IFMT) !=
1069
        ((statb.st_mode & S_IFMT) !=
Lines 1080-1086 Link Here
1080
    struct sockaddr_in	sockname;
1135
    struct sockaddr_in	sockname;
1081
    int			namelen = sizeof(sockname);
1136
    int			namelen = sizeof(sockname);
1082
1137
1083
    PRMSG (2, "SocketINETAccept(%x,%d)\n", ciptr, ciptr->fd, 0);
1138
    PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
1084
1139
1085
    if ((newciptr = (XtransConnInfo) xcalloc (
1140
    if ((newciptr = (XtransConnInfo) xcalloc (
1086
	1, sizeof(struct _XtransConnInfo))) == NULL)
1141
	1, sizeof(struct _XtransConnInfo))) == NULL)
Lines 1160-1166 Link Here
1160
    int namelen = sizeof sockname;
1215
    int namelen = sizeof sockname;
1161
#endif
1216
#endif
1162
1217
1163
    PRMSG (2, "SocketUNIXAccept(%x,%d)\n", ciptr, ciptr->fd, 0);
1218
    PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
1164
1219
1165
    if ((newciptr = (XtransConnInfo) xcalloc (
1220
    if ((newciptr = (XtransConnInfo) xcalloc (
1166
	1, sizeof(struct _XtransConnInfo))) == NULL)
1221
	1, sizeof(struct _XtransConnInfo))) == NULL)
Lines 1229-1238 Link Here
1229
#ifdef TRANS_CLIENT
1284
#ifdef TRANS_CLIENT
1230
1285
1231
#ifdef TCPCONN
1286
#ifdef TCPCONN
1287
1288
#ifdef IPv6
1289
struct addrlist {
1290
    struct addrinfo *	addr;
1291
    struct addrinfo *	firstaddr; 
1292
    char 		port[PORTBUFSIZE];
1293
    char 		host[MAXHOSTNAMELEN];
1294
};
1295
static struct addrlist  *addrlist = NULL;
1296
#endif
1297
1298
1232
static int
1299
static int
1233
TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
1300
TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
1234
1301
1235
{
1302
{
1303
    struct sockaddr *	socketaddr = NULL;
1304
    int			socketaddrlen = 0;
1305
    int			res;
1306
#ifdef IPv6
1307
    struct addrinfo 	hints;
1308
    char		ntopbuf[INET6_ADDRSTRLEN];
1309
    struct sockaddr_in6 tmpsin6;
1310
    int			resetonce = 0;
1311
#else
1236
    struct sockaddr_in	sockname;
1312
    struct sockaddr_in	sockname;
1237
#if defined(SVR4) || defined(SCO325)
1313
#if defined(SVR4) || defined(SCO325)
1238
    size_t namelen = sizeof sockname;
1314
    size_t namelen = sizeof sockname;
Lines 1245-1257 Link Here
1245
#endif
1321
#endif
1246
    struct hostent	*hostp;
1322
    struct hostent	*hostp;
1247
    struct servent	*servp;
1323
    struct servent	*servp;
1248
1324
    unsigned long 	tmpaddr;
1325
#endif
1249
#ifdef X11_t
1326
#ifdef X11_t
1250
    char	portbuf[PORTBUFSIZE];
1327
    char	portbuf[PORTBUFSIZE];
1251
#endif
1328
#endif
1252
1329
1330
#if defined(X11_t) || !defined(IPv6)
1253
    long		tmpport;
1331
    long		tmpport;
1254
    unsigned long 	tmpaddr;
1332
#endif
1255
    char 		hostnamebuf[256];		/* tmp space */
1333
    char 		hostnamebuf[256];		/* tmp space */
1256
1334
1257
    PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
1335
    PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
Lines 1281-1286 Link Here
1281
    }
1359
    }
1282
#endif
1360
#endif
1283
1361
1362
#ifdef IPv6
1363
    if (addrlist != NULL) {
1364
	if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) {
1365
	    if (addrlist->firstaddr)
1366
	     	freeaddrinfo(addrlist->firstaddr);
1367
	    addrlist->firstaddr = NULL;
1368
	}
1369
    } else {
1370
	addrlist = malloc(sizeof(struct addrlist));
1371
	addrlist->firstaddr = NULL;
1372
    }
1373
1374
    if (addrlist->firstaddr == NULL) {
1375
	strncpy(addrlist->port, port, sizeof(addrlist->port));
1376
	addrlist->port[sizeof(addrlist->port) - 1] = '\0';
1377
	strncpy(addrlist->host, host, sizeof(addrlist->host));
1378
	addrlist->host[sizeof(addrlist->host) - 1] = '\0';
1379
1380
	bzero(&hints,sizeof(hints));
1381
	hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname;
1382
1383
	res = getaddrinfo(host,port,&hints,&addrlist->firstaddr);
1384
	if (res != 0) {
1385
	    PRMSG (1,
1386
	      "TRANS(SocketINETConnect) () can't get address for %s:%s: %s\n",
1387
	      host, port, gai_strerror(res));
1388
	    ESET(EINVAL);
1389
	    return TRANS_CONNECT_FAILED;
1390
	}
1391
	for (res = 0, addrlist->addr = addrlist->firstaddr; addrlist->addr ; res++) {
1392
	    addrlist->addr = addrlist->addr->ai_next;
1393
	}
1394
	PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0);
1395
	res = 0;
1396
	addrlist->addr = NULL;
1397
    }
1398
1399
    while ( socketaddr == NULL ) {
1400
	if (addrlist->addr == NULL) {
1401
	    if (resetonce) { 
1402
		/* Already checked entire list - no usable addresses */
1403
		PRMSG (1,
1404
	      "TRANS(SocketINETConnect) () no usable address for %s:%s\n",
1405
		  host, port, 0);
1406
		return TRANS_CONNECT_FAILED;
1407
	    } else {
1408
		/* Go back to beginning of list */
1409
		resetonce = 1;
1410
		addrlist->addr = addrlist->firstaddr;
1411
	    }
1412
	} 
1413
	    
1414
1415
	socketaddr = addrlist->addr->ai_addr;
1416
	socketaddrlen = addrlist->addr->ai_addrlen;
1417
    
1418
	if (addrlist->addr->ai_family == AF_INET) {
1419
	    struct sockaddr_in	*sin = (struct sockaddr_in *) socketaddr;
1420
	    
1421
	    PRMSG (4,"TRANS(SocketINETConnect) sockname.sin_addr = %s\n",
1422
	      inet_ntop(addrlist->addr->ai_family,&sin->sin_addr,
1423
		ntopbuf,sizeof(ntopbuf)), 0, 0); 
1424
1425
	    PRMSG (4,"TRANS(SocketINETConnect) sockname.sin_port = %d\n",
1426
	      ntohs(sin->sin_port), 0, 0); 
1427
1428
	    if (Sockettrans2devtab[ciptr->index].family == AF_INET6) {
1429
		/* We have IPv6 socket, need to map IPv4 address to IPv6 */
1430
		char *v4addr = (char *) &sin->sin_addr.s_addr;
1431
		bzero(&tmpsin6, sizeof(tmpsin6));
1432
#ifdef SIN6_LEN
1433
		tmpsin6.sin6_len = sizeof(tmpsin6);
1434
#endif
1435
		tmpsin6.sin6_family = AF_INET6;
1436
		tmpsin6.sin6_port = sin->sin_port;
1437
		tmpsin6.sin6_addr.s6_addr[10] = 0xff;
1438
		tmpsin6.sin6_addr.s6_addr[11] = 0xff;
1439
		tmpsin6.sin6_addr.s6_addr[12] = v4addr[0];
1440
		tmpsin6.sin6_addr.s6_addr[13] = v4addr[1];
1441
		tmpsin6.sin6_addr.s6_addr[14] = v4addr[2];
1442
		tmpsin6.sin6_addr.s6_addr[15] = v4addr[3];
1443
		
1444
		socketaddr = (struct sockaddr *) &tmpsin6;
1445
		socketaddrlen = sizeof(tmpsin6);
1446
		PRMSG (4,"TRANS(SocketINETConnect) sockname.sin6_addr = %s\n",
1447
		  inet_ntop(AF_INET6, &tmpsin6.sin6_addr, ntopbuf,
1448
		    sizeof(ntopbuf)), 0, 0); 
1449
	    }
1450
	} else if (addrlist->addr->ai_family == AF_INET6) {
1451
	    struct sockaddr_in6	*sin6 = (struct sockaddr_in6 *) socketaddr;
1452
	
1453
	    PRMSG (4,"TRANS(SocketINETConnect) sockname.sin6_addr = %s\n",
1454
	      inet_ntop(addrlist->addr->ai_family, &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)),
1455
	      0, 0); 
1456
	    PRMSG (4,"TRANS(SocketINETConnect) sockname.sin6_port = %d\n",
1457
	      ntohs(sin6->sin6_port), 0, 0); 
1458
1459
	    if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
1460
		PRMSG (4,"TRANS(SocketINETConnect) Skipping IPv6 address\n",
1461
		  0,0,0);
1462
		socketaddr = NULL;
1463
	    }
1464
	} else {
1465
	    socketaddr = NULL; /* Unsupported address type */
1466
	}
1467
	if (socketaddr == NULL) {
1468
	    addrlist->addr = addrlist->addr->ai_next;
1469
	}
1470
    } 
1471
#else
1284
    /*
1472
    /*
1285
     * Build the socket name.
1473
     * Build the socket name.
1286
     */
1474
     */
Lines 1305-1311 Link Here
1305
    PRMSG (4,"SocketINETConnect: inet_addr(%s) = %x\n",
1493
    PRMSG (4,"SocketINETConnect: inet_addr(%s) = %x\n",
1306
	host, tmpaddr, 0);
1494
	host, tmpaddr, 0);
1307
1495
1308
    if (tmpaddr == -1)
1496
    if ((long)tmpaddr == -1L)
1309
    {
1497
    {
1310
	if ((hostp = _XGethostbyname(host,hparams)) == NULL)
1498
	if ((hostp = _XGethostbyname(host,hparams)) == NULL)
1311
	{
1499
	{
Lines 1371-1376 Link Here
1371
    
1559
    
1372
    PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n",
1560
    PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n",
1373
	  ntohs(sockname.sin_port), 0, 0);
1561
	  ntohs(sockname.sin_port), 0, 0);
1562
    socketaddr = (struct sockaddr *) &sockname;
1563
    socketaddrlen = sizeof(sockname);
1564
#endif    /* IPv6 */
1374
1565
1375
    /*
1566
    /*
1376
     * Turn on socket keepalive so the client process will eventually
1567
     * Turn on socket keepalive so the client process will eventually
Lines 1393-1399 Link Here
1393
     * Do the connect()
1584
     * Do the connect()
1394
     */
1585
     */
1395
1586
1396
    if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0)
1587
    if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0)
1397
    {
1588
    {
1398
#ifdef WIN32
1589
#ifdef WIN32
1399
	int olderrno = WSAGetLastError();
1590
	int olderrno = WSAGetLastError();
Lines 1410-1452 Link Here
1410
	 *
1601
	 *
1411
	 * If the error was EINTR, the connect was interrupted and we
1602
	 * If the error was EINTR, the connect was interrupted and we
1412
	 * should try again.
1603
	 * should try again.
1604
	 *
1605
	 * If multiple addresses are found for a host then we should
1606
	 * try to connect again with a different address for a larger
1607
	 * number of errors that made us quit before, since those
1608
	 * could be caused by trying to use an IPv6 address to contact
1609
	 * a machine with an IPv4-only server or other reasons that
1610
	 * only affect one of a set of addresses.  
1413
	 */
1611
	 */
1414
1612
1415
	if (olderrno == ECONNREFUSED || olderrno == EINTR)
1613
	if (olderrno == ECONNREFUSED || olderrno == EINTR
1416
	    return TRANS_TRY_CONNECT_AGAIN;
1614
#ifdef IPv6
1615
	  || ( ((addrlist->addr->ai_next != NULL) || 
1616
	        (addrlist->addr != addrlist->firstaddr)) &&
1617
               (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT ||
1618
		 olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT))
1619
#endif
1620
	    )
1621
	    res = TRANS_TRY_CONNECT_AGAIN;
1417
	else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
1622
	else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
1418
	    return TRANS_IN_PROGRESS;
1623
	    res = TRANS_IN_PROGRESS;
1419
	else
1624
	else
1420
	{
1625
	{
1421
	    PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n",
1626
	    PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n",
1422
		   olderrno,0, 0);
1627
		   olderrno,0, 0);
1423
1628
1424
	    return TRANS_CONNECT_FAILED;	
1629
	    res = TRANS_CONNECT_FAILED;	
1425
	}
1630
	}
1426
    }
1631
    } else {
1632
	res = 0;
1427
    
1633
    
1428
1634
1429
    /*
1635
	/*
1430
     * Sync up the address fields of ciptr.
1636
	 * Sync up the address fields of ciptr.
1431
     */
1637
	 */
1432
    
1638
    
1433
    if (TRANS(SocketINETGetAddr) (ciptr) < 0)
1639
	if (TRANS(SocketINETGetAddr) (ciptr) < 0)
1434
    {
1640
	{
1435
	PRMSG (1,
1641
	    PRMSG (1,
1436
	   "SocketINETConnect: ...SocketINETGetAddr() failed:\n",
1642
	     "SocketINETConnect: ...SocketINETGetAddr() failed:\n",
1437
	   0, 0, 0);
1643
	      0, 0, 0);
1438
	return TRANS_CONNECT_FAILED;
1644
	    res = TRANS_CONNECT_FAILED;
1439
    }
1645
	}
1440
1646
1441
    if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0)
1647
	else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0)
1442
    {
1648
	{
1443
	PRMSG (1,
1649
	    PRMSG (1,
1444
	 "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n",
1650
	      "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n",
1445
	      0, 0, 0);
1651
	      0, 0, 0);
1446
	return TRANS_CONNECT_FAILED;
1652
	    res = TRANS_CONNECT_FAILED;
1653
	}
1447
    }
1654
    }
1448
1655
1449
    return 0;
1656
#ifdef IPv6
1657
   if (res != 0) { 
1658
	addrlist->addr = addrlist->addr->ai_next;
1659
   }
1660
#endif
1661
1662
    return res;
1450
}
1663
}
1451
1664
1452
#endif /* TCPCONN */
1665
#endif /* TCPCONN */
Lines 1473-1478 Link Here
1473
    }
1686
    }
1474
    else
1687
    else
1475
    {
1688
    {
1689
#ifdef IPv6
1690
	struct addrinfo *localhostaddr;
1691
	struct addrinfo *otherhostaddr;
1692
	struct addrinfo *i, *j;
1693
	int equiv = 0;
1694
1695
	if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0)
1696
	    return 0;
1697
	if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) {
1698
	    freeaddrinfo(localhostaddr);
1699
	    return 0;
1700
	}
1701
1702
	for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) {
1703
	    for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) {
1704
		if (i->ai_family == j->ai_family) {
1705
		    if (i->ai_family == AF_INET) {
1706
			struct sockaddr_in *sinA 
1707
			  = (struct sockaddr_in *) i->ai_addr;
1708
			struct sockaddr_in *sinB
1709
			  = (struct sockaddr_in *) j->ai_addr;
1710
			struct in_addr *A = &sinA->sin_addr;
1711
			struct in_addr *B = &sinB->sin_addr;
1712
1713
			if (memcmp(A,B,sizeof(struct in_addr)) == 0) {
1714
			    equiv = 1;
1715
			}
1716
		    } else if (i->ai_family == AF_INET6) {
1717
			struct sockaddr_in6 *sinA 
1718
			  = (struct sockaddr_in6 *) i->ai_addr;
1719
			struct sockaddr_in6 *sinB 
1720
			  = (struct sockaddr_in6 *) j->ai_addr;
1721
			struct in6_addr *A = &sinA->sin6_addr;
1722
			struct in6_addr *B = &sinB->sin6_addr;
1723
1724
			if (memcmp(A,B,sizeof(struct in6_addr)) == 0) {
1725
			    equiv = 1;
1726
			}
1727
		    }
1728
		}
1729
	    }
1730
	}
1731
	
1732
	freeaddrinfo(localhostaddr);
1733
	freeaddrinfo(otherhostaddr);
1734
	return equiv;
1735
#else
1476
	/*
1736
	/*
1477
	 * A host may have more than one network address.  If any of the
1737
	 * A host may have more than one network address.  If any of the
1478
	 * network addresses of 'host' (specified to the connect call)
1738
	 * network addresses of 'host' (specified to the connect call)
Lines 1542-1547 Link Here
1542
	}
1802
	}
1543
	
1803
	
1544
    return (equiv);
1804
    return (equiv);
1805
#endif
1545
    }
1806
    }
1546
}
1807
}
1547
1808
Lines 1703-1709 Link Here
1703
TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
1964
TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
1704
1965
1705
{
1966
{
1706
    PRMSG (2,"SocketBytesReadable(%x,%d,%x)\n",
1967
    PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n",
1707
	ciptr, ciptr->fd, pend);
1968
	ciptr, ciptr->fd, pend);
1708
#if defined(QNX4)
1969
#if defined(QNX4)
1709
    *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */
1970
    *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */
Lines 1728-1734 Link Here
1728
TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
1989
TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
1729
1990
1730
{
1991
{
1731
    PRMSG (2,"SocketRead(%d,%x,%d)\n", ciptr->fd, buf, size);
1992
    PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size);
1732
1993
1733
#if defined(WIN32) || defined(__UNIXOS2__)
1994
#if defined(WIN32) || defined(__UNIXOS2__)
1734
    return recv ((SOCKET)ciptr->fd, buf, size, 0);
1995
    return recv ((SOCKET)ciptr->fd, buf, size, 0);
Lines 1742-1748 Link Here
1742
TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
2003
TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
1743
2004
1744
{
2005
{
1745
    PRMSG (2,"SocketWrite(%d,%x,%d)\n", ciptr->fd, buf, size);
2006
    PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size);
1746
2007
1747
#if defined(WIN32) || defined(__UNIXOS2__)
2008
#if defined(WIN32) || defined(__UNIXOS2__)
1748
    return send ((SOCKET)ciptr->fd, buf, size, 0);
2009
    return send ((SOCKET)ciptr->fd, buf, size, 0);
Lines 1756-1762 Link Here
1756
TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
2017
TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
1757
2018
1758
{
2019
{
1759
    PRMSG (2,"SocketReadv(%d,%x,%d)\n", ciptr->fd, buf, size);
2020
    PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size);
1760
2021
1761
    return READV (ciptr, buf, size);
2022
    return READV (ciptr, buf, size);
1762
}
2023
}
Lines 1766-1772 Link Here
1766
TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
2027
TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
1767
2028
1768
{
2029
{
1769
    PRMSG (2,"SocketWritev(%d,%x,%d)\n", ciptr->fd, buf, size);
2030
    PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size);
1770
2031
1771
    return WRITEV (ciptr, buf, size);
2032
    return WRITEV (ciptr, buf, size);
1772
}
2033
}
Lines 1776-1782 Link Here
1776
TRANS(SocketDisconnect) (XtransConnInfo ciptr)
2037
TRANS(SocketDisconnect) (XtransConnInfo ciptr)
1777
2038
1778
{
2039
{
1779
    PRMSG (2,"SocketDisconnect(%x,%d)\n", ciptr, ciptr->fd, 0);
2040
    PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0);
1780
2041
1781
    return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
2042
    return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
1782
}
2043
}
Lines 1787-1793 Link Here
1787
TRANS(SocketINETClose) (XtransConnInfo ciptr)
2048
TRANS(SocketINETClose) (XtransConnInfo ciptr)
1788
2049
1789
{
2050
{
1790
    PRMSG (2,"SocketINETClose(%x,%d)\n", ciptr, ciptr->fd, 0);
2051
    PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0);
1791
2052
1792
    return close (ciptr->fd);
2053
    return close (ciptr->fd);
1793
}
2054
}
Lines 1809-1815 Link Here
1809
    char	path[200]; /* > sizeof sun_path +1 */
2070
    char	path[200]; /* > sizeof sun_path +1 */
1810
    int ret;
2071
    int ret;
1811
2072
1812
    PRMSG (2,"SocketUNIXClose(%x,%d)\n", ciptr, ciptr->fd, 0);
2073
    PRMSG (2,"SocketUNIXClose(%p,%d)\n", ciptr, ciptr->fd, 0);
1813
2074
1814
    ret = close(ciptr->fd);
2075
    ret = close(ciptr->fd);
1815
2076
Lines 1837-1843 Link Here
1837
2098
1838
    int ret;
2099
    int ret;
1839
2100
1840
    PRMSG (2,"SocketUNIXCloseForCloning(%x,%d)\n",
2101
    PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n",
1841
	ciptr, ciptr->fd, 0);
2102
	ciptr, ciptr->fd, 0);
1842
2103
1843
    ret = close(ciptr->fd);
2104
    ret = close(ciptr->fd);
(-)4.3.0/xc/lib/xtrans/Xtransutil.c (-7 / +82 lines)
Lines 69-77 Link Here
69
 * of these values are also defined by the ChangeHost protocol message.
69
 * of these values are also defined by the ChangeHost protocol message.
70
 */
70
 */
71
71
72
#define FamilyInternet		0
72
#define FamilyInternet		0	/* IPv4 */
73
#define FamilyDECnet		1
73
#define FamilyDECnet		1
74
#define FamilyChaos		2
74
#define FamilyChaos		2
75
#define FamilyInternetV6	6
75
#define FamilyAmoeba		33
76
#define FamilyAmoeba		33
76
#define FamilyLocalHost		252
77
#define FamilyLocalHost		252
77
#define FamilyKrb5Principal	253
78
#define FamilyKrb5Principal	253
Lines 82-88 Link Here
82
/*
83
/*
83
 * TRANS(ConvertAddress) converts a sockaddr based address to an
84
 * TRANS(ConvertAddress) converts a sockaddr based address to an
84
 * X authorization based address. Some of this is defined as part of
85
 * X authorization based address. Some of this is defined as part of
85
 * the ChangeHost protocol. The rest is just doen in a consistent manner.
86
 * the ChangeHost protocol. The rest is just done in a consistent manner.
86
 */
87
 */
87
88
88
int
89
int
Lines 130-135 Link Here
130
	}
131
	}
131
	break;
132
	break;
132
    }
133
    }
134
135
#ifdef IPv6
136
    case AF_INET6:
137
    {
138
	struct sockaddr_in6 saddr6;
139
140
	memcpy (&saddr6, *addrp, sizeof (struct sockaddr_in6));
141
142
	if (IN6_IS_ADDR_LOOPBACK(&saddr6.sin6_addr))
143
	{
144
	    *familyp=FamilyLocal;
145
	}
146
	else if (IN6_IS_ADDR_V4MAPPED(&(saddr6.sin6_addr))) {
147
	    char *cp = (char *) &saddr6.sin6_addr.s6_addr[12];
148
149
	    if ((cp[0] == 127) && (cp[1] == 0) &&
150
	      (cp[2] == 0) && (cp[3] == 1))
151
	    {
152
		*familyp=FamilyLocal;
153
	    }
154
	    else 
155
	    {
156
		*familyp=FamilyInternet;
157
		*addrlenp = sizeof (struct in_addr);
158
		memcpy(*addrp,cp,*addrlenp);
159
	    }
160
	}
161
	else
162
	{
163
	    *familyp=FamilyInternetV6;
164
	    *addrlenp=sizeof(saddr6.sin6_addr);
165
	    memcpy(*addrp,&saddr6.sin6_addr,sizeof(saddr6.sin6_addr));
166
	}
167
	break;
168
    }
169
#endif /* IPv6 */
133
#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
170
#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
134
171
135
#if defined(DNETCONN)
172
#if defined(DNETCONN)
Lines 237-247 Link Here
237
274
238
#if defined(TCPCONN) || defined(STREAMSCONN)
275
#if defined(TCPCONN) || defined(STREAMSCONN)
239
    case AF_INET:
276
    case AF_INET:
277
#ifdef IPv6
278
    case AF_INET6:
279
#endif
240
    {
280
    {
241
	struct sockaddr_in *saddr = (struct sockaddr_in *) addr;
281
	struct sockaddr_in *saddr = (struct sockaddr_in *) addr;
282
#ifdef IPv6
283
	struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) addr;
284
#endif
285
	int portnum;
242
	char portnumbuf[10];
286
	char portnumbuf[10];
243
287
244
	sprintf (portnumbuf, "%d", ntohs (saddr->sin_port));
288
289
#ifdef IPv6
290
	if (family == AF_INET6)
291
	    portnum = ntohs (saddr6->sin6_port);
292
	else
293
#endif
294
	    portnum = ntohs (saddr->sin_port);
295
296
	sprintf (portnumbuf, "%d", portnum);
245
	networkId = (char *) xalloc (3 + strlen (transName) +
297
	networkId = (char *) xalloc (3 + strlen (transName) +
246
	    strlen (hostnamebuf) + strlen (portnumbuf));
298
	    strlen (hostnamebuf) + strlen (portnumbuf));
247
	sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
299
	sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
Lines 273-279 Link Here
273
static jmp_buf env;
325
static jmp_buf env;
274
326
275
#ifdef SIGALRM
327
#ifdef SIGALRM
276
static int nameserver_timedout = 0;
328
static volatile int nameserver_timedout = 0;
277
329
278
static 
330
static 
279
#ifdef SIGNALRETURNSINT
331
#ifdef SIGNALRETURNSINT
Lines 301-307 Link Here
301
    char	*peer_addr = ciptr->peeraddr;
353
    char	*peer_addr = ciptr->peeraddr;
302
    char	*hostname;
354
    char	*hostname;
303
    char	addrbuf[256];
355
    char	addrbuf[256];
304
    char	*addr = NULL;
356
    const char	*addr = NULL;
305
357
306
    switch (family)
358
    switch (family)
307
    {
359
    {
Lines 317-329 Link Here
317
369
318
#if defined(TCPCONN) || defined(STREAMSCONN)
370
#if defined(TCPCONN) || defined(STREAMSCONN)
319
    case AF_INET:
371
    case AF_INET:
372
#ifdef IPv6
373
    case AF_INET6:
374
#endif
320
    {
375
    {
321
	struct sockaddr_in *saddr = (struct sockaddr_in *) peer_addr;
376
	struct sockaddr_in *saddr = (struct sockaddr_in *) peer_addr;
377
#ifdef IPv6
378
	struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) peer_addr;
379
#endif
380
	char *address;
381
	int addresslen;
322
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
382
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
323
	_Xgethostbynameparams hparams;
383
	_Xgethostbynameparams hparams;
324
#endif
384
#endif
325
	struct hostent * volatile hostp = NULL;
385
	struct hostent * volatile hostp = NULL;
326
386
387
#ifdef IPv6
388
	if (family == AF_INET6) {
389
	    address = (char *) &saddr6->sin6_addr;
390
	    addresslen = sizeof (saddr6->sin6_addr);
391
	}
392
	else
393
#endif
394
        {
395
	    address = (char *) &saddr->sin_addr;
396
	    addresslen = sizeof (saddr->sin_addr);
397
	}
398
327
#ifdef SIGALRM
399
#ifdef SIGALRM
328
	/*
400
	/*
329
	 * gethostbyaddr can take a LONG time if the host does not exist.
401
	 * gethostbyaddr can take a LONG time if the host does not exist.
Lines 338-345 Link Here
338
	alarm (4);
410
	alarm (4);
339
	if (setjmp(env) == 0) {
411
	if (setjmp(env) == 0) {
340
#endif
412
#endif
341
	    hostp = _XGethostbyaddr ((char *) &saddr->sin_addr,
413
	    hostp = _XGethostbyaddr (address, addresslen, family, hparams);
342
		sizeof (saddr->sin_addr), AF_INET, hparams);
343
#ifdef SIGALRM
414
#ifdef SIGALRM
344
	}
415
	}
345
	alarm (0);
416
	alarm (0);
Lines 347-353 Link Here
347
	if (hostp != NULL)
418
	if (hostp != NULL)
348
	  addr = hostp->h_name;
419
	  addr = hostp->h_name;
349
	else
420
	else
421
#ifdef IPv6
422
	  addr = inet_ntop (family, address, addrbuf, sizeof (addrbuf));
423
#else
350
	  addr = inet_ntoa (saddr->sin_addr);
424
	  addr = inet_ntoa (saddr->sin_addr);
425
#endif
351
	break;
426
	break;
352
    }
427
    }
353
428
(-)4.3.0/xc/programs/Xserver/os/access.c (-27 / +274 lines)
Lines 1-4 Link Here
1
/* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
1
/* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */
2
/* Updated for IPv6 */
2
/***********************************************************
3
/***********************************************************
3
4
4
Copyright 1987, 1998  The Open Group
5
Copyright 1987, 1998  The Open Group
Lines 52-57 Link Here
52
#endif
53
#endif
53
54
54
#include <stdio.h>
55
#include <stdio.h>
56
#include <stdlib.h>
55
#include <X11/Xtrans.h>
57
#include <X11/Xtrans.h>
56
#include <X11/Xauth.h>
58
#include <X11/Xauth.h>
57
#include <X.h>
59
#include <X.h>
Lines 142-147 Link Here
142
#include <ifaddrs.h>
144
#include <ifaddrs.h>
143
#endif
145
#endif
144
146
147
/* Solaris provides an extended interface SIOCGLIFCONF.  Other systems
148
 * may have this as well, but the code has only been tested on Solaris
149
 * so far, so we only enable it there.  Other platforms may be added as
150
 * needed.
151
 */
152
#ifdef SIOCGLIFCONF
153
#if defined(sun)
154
#define USE_SIOCGLIFCONF
155
#endif
156
#endif
157
145
#endif /* WIN32 */
158
#endif /* WIN32 */
146
159
147
#ifndef PATH_MAX
160
#ifndef PATH_MAX
Lines 170-175 Link Here
170
#include "extensions/security.h"
183
#include "extensions/security.h"
171
#endif
184
#endif
172
185
186
#ifndef PATH_MAX
187
#ifdef MAXPATHLEN
188
#define PATH_MAX MAXPATHLEN
189
#else
190
#define PATH_MAX 1024
191
#endif
192
#endif
193
173
Bool defeatAccessControl = FALSE;
194
Bool defeatAccessControl = FALSE;
174
195
175
#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
196
#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
Lines 191-211 Link Here
191
		    pointer /*addr*/,
212
		    pointer /*addr*/,
192
		    int /*len*/);
213
		    int /*len*/);
193
214
215
#ifdef XDMCP
216
extern void XdmcpRegisterConnection (int type, char *address, int addrlen);
217
extern void XdmcpRegisterBroadcastAddress (struct sockaddr_in  *addr);
218
#endif
219
220
/* default hosts bug fix: To keep track of which hosts were explicitly
221
   requested in /etc/X<display>.hosts, we've added a requested field
222
   to the HOST struct, and a LocalHostRequested variable.  These
223
   default to FALSE, but are set to TRUE in ResetHosts when reading in
224
   /etc/X<display>.hosts.  They are checked in DisableLocalHost(),
225
   which is called to disable the default local host entries when
226
   stronger authentication is turned on. 
227
 */
228
194
typedef struct _host {
229
typedef struct _host {
195
	short		family;
230
	short		family;
196
	short		len;
231
	short		len;
197
	unsigned char	*addr;
232
	unsigned char	*addr;
198
	struct _host *next;
233
	struct _host *next;
234
        int             requested;
199
} HOST;
235
} HOST;
200
236
201
#define MakeHost(h,l)	(h)=(HOST *) xalloc(sizeof *(h)+(l));\
237
#define MakeHost(h,l)	(h)=(HOST *) xalloc(sizeof *(h)+(l));\
202
                        if((h))\
238
                        if ((h)) {\
203
			(h)->addr=(unsigned char *) ((h) + 1);
239
			  (h)->addr=(unsigned char *) ((h) + 1);\
240
                          (h)->requested = FALSE; \
241
                        }
204
#define FreeHost(h)	xfree(h)
242
#define FreeHost(h)	xfree(h)
205
static HOST *selfhosts = NULL;
243
static HOST *selfhosts = NULL;
206
static HOST *validhosts = NULL;
244
static HOST *validhosts = NULL;
207
static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
245
static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
208
static int LocalHostEnabled = FALSE;
246
static int LocalHostEnabled = FALSE;
247
static int LocalHostRequested = FALSE;
209
static int UsingXdmcp = FALSE;
248
static int UsingXdmcp = FALSE;
210
249
211
250
Lines 232-240 Link Here
232
{
271
{
233
    HOST *self;
272
    HOST *self;
234
273
235
    LocalHostEnabled = FALSE;
274
    if (!LocalHostRequested) 
275
	LocalHostEnabled = FALSE;
236
    for (self = selfhosts; self; self = self->next)
276
    for (self = selfhosts; self; self = self->next)
277
    {
278
      if (!self->requested)
237
	(void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr);
279
	(void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr);
280
    }
238
}
281
}
239
282
240
/*
283
/*
Lines 250-256 Link Here
250
}
293
}
251
294
252
295
253
#if ((defined(SVR4) && !defined(DGUX) && !defined(SCO325) && !defined(sun) && !defined(NCR)) || defined(ISC)) && defined(SIOCGIFCONF)
296
#if ((defined(SVR4) && !defined(DGUX) && !defined(SCO325) && !defined(sun) && !defined(NCR)) || defined(ISC)) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF)
254
297
255
/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
298
/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
256
299
Lines 465-473 Link Here
465
    union {
508
    union {
466
	struct  sockaddr   sa;
509
	struct  sockaddr   sa;
467
	struct  sockaddr_in  in;
510
	struct  sockaddr_in  in;
511
#ifdef IPv6
512
	struct  sockaddr_in6  in6;
513
#endif
468
    } saddr;
514
    } saddr;
469
	
515
	
470
    struct	sockaddr_in	*inetaddr;
516
    struct	sockaddr_in	*inetaddr;
517
    struct	sockaddr_in6	*inet6addr;
471
    struct sockaddr_in broad_addr;
518
    struct sockaddr_in broad_addr;
472
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
519
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
473
    _Xgethostbynameparams hparams;
520
    _Xgethostbynameparams hparams;
Lines 492-500 Link Here
492
    if (hp != NULL)
539
    if (hp != NULL)
493
    {
540
    {
494
	saddr.sa.sa_family = hp->h_addrtype;
541
	saddr.sa.sa_family = hp->h_addrtype;
495
	inetaddr = (struct sockaddr_in *) (&(saddr.sa));
542
	switch (hp->h_addrtype) {
496
	acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length);
543
	case AF_INET:
497
	len = sizeof(saddr.sa);
544
	    inetaddr = (struct sockaddr_in *) (&(saddr.sa));
545
	    acopy ( hp->h_addr, &(inetaddr->sin_addr), hp->h_length);
546
	    len = sizeof(saddr.sa);
547
	    break;
548
#ifdef IPv6
549
	case AF_INET6:
550
	    inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
551
	    acopy ( hp->h_addr, &(inet6addr->sin6_addr), hp->h_length);
552
	    len = sizeof(saddr.in6);
553
	    break;
554
#endif
555
	default:
556
	    goto DefineLocalHost;
557
	}
498
	family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
558
	family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
499
	if ( family != -1 && family != FamilyLocal )
559
	if ( family != -1 && family != FamilyLocal )
500
	{
560
	{
Lines 530-535 Link Here
530
		    XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
590
		    XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
531
						   &broad_addr);
591
						   &broad_addr);
532
		}
592
		}
593
#ifdef IPv6
594
		else if (family == FamilyInternetV6 &&
595
		  !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
596
		{
597
		    XdmcpRegisterConnection (family, (char *)addr, len);
598
		}
599
#endif
600
533
#endif /* XDMCP */
601
#endif /* XDMCP */
534
	    }
602
	    }
535
	}
603
	}
Lines 537-542 Link Here
537
    /*
605
    /*
538
     * now add a host of family FamilyLocalHost...
606
     * now add a host of family FamilyLocalHost...
539
     */
607
     */
608
DefineLocalHost:
540
    for (host = selfhosts;
609
    for (host = selfhosts;
541
	 host && !addrEqual(FamilyLocalHost, "", 0, host);
610
	 host && !addrEqual(FamilyLocalHost, "", 0, host);
542
	 host = host->next);
611
	 host = host->next);
Lines 557-562 Link Here
557
626
558
#else
627
#else
559
628
629
#ifdef USE_SIOCGLIFCONF
630
#define ifr_type    struct lifreq
631
#else
632
#define ifr_type    struct ifreq
633
#endif
634
560
#ifdef VARIABLE_IFREQ
635
#ifdef VARIABLE_IFREQ
561
#define ifr_size(p) (sizeof (struct ifreq) + \
636
#define ifr_size(p) (sizeof (struct ifreq) + \
562
		     (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
637
		     (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
Lines 567-573 Link Here
567
#define ifr_size(p) (p->ifr_addr.sa_len + IFNAMSIZ)
642
#define ifr_size(p) (p->ifr_addr.sa_len + IFNAMSIZ)
568
#define ifraddr_size(a) (a.sa_len)
643
#define ifraddr_size(a) (a.sa_len)
569
#else
644
#else
570
#define ifr_size(p) (sizeof (struct ifreq))
645
#define ifr_size(p) (sizeof (ifr_type))
571
#define ifraddr_size(a) (sizeof (a))
646
#define ifraddr_size(a) (sizeof (a))
572
#endif
647
#endif
573
#endif
648
#endif
Lines 581-588 Link Here
581
{
656
{
582
#ifndef HAS_GETIFADDRS
657
#ifndef HAS_GETIFADDRS
583
    char		buf[2048], *cp, *cplim;
658
    char		buf[2048], *cp, *cplim;
659
    void *		bufptr = buf;   
660
#ifdef USE_SIOCGLIFCONF
661
    struct lifconf	ifc;
662
    register struct lifreq *ifr;
663
#ifdef SIOCGLIFNUM
664
    struct lifnum	ifn;
665
#endif
666
#else
584
    struct ifconf	ifc;
667
    struct ifconf	ifc;
585
    register struct ifreq *ifr;
668
    register struct ifreq *ifr;
669
#endif 
586
#else 
670
#else 
587
    struct ifaddrs *	ifap, *ifr;
671
    struct ifaddrs *	ifap, *ifr;
588
#endif
672
#endif
Lines 621-657 Link Here
621
    }
705
    }
622
#endif /* DNETCONN */
706
#endif /* DNETCONN */
623
#ifndef HAS_GETIFADDRS
707
#ifndef HAS_GETIFADDRS
624
    ifc.ifc_len = sizeof (buf);
625
    ifc.ifc_buf = buf;
626
    if (ifioctl (fd, SIOCGIFCONF, (pointer) &ifc) < 0)
627
        Error ("Getting interface configuration (4)");
628
708
709
    len = sizeof(buf);
710
711
#ifdef USE_SIOCGLIFCONF
712
    
713
#ifdef SIOCGLIFNUM
714
    ifn.lifn_family = AF_UNSPEC;
715
    ifn.lifn_flags = 0;
716
    if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0)
717
        Error ("Getting interface count");    
718
    if (len < (ifn.lifn_count * sizeof(struct lifreq))) {
719
	len = ifn.lifn_count * sizeof(struct lifreq);
720
	bufptr = xalloc(len);
721
    }
722
#endif
723
    
724
    ifc.lifc_family = AF_UNSPEC;
725
    ifc.lifc_flags = 0;
726
    ifc.lifc_len = len;
727
    ifc.lifc_buf = bufptr;
728
729
#define IFC_IOCTL_REQ SIOCGLIFCONF
730
#define IFC_IFC_REQ ifc.lifc_req
731
#define IFC_IFC_LEN ifc.lifc_len
732
#define IFR_IFR_ADDR ifr->lifr_addr
733
#define IFR_IFR_NAME ifr->lifr_name
734
735
#else /* Use SIOCGIFCONF */
736
    ifc.ifc_len = len;
737
    ifc.ifc_buf = bufptr;
738
739
#define IFC_IOCTL_REQ SIOCGIFCONF
629
#ifdef ISC
740
#ifdef ISC
630
#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf
741
#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf
631
#else
742
#else
632
#define IFC_IFC_REQ ifc.ifc_req
743
#define IFC_IFC_REQ ifc.ifc_req
633
#endif /* ISC */
744
#endif /* ISC */
745
#define IFC_IFC_LEN ifc.ifc_len
746
#define IFR_IFR_ADDR ifr->ifr_addr
747
#define IFR_IFR_NAME ifr->ifr_name
748
#endif
749
750
    if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0)
751
        Error ("Getting interface configuration (4)");
634
752
635
    cplim = (char *) IFC_IFC_REQ + ifc.ifc_len;
753
    cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN;
636
    
754
    
637
    for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
755
    for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
638
    {
756
    {
639
	ifr = (struct ifreq *) cp;
757
	ifr = (ifr_type *) cp;
640
	len = ifraddr_size (ifr->ifr_addr);
758
	len = ifraddr_size (IFR_IFR_ADDR);
759
	family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR, 
760
	  			&len, (pointer *)&addr);
641
#ifdef DNETCONN
761
#ifdef DNETCONN
642
	/*
762
	/*
643
	 * DECnet was handled up above.
763
	 * DECnet was handled up above.
644
	 */
764
	 */
645
	if (ifr->ifr_addr.sa_family == AF_DECnet)
765
	if (family == AF_DECnet)
646
	    continue;
766
	    continue;
647
#endif /* DNETCONN */
767
#endif /* DNETCONN */
648
	family = ConvertAddr (&ifr->ifr_addr, &len, (pointer *)&addr);
649
        if (family == -1 || family == FamilyLocal)
768
        if (family == -1 || family == FamilyLocal)
650
	    continue;
769
	    continue;
651
#ifdef DEF_SELF_DEBUG
770
#ifdef DEF_SELF_DEBUG
652
	if (family == FamilyInternet) 
771
	if (family == FamilyInternet) 
653
	    ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n",
772
	    ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %d.%d.%d.%d\n",
654
		   ifr->ifr_name, addr[0], addr[1], addr[2], addr[3]);
773
		   IFR_IFR_NAME, addr[0], addr[1], addr[2], addr[3]);
774
#ifdef IPv6
775
	else if (family == FamilyInternetV6) {
776
	    char cp[INET6_ADDRSTRLEN] = "";
777
	    inet_ntop(AF_INET6, addr, cp, sizeof(cp));
778
	    ErrorF("Xserver: DefineSelf(): ifname = %s, addr = %s\n",
779
		   IFR_IFR_NAME,  cp);
780
	}
781
#endif
655
#endif /* DEF_SELF_DEBUG */
782
#endif /* DEF_SELF_DEBUG */
656
        for (host = selfhosts;
783
        for (host = selfhosts;
657
 	     host && !addrEqual (family, addr, len, host);
784
 	     host && !addrEqual (family, addr, len, host);
Lines 670-697 Link Here
670
	}
797
	}
671
#ifdef XDMCP
798
#ifdef XDMCP
672
	{
799
	{
800
#ifdef USE_SIOCGLIFCONF
801
	    struct sockaddr_storage broad_addr;
802
#else
673
	    struct sockaddr broad_addr;
803
	    struct sockaddr broad_addr;
804
#endif
674
805
675
	    /*
806
	    /*
676
	     * If this isn't an Internet Address, don't register it.
807
	     * If this isn't an Internet Address, don't register it.
677
	     */
808
	     */
678
	    if (family != FamilyInternet)
809
	    if (family != FamilyInternet
810
#ifdef IPv6
811
	      && family != FamilyInternetV6
812
#endif
813
		)
679
		continue;
814
		continue;
680
815
681
	    /*
816
	    /*
682
 	     * ignore 'localhost' entries as they're not useful
817
 	     * ignore 'localhost' entries as they're not useful
683
	     * on the other end of the wire
818
	     * on the other end of the wire
684
	     */
819
	     */
685
	    if (len == 4 &&
820
	    if (family == FamilyInternet &&
686
		addr[0] == 127 && addr[1] == 0 &&
821
		addr[0] == 127 && addr[1] == 0 &&
687
		addr[2] == 0 && addr[3] == 1)
822
		addr[2] == 0 && addr[3] == 1)
688
		continue;
823
		continue;
824
#ifdef IPv6
825
	    else if (family == FamilyInternetV6 && 
826
	      IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
827
		continue;
828
#endif
689
829
690
	    XdmcpRegisterConnection (family, (char *)addr, len);
830
	    XdmcpRegisterConnection (family, (char *)addr, len);
691
	    broad_addr = ifr->ifr_addr;
831
832
#ifdef IPv6
833
	    /* IPv6 doesn't support broadcasting, so we drop out here */
834
	    if (family == FamilyInternetV6)
835
		continue;
836
#endif
837
838
	    broad_addr = IFR_IFR_ADDR;
839
692
	    ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
840
	    ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
693
		htonl (INADDR_BROADCAST);
841
		htonl (INADDR_BROADCAST);
694
#ifdef SIOCGIFBRDADDR
842
#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR)
843
	    {
844
	    	struct lifreq    broad_req;
845
    
846
	    	broad_req = *ifr;
847
		if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 &&
848
		    (broad_req.lifr_flags & IFF_BROADCAST) &&
849
		    (broad_req.lifr_flags & IFF_UP)
850
		    )
851
		{
852
		    broad_req = *ifr;
853
		    if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1)
854
			broad_addr = broad_req.lifr_broadaddr;
855
		    else
856
			continue;
857
		}
858
		else
859
		    continue;
860
	    }
861
862
#elif defined(SIOCGIFBRDADDR)
695
	    {
863
	    {
696
	    	struct ifreq    broad_req;
864
	    	struct ifreq    broad_req;
697
    
865
    
Lines 713-725 Link Here
713
#endif /* SIOCGIFBRDADDR */
881
#endif /* SIOCGIFBRDADDR */
714
#ifdef DEF_SELF_DEBUG
882
#ifdef DEF_SELF_DEBUG
715
	    ErrorF("Xserver: DefineSelf(): ifname = %s, baddr = %s\n",
883
	    ErrorF("Xserver: DefineSelf(): ifname = %s, baddr = %s\n",
716
		   ifr->ifr_name,
884
		   IFR_IFR_NAME,
717
	           inet_ntoa(((struct sockaddr_in *) &broad_addr)->sin_addr));
885
	           inet_ntoa(((struct sockaddr_in *) &broad_addr)->sin_addr));
718
#endif /* DEF_SELF_DEBUG */
886
#endif /* DEF_SELF_DEBUG */
719
	    XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr);
887
	    XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr);
720
	}
888
	}
721
#endif /* XDMCP */
889
#endif /* XDMCP */
722
    }
890
    }
891
    if (bufptr != buf)
892
        free(bufptr);    
723
#else /* HAS_GETIFADDRS */
893
#else /* HAS_GETIFADDRS */
724
    if (getifaddrs(&ifap) < 0) {
894
    if (getifaddrs(&ifap) < 0) {
725
	ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
895
	ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
Lines 837-849 Link Here
837
}
1007
}
838
#endif
1008
#endif
839
1009
1010
/* Default hosts bug fix: This variable is set to TRUE only when AddLocalHosts
1011
   is being run.  This tells NewHost that we are adding the default local
1012
   host entries and not to flag the entries as being explicitly requested */
1013
static int AddingLocalHosts = FALSE;
1014
840
void
1015
void
841
AddLocalHosts (void)
1016
AddLocalHosts (void)
842
{
1017
{
843
    HOST    *self;
1018
    HOST    *self;
844
1019
1020
    AddingLocalHosts = TRUE;
845
    for (self = selfhosts; self; self = self->next)
1021
    for (self = selfhosts; self; self = self->next)
846
	(void) NewHost (self->family, self->addr, self->len);
1022
	(void) NewHost (self->family, self->addr, self->len);
1023
    AddingLocalHosts = FALSE;
847
}
1024
}
848
1025
849
/* Reset access control list to initial hosts */
1026
/* Reset access control list to initial hosts */
Lines 858-872 Link Here
858
    FILE		*fd;
1035
    FILE		*fd;
859
    char		*ptr;
1036
    char		*ptr;
860
    int                 i, hostlen;
1037
    int                 i, hostlen;
1038
#if ((defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)) && !defined(IPv6)) || defined (DNETCONN)
861
    union {
1039
    union {
862
        struct sockaddr	sa;
1040
        struct sockaddr	sa;
863
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
1041
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
864
        struct sockaddr_in in;
1042
	struct sockaddr_in in;
865
#endif /* TCPCONN || STREAMSCONN */
1043
#endif /* TCPCONN || STREAMSCONN */
866
#ifdef DNETCONN
1044
#ifdef DNETCONN
867
        struct sockaddr_dn dn;
1045
	struct sockaddr_dn dn;
1046
#endif
1047
    }
868
#endif
1048
#endif
869
    } 			saddr;
870
#ifdef DNETCONN
1049
#ifdef DNETCONN
871
    struct nodeent 	*np;
1050
    struct nodeent 	*np;
872
    struct dn_naddr 	dnaddr, *dnaddrp, *dnet_addr();
1051
    struct dn_naddr 	dnaddr, *dnaddrp, *dnet_addr();
Lines 878-884 Link Here
878
    int			family = 0;
1057
    int			family = 0;
879
    pointer		addr;
1058
    pointer		addr;
880
    int 		len;
1059
    int 		len;
881
    register struct hostent *hp;
882
1060
883
    AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL;
1061
    AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL;
884
    LocalHostEnabled = FALSE;
1062
    LocalHostEnabled = FALSE;
Lines 902-907 Link Here
902
    {
1080
    {
903
        while (fgets (ohostname, sizeof (ohostname), fd))
1081
        while (fgets (ohostname, sizeof (ohostname), fd))
904
	{
1082
	{
1083
	family = FamilyWild;
905
	if (*ohostname == '#')
1084
	if (*ohostname == '#')
906
	    continue;
1085
	    continue;
907
    	if ((ptr = strchr(ohostname, '\n')) != 0)
1086
    	if ((ptr = strchr(ohostname, '\n')) != 0)
Lines 918-923 Link Here
918
	{
1097
	{
919
	    family = FamilyLocalHost;
1098
	    family = FamilyLocalHost;
920
	    NewHost(family, "", 0);
1099
	    NewHost(family, "", 0);
1100
	    LocalHostRequested = TRUE;	/* Default host bug fix */
921
	}
1101
	}
922
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
1102
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
923
	else if (!strncmp("inet:", lhostname, 5))
1103
	else if (!strncmp("inet:", lhostname, 5))
Lines 925-930 Link Here
925
	    family = FamilyInternet;
1105
	    family = FamilyInternet;
926
	    hostname = ohostname + 5;
1106
	    hostname = ohostname + 5;
927
	}
1107
	}
1108
#ifdef IPv6
1109
	else if (!strncmp("inetv6:", lhostname, 7))
1110
	{
1111
	    family = FamilyInternetV6;
1112
	    hostname = ohostname + 7;
1113
	}
1114
#endif
928
#endif
1115
#endif
929
#ifdef DNETCONN
1116
#ifdef DNETCONN
930
	else if (!strncmp("dnet:", lhostname, 5))
1117
	else if (!strncmp("dnet:", lhostname, 5))
Lines 993-1001 Link Here
993
#endif /* SECURE_RPC */
1180
#endif /* SECURE_RPC */
994
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
1181
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
995
	{
1182
	{
1183
#ifdef IPv6
1184
	    if ( (family == FamilyInternet) || (family == FamilyInternetV6)
1185
	      || (family == FamilyWild) ) 
1186
            {
1187
		struct addrinfo *addresses;
1188
		struct addrinfo *a;
1189
		int f;
1190
	    
1191
		if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
1192
		    for (a = addresses ; a != NULL ; a = a->ai_next) {
1193
			len = a->ai_addrlen;
1194
			f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr);
1195
			if ( (family == f) || 
1196
			     ((family == FamilyWild) && (f != -1)) ) {
1197
			    NewHost(f, addr, len);
1198
			}			
1199
		    }
1200
		    freeaddrinfo(addresses);
1201
		}
1202
	    }
1203
#else
996
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
1204
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
997
	    _Xgethostbynameparams hparams;
1205
	    _Xgethostbynameparams hparams;
998
#endif
1206
#endif
1207
	    register struct hostent *hp;
999
1208
1000
    	    /* host name */
1209
    	    /* host name */
1001
    	    if ((family == FamilyInternet &&
1210
    	    if ((family == FamilyInternet &&
Lines 1017-1022 Link Here
1017
#endif
1226
#endif
1018
		}
1227
		}
1019
    	    }
1228
    	    }
1229
#endif /* IPv6 */
1020
        }
1230
        }
1021
#endif /* TCPCONN || STREAMSCONN */
1231
#endif /* TCPCONN || STREAMSCONN */
1022
	family = FamilyWild;
1232
	family = FamilyWild;
Lines 1158-1163 Link Here
1158
	break;
1368
	break;
1159
#endif
1369
#endif
1160
    case FamilyInternet:
1370
    case FamilyInternet:
1371
#ifdef IPv6
1372
    case FamilyInternetV6:
1373
#endif
1161
    case FamilyDECnet:
1374
    case FamilyDECnet:
1162
    case FamilyChaos:
1375
    case FamilyChaos:
1163
	if ((len = CheckAddr (family, pAddr, length)) < 0)
1376
	if ((len = CheckAddr (family, pAddr, length)) < 0)
Lines 1206-1211 Link Here
1206
        if (addrEqual (family, addr, len, host))
1419
        if (addrEqual (family, addr, len, host))
1207
	    return TRUE;
1420
	    return TRUE;
1208
    }
1421
    }
1422
    if (!AddingLocalHosts) {			/* Default host bug fix */
1423
	for (host = selfhosts; host; host = host->next) {
1424
	    if (addrEqual (family, addr, len, host)) {
1425
		host->requested = TRUE;
1426
		break;
1427
	    }	    
1428
	}
1429
    }
1209
    MakeHost(host,len)
1430
    MakeHost(host,len)
1210
    if (!host)
1431
    if (!host)
1211
	return FALSE;
1432
	return FALSE;
Lines 1247-1252 Link Here
1247
	break;
1468
	break;
1248
#endif
1469
#endif
1249
    case FamilyInternet:
1470
    case FamilyInternet:
1471
#ifdef IPv6
1472
    case FamilyInternetV6:
1473
#endif
1250
    case FamilyDECnet:
1474
    case FamilyDECnet:
1251
    case FamilyChaos:
1475
    case FamilyChaos:
1252
    	if ((len = CheckAddr (family, pAddr, length)) < 0)
1476
    	if ((len = CheckAddr (family, pAddr, length)) < 0)
Lines 1336-1341 Link Here
1336
	else
1560
	else
1337
	    len = -1;
1561
	    len = -1;
1338
        break;
1562
        break;
1563
#ifdef IPv6
1564
      case FamilyInternetV6:
1565
	if (length == sizeof (struct in6_addr))
1566
	    len = length;
1567
	else
1568
	    len = -1;
1569
        break;
1570
#endif
1339
#endif 
1571
#endif 
1340
#ifdef DNETCONN
1572
#ifdef DNETCONN
1341
      case FamilyDECnet:
1573
      case FamilyDECnet:
Lines 1424-1429 Link Here
1424
        *len = sizeof (struct in_addr);
1656
        *len = sizeof (struct in_addr);
1425
        *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
1657
        *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
1426
        return FamilyInternet;
1658
        return FamilyInternet;
1659
#ifdef IPv6
1660
    case AF_INET6: 
1661
    {
1662
	struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
1663
	if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) {
1664
	    *len = sizeof (struct in_addr);
1665
	    *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]);
1666
	    return FamilyInternet;
1667
	} else {
1668
	    *len = sizeof (struct in6_addr);
1669
	    *addr = (pointer) &(saddr6->sin6_addr);
1670
	    return FamilyInternetV6;
1671
	}
1672
    }
1673
#endif
1427
#endif
1674
#endif
1428
#ifdef DNETCONN
1675
#ifdef DNETCONN
1429
    case AF_DECnet:
1676
    case AF_DECnet:
(-)4.3.0/xc/programs/Xserver/os/connection.c (+13 lines)
Lines 1-4 Link Here
1
/* $Xorg: connection.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */
1
/* $Xorg: connection.c,v 1.6 2001/02/09 02:05:23 xorgcvs Exp $ */
2
/* Updated for IPv6 */
2
/***********************************************************
3
/***********************************************************
3
4
4
Copyright 1987, 1989, 1998  The Open Group
5
Copyright 1987, 1989, 1998  The Open Group
Lines 72-77 Link Here
72
#include <errno.h>
73
#include <errno.h>
73
#include <signal.h>
74
#include <signal.h>
74
#include <stdio.h>
75
#include <stdio.h>
76
#include <stdlib.h>
75
77
76
#ifndef WIN32
78
#ifndef WIN32
77
#if defined(Lynx)
79
#if defined(Lynx)
Lines 123-128 Link Here
123
#    endif
125
#    endif
124
#  endif
126
#  endif
125
# endif
127
# endif
128
# include <arpa/inet.h>
126
#endif
129
#endif
127
130
128
#ifdef AMTCPCONN
131
#ifdef AMTCPCONN
Lines 510-515 Link Here
510
		    inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr),
513
		    inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr),
511
		    ntohs(((struct sockaddr_in *) saddr)->sin_port));
514
		    ntohs(((struct sockaddr_in *) saddr)->sin_port));
512
	    break;
515
	    break;
516
#ifdef IPv6
517
	case AF_INET6: {
518
	    char ipaddr[INET6_ADDRSTRLEN];
519
	    inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr,
520
	      ipaddr, sizeof(ipaddr));
521
	    sprintf(out, "IP %s port %d", ipaddr,		    
522
		    ((struct sockaddr_in6 *) saddr)->sin6_port);
523
	}
524
	    break;
525
#endif
513
#endif
526
#endif
514
#ifdef DNETCONN
527
#ifdef DNETCONN
515
	case AF_DECnet:
528
	case AF_DECnet:
(-)4.3.0/xc/programs/Xserver/os/utils.c (-3 / +29 lines)
Lines 486-491 Link Here
486
486
487
void UseMsg()
487
void UseMsg()
488
{
488
{
489
#ifdef XDMCP
490
    extern void XdmcpUseMsg(void);
491
#endif
492
489
#if !defined(AIXrt) && !defined(AIX386)
493
#if !defined(AIXrt) && !defined(AIX386)
490
    ErrorF("use: X [:<display>] [option]\n");
494
    ErrorF("use: X [:<display>] [option]\n");
491
    ErrorF("-a #                   mouse acceleration (pixels)\n");
495
    ErrorF("-a #                   mouse acceleration (pixels)\n");
Lines 1119-1153 Link Here
1119
{
1123
{
1120
#define AUTHORIZATION_NAME "hp-hostname-1"
1124
#define AUTHORIZATION_NAME "hp-hostname-1"
1121
#if defined(TCPCONN) || defined(STREAMSCONN)
1125
#if defined(TCPCONN) || defined(STREAMSCONN)
1122
    static char result[1024];
1126
    static char *result = NULL;
1123
    static char *p = NULL;
1127
    static char *p = NULL;
1124
1128
1125
    if (p == NULL)
1129
    if (p == NULL)
1126
    {
1130
    {
1127
	char hname[1024], *hnameptr;
1131
	char hname[1024], *hnameptr;
1132
	unsigned int len;
1133
#ifdef IPv6
1134
	struct addrinfo hints, *ai = NULL;
1135
#else
1128
	struct hostent *host;
1136
	struct hostent *host;
1129
	int len;
1130
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
1137
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
1131
	_Xgethostbynameparams hparams;
1138
	_Xgethostbynameparams hparams;
1132
#endif
1139
#endif
1140
#endif
1133
1141
1134
	gethostname(hname, 1024);
1142
	gethostname(hname, 1024);
1143
#ifdef IPv6
1144
	bzero(&hints, sizeof(hints));
1145
	hints.ai_flags = AI_CANONNAME;
1146
	if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
1147
	    hnameptr = ai->ai_canonname;
1148
	} else {
1149
	    hnameptr = hname;
1150
	}
1151
#else
1135
	host = _XGethostbyname(hname, hparams);
1152
	host = _XGethostbyname(hname, hparams);
1136
	if (host == NULL)
1153
	if (host == NULL)
1137
	    hnameptr = hname;
1154
	    hnameptr = hname;
1138
	else
1155
	else
1139
	    hnameptr = host->h_name;
1156
	    hnameptr = host->h_name;
1157
#endif
1158
1159
	len = strlen(hnameptr) + 1;
1160
	result = xalloc(len + sizeof(AUTHORIZATION_NAME) + 4);
1140
1161
1141
	p = result;
1162
	p = result;
1142
        *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
1163
        *p++ = sizeof(AUTHORIZATION_NAME) >> 8;
1143
        *p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
1164
        *p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
1144
        *p++ = (len = strlen(hnameptr) + 1) >> 8;
1165
        *p++ = (len) >> 8;
1145
        *p++ = (len & 0xff);
1166
        *p++ = (len & 0xff);
1146
1167
1147
	memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
1168
	memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
1148
	p += sizeof(AUTHORIZATION_NAME);
1169
	p += sizeof(AUTHORIZATION_NAME);
1149
	memmove(p, hnameptr, len);
1170
	memmove(p, hnameptr, len);
1150
	p += len;
1171
	p += len;
1172
#ifdef IPv6
1173
	if (hnameptr == ai->ai_canonname) {
1174
	    freeaddrinfo(ai);
1175
	}
1176
#endif
1151
    }
1177
    }
1152
    *authlen = p - result;
1178
    *authlen = p - result;
1153
    *authorizations = result;
1179
    *authorizations = result;
(-)4.3.0/xc/programs/Xserver/os/xdmcp.c (-73 / +411 lines)
Lines 1-4 Link Here
1
/* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */
1
/* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */
2
/* Updated for IPv6 */
2
/*
3
/*
3
 * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
4
 * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.
4
 *
5
 *
Lines 43-48 Link Here
43
#endif
44
#endif
44
45
45
#include <stdio.h>
46
#include <stdio.h>
47
#include <stdlib.h>
46
#include "X.h"
48
#include "X.h"
47
#include "Xmd.h"
49
#include "Xmd.h"
48
#include "misc.h"
50
#include "misc.h"
Lines 74-80 Link Here
74
76
75
static int		    xdmcpSocket, sessionSocket;
77
static int		    xdmcpSocket, sessionSocket;
76
static xdmcp_states	    state;
78
static xdmcp_states	    state;
79
#ifdef IPv6
80
static int		    xdmcpSocket6;
81
static struct sockaddr_storage req_sockaddr;
82
#else
77
static struct sockaddr_in   req_sockaddr;
83
static struct sockaddr_in   req_sockaddr;
84
#endif
78
static int		    req_socklen;
85
static int		    req_socklen;
79
static CARD32		    SessionID;
86
static CARD32		    SessionID;
80
static CARD32		    timeOutTime;
87
static CARD32		    timeOutTime;
Lines 89-106 Link Here
89
96
90
static XdmcpBuffer	    buffer;
97
static XdmcpBuffer	    buffer;
91
98
92
static struct sockaddr_in   ManagerAddress;
99
#ifdef IPv6
93
static struct sockaddr_in   FromAddress;
100
101
static struct addrinfo *mgrAddr;
102
static struct addrinfo *mgrAddrFirst;
103
104
#define SOCKADDR_TYPE	struct sockaddr_storage
105
#define SOCKLEN_TYPE 	socklen_t
106
#define SOCKADDR_FAMILY ss_family
107
108
#ifdef BSD44SOCKETS
109
#define SOCKLEN_FIELD 	ss_len
110
#endif
111
112
#else
113
114
#define SOCKADDR_TYPE	struct sockaddr_in
115
#define SOCKLEN_TYPE	size_t
116
#define SOCKADDR_FAMILY sin_family
117
118
#ifdef BSD44SOCKETS
119
#define SOCKLEN_FIELD sin_len
120
#endif
121
122
#endif
123
124
static SOCKADDR_TYPE   ManagerAddress;
125
static SOCKADDR_TYPE   FromAddress;
126
127
#ifdef SOCKLEN_FIELD
128
#define ManagerAddressLen ManagerAddress.SOCKLEN_FIELD
129
#define FromAddressLen FromAddress.SOCKLEN_FIELD
130
#else
131
static SOCKLEN_TYPE ManagerAddressLen, FromAddressLen;
132
#endif
133
134
#ifdef IPv6
135
static struct multicastinfo {
136
    struct multicastinfo	*next;
137
    struct addrinfo		*ai;
138
    int				 hops;
139
} *mcastlist;
140
#endif
94
141
95
static void XdmcpAddHost(
142
static void XdmcpAddHost(
96
    struct sockaddr_in  *from,
143
    struct sockaddr    *from,
97
    int			fromlen,
144
    int			fromlen,
98
    ARRAY8Ptr		AuthenticationName,
145
    ARRAY8Ptr		AuthenticationName,
99
    ARRAY8Ptr		hostname,
146
    ARRAY8Ptr		hostname,
100
    ARRAY8Ptr		status);
147
    ARRAY8Ptr		status);
101
148
102
static void XdmcpSelectHost(
149
static void XdmcpSelectHost(
103
    struct sockaddr_in	*host_sockaddr,
150
    struct sockaddr	*host_sockaddr,
104
    int			host_len,
151
    int			host_len,
105
    ARRAY8Ptr		AuthenticationName);
152
    ARRAY8Ptr		AuthenticationName);
106
153
Lines 118-124 Link Here
118
165
119
static void recv_willing_msg(
166
static void recv_willing_msg(
120
#if NeedFunctionPrototypes
167
#if NeedFunctionPrototypes
121
    struct sockaddr_in */*from*/,
168
    struct sockaddr */*from*/,
122
    int /*fromlen*/,
169
    int /*fromlen*/,
123
    unsigned /*length*/
170
    unsigned /*length*/
124
#endif
171
#endif
Lines 195-203 Link Here
195
242
196
static void get_fromaddr_by_name(int /*argc*/, char **/*argv*/, int /*i*/);
243
static void get_fromaddr_by_name(int /*argc*/, char **/*argv*/, int /*i*/);
197
244
245
#ifdef IPv6
246
static int get_mcast_options(
247
#if NeedFunctionPrototypes
248
    int /*argc*/,
249
    char **/*argv*/,
250
    int /*i*/
251
#endif
252
);
253
#endif
254
198
static void receive_packet(
255
static void receive_packet(
199
#if NeedFunctionPrototypes
256
#if NeedFunctionPrototypes
200
    void
257
    int socketfd
201
#endif
258
#endif
202
);
259
);
203
260
Lines 249-255 Link Here
249
);
306
);
250
307
251
308
252
static short	xdm_udp_port = XDM_UDP_PORT;
309
static unsigned short	xdm_udp_port = XDM_UDP_PORT;
253
static Bool	OneSession = FALSE;
310
static Bool	OneSession = FALSE;
254
static const char 	*xdm_from = NULL;
311
static const char 	*xdm_from = NULL;
255
312
Lines 258-263 Link Here
258
{
315
{
259
    ErrorF("-query host-name       contact named host for XDMCP\n");
316
    ErrorF("-query host-name       contact named host for XDMCP\n");
260
    ErrorF("-broadcast             broadcast for XDMCP\n");
317
    ErrorF("-broadcast             broadcast for XDMCP\n");
318
#ifdef IPv6
319
    ErrorF("-multicast [addr [hops]] IPv6 multicast for XDMCP\n");
320
#endif
261
    ErrorF("-indirect host-name    contact named host for indirect XDMCP\n");
321
    ErrorF("-indirect host-name    contact named host for indirect XDMCP\n");
262
    ErrorF("-port port-num         UDP port number to send messages to\n");
322
    ErrorF("-port port-num         UDP port number to send messages to\n");
263
    ErrorF("-from local-address    specify the local address to connect from\n");
323
    ErrorF("-from local-address    specify the local address to connect from\n");
Lines 273-279 Link Here
273
XdmcpOptions(int argc, char **argv, int i)
333
XdmcpOptions(int argc, char **argv, int i)
274
{
334
{
275
    if (strcmp(argv[i], "-query") == 0) {
335
    if (strcmp(argv[i], "-query") == 0) {
276
	get_manager_by_name(argc, argv, ++i);
336
	get_manager_by_name(argc, argv, i++);
277
	XDM_INIT_STATE = XDM_QUERY;
337
	XDM_INIT_STATE = XDM_QUERY;
278
	AccessUsingXdmcp ();
338
	AccessUsingXdmcp ();
279
	return (i + 1);
339
	return (i + 1);
Lines 283-290 Link Here
283
	AccessUsingXdmcp ();
343
	AccessUsingXdmcp ();
284
	return (i + 1);
344
	return (i + 1);
285
    }
345
    }
346
#ifdef IPv6
347
    if (strcmp(argv[i], "-multicast") == 0) {
348
	i = get_mcast_options(argc, argv, ++i);
349
	XDM_INIT_STATE = XDM_MULTICAST;
350
	AccessUsingXdmcp ();
351
	return (i + 1);
352
    }
353
#endif
286
    if (strcmp(argv[i], "-indirect") == 0) {
354
    if (strcmp(argv[i], "-indirect") == 0) {
287
	get_manager_by_name(argc, argv, ++i);
355
	get_manager_by_name(argc, argv, i++);
288
	XDM_INIT_STATE = XDM_INDIRECT;
356
	XDM_INIT_STATE = XDM_INDIRECT;
289
	AccessUsingXdmcp ();
357
	AccessUsingXdmcp ();
290
	return (i + 1);
358
	return (i + 1);
Lines 294-300 Link Here
294
	    ErrorF("Xserver: missing port number in command line\n");
362
	    ErrorF("Xserver: missing port number in command line\n");
295
	    exit(1);
363
	    exit(1);
296
	}
364
	}
297
	xdm_udp_port = atoi(argv[i]);
365
	xdm_udp_port = (unsigned short) atoi(argv[i]);
298
	return (i + 1);
366
	return (i + 1);
299
    }
367
    }
300
    if (strcmp(argv[i], "-from") == 0) {
368
    if (strcmp(argv[i], "-from") == 0) {
Lines 348-353 Link Here
348
416
349
#define MAX_BROADCAST	10
417
#define MAX_BROADCAST	10
350
418
419
/* This stays sockaddr_in since IPv6 doesn't support broadcast */
351
static struct sockaddr_in   BroadcastAddresses[MAX_BROADCAST];
420
static struct sockaddr_in   BroadcastAddresses[MAX_BROADCAST];
352
static int		    NumBroadcastAddresses;
421
static int		    NumBroadcastAddresses;
353
422
Lines 478-487 Link Here
478
	XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
547
	XdmcpDisposeARRAYofARRAY8 (&ConnectionAddresses);
479
	xdmcpGeneration = serverGeneration;
548
	xdmcpGeneration = serverGeneration;
480
    }
549
    }
481
    if (addrlen == sizeof(struct in_addr) && xdm_from != NULL)
550
    if (xdm_from != NULL) {	/* Only register the requested address */
482
    {
551
	const void *regAddr = address;
483
	/* Only register the requested address */
552
	const void *fromAddr = NULL;
484
	if (memcmp(address, &FromAddress.sin_addr, addrlen) != 0) {
553
	int regAddrlen = addrlen;
554
555
	if (addrlen == sizeof(struct in_addr)) {
556
	    if (FromAddress.SOCKADDR_FAMILY == AF_INET) {
557
		fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
558
	    } 
559
#ifdef IPv6
560
	    else if ((FromAddress.SOCKADDR_FAMILY == AF_INET6) &&
561
	      IN6_IS_ADDR_V4MAPPED(
562
		  &((struct sockaddr_in6 *)&FromAddress)->sin6_addr)) {
563
		fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr.s6_addr[12];
564
	    } 
565
#endif
566
	}
567
#ifdef IPv6
568
	else if (addrlen == sizeof(struct in6_addr)) {
569
	    if (FromAddress.SOCKADDR_FAMILY == AF_INET6) {
570
		fromAddr = &((struct sockaddr_in6 *)&FromAddress)->sin6_addr;
571
	    } else if ((FromAddress.SOCKADDR_FAMILY == AF_INET) &&
572
	      IN6_IS_ADDR_V4MAPPED((struct in6_addr *) address)) {
573
		fromAddr = &((struct sockaddr_in *)&FromAddress)->sin_addr;
574
		regAddr = &((struct sockaddr_in6 *)&address)->sin6_addr.s6_addr[12];
575
		regAddrlen = sizeof(struct in_addr);
576
	    }
577
	}
578
#endif
579
	if (fromAddr && memcmp(regAddr, fromAddr, regAddrlen) != 0) {
485
	    return;
580
	    return;
486
	}
581
	}
487
    }
582
    }
Lines 665-670 Link Here
665
    if (state == XDM_OFF)
760
    if (state == XDM_OFF)
666
	return;
761
	return;
667
    FD_SET(xdmcpSocket, LastSelectMask);
762
    FD_SET(xdmcpSocket, LastSelectMask);
763
#ifdef IPv6
764
    FD_SET(xdmcpSocket6, LastSelectMask);
765
#endif
668
    if (timeOutTime == 0)
766
    if (timeOutTime == 0)
669
	return;
767
	return;
670
    millisToGo = timeOutTime - GetTimeInMillis();
768
    millisToGo = timeOutTime - GetTimeInMillis();
Lines 695-703 Link Here
695
    {
793
    {
696
	if (FD_ISSET(xdmcpSocket, LastSelectMask))
794
	if (FD_ISSET(xdmcpSocket, LastSelectMask))
697
	{
795
	{
698
	    receive_packet();
796
	    receive_packet(xdmcpSocket);
699
	    FD_CLR(xdmcpSocket, LastSelectMask);
797
	    FD_CLR(xdmcpSocket, LastSelectMask);
700
	} 
798
	} 
799
#ifdef IPv6
800
	if (FD_ISSET(xdmcpSocket6, LastSelectMask))
801
	{
802
	    receive_packet(xdmcpSocket6);
803
	    FD_CLR(xdmcpSocket6, LastSelectMask);
804
	} 
805
#endif
701
	XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
806
	XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
702
	if (XFD_ANYSET(&devicesReadable))
807
	if (XFD_ANYSET(&devicesReadable))
703
	{
808
	{
Lines 728-737 Link Here
728
833
729
static void
834
static void
730
XdmcpSelectHost(
835
XdmcpSelectHost(
731
    struct sockaddr_in	*host_sockaddr,
836
    struct sockaddr	*host_sockaddr,
732
    int			host_len,
837
    int			host_len,
733
    ARRAY8Ptr		AuthenticationName)
838
    ARRAY8Ptr		AuthenticationName)
734
{
839
{
840
#ifdef IPv6
841
    /* Don't need list of addresses for host anymore */
842
    if (mgrAddrFirst != NULL) {
843
	freeaddrinfo(mgrAddrFirst);
844
	mgrAddrFirst = NULL;
845
	mgrAddr = NULL;
846
    }
847
#endif
735
    state = XDM_START_CONNECTION;
848
    state = XDM_START_CONNECTION;
736
    memmove(&req_sockaddr, host_sockaddr, host_len);
849
    memmove(&req_sockaddr, host_sockaddr, host_len);
737
    req_socklen = host_len;
850
    req_socklen = host_len;
Lines 748-754 Link Here
748
/*ARGSUSED*/
861
/*ARGSUSED*/
749
static void
862
static void
750
XdmcpAddHost(
863
XdmcpAddHost(
751
    struct sockaddr_in  *from,
864
    struct sockaddr    *from,
752
    int			fromlen,
865
    int			fromlen,
753
    ARRAY8Ptr		AuthenticationName,
866
    ARRAY8Ptr		AuthenticationName,
754
    ARRAY8Ptr		hostname,
867
    ARRAY8Ptr		hostname,
Lines 765-778 Link Here
765
ARRAY8	UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
878
ARRAY8	UnwillingMessage = { (CARD8) 14, (CARD8 *) "Host unwilling" };
766
879
767
static void
880
static void
768
receive_packet(void)
881
receive_packet(int socketfd)
769
{
882
{
883
#ifdef IPv6
884
    struct sockaddr_storage from;
885
#else
770
    struct sockaddr_in from;
886
    struct sockaddr_in from;
771
    int fromlen = sizeof(struct sockaddr_in);
887
#endif
888
    int fromlen = sizeof(from);
772
    XdmcpHeader	header;
889
    XdmcpHeader	header;
773
890
774
    /* read message off socket */
891
    /* read message off socket */
775
    if (!XdmcpFill (xdmcpSocket, &buffer, (XdmcpNetaddr) &from, &fromlen))
892
    if (!XdmcpFill (socketfd, &buffer, (XdmcpNetaddr) &from, &fromlen))
776
	return;
893
	return;
777
894
778
    /* reset retransmission backoff */
895
    /* reset retransmission backoff */
Lines 786-792 Link Here
786
903
787
    switch (header.opcode) {
904
    switch (header.opcode) {
788
    case WILLING:
905
    case WILLING:
789
	recv_willing_msg(&from, fromlen, header.length);
906
	recv_willing_msg((struct sockaddr *) &from, fromlen, header.length);
790
	break;
907
	break;
791
    case UNWILLING:
908
    case UNWILLING:
792
	XdmcpFatal("Manager unwilling", &UnwillingMessage);
909
	XdmcpFatal("Manager unwilling", &UnwillingMessage);
Lines 821-826 Link Here
821
    case XDM_QUERY:
938
    case XDM_QUERY:
822
    case XDM_BROADCAST:
939
    case XDM_BROADCAST:
823
    case XDM_INDIRECT:
940
    case XDM_INDIRECT:
941
#ifdef IPv6
942
    case XDM_MULTICAST:
943
#endif
824
	send_query_msg();
944
	send_query_msg();
825
	break;
945
	break;
826
    case XDM_START_CONNECTION:
946
    case XDM_START_CONNECTION:
Lines 873-885 Link Here
873
    }
993
    }
874
    else if (timeOutRtx >= XDM_RTX_LIMIT)
994
    else if (timeOutRtx >= XDM_RTX_LIMIT)
875
    {
995
    {
876
	ErrorF("XDM: too many retransmissions\n");
996
	/* Quit if "-once" specified, otherwise reset and try again. */
877
	state = XDM_AWAIT_USER_INPUT;
997
        if (OneSession) {
878
	timeOutTime = 0;
998
	    dispatchException |= DE_TERMINATE;
879
	timeOutRtx = 0;
999
	    ErrorF("XDM: too many retransmissions\n");
1000
	} else { 
1001
	    XdmcpDeadSession("too many retransmissions");
1002
	}
880
	return;
1003
	return;
881
    }
1004
    }
882
1005
1006
#ifdef IPv6
1007
    if (state == XDM_COLLECT_QUERY || state == XDM_COLLECT_INDIRECT_QUERY) {
1008
	/* Try next address */
1009
	for (mgrAddr = mgrAddr->ai_next; ; mgrAddr = mgrAddr->ai_next) {
1010
	    if (mgrAddr == NULL) {
1011
		mgrAddr = mgrAddrFirst;
1012
	    }
1013
	    if (mgrAddr->ai_family == AF_INET 
1014
	      || mgrAddr->ai_family == AF_INET6)
1015
		break;
1016
	}
1017
#ifndef SIN6_LEN
1018
	ManagerAddressLen = mgrAddr->ai_addrlen;
1019
#endif
1020
	memcpy(&ManagerAddress, mgrAddr->ai_addr, mgrAddr->ai_addrlen);
1021
    }
1022
#endif
1023
883
    switch (state) {
1024
    switch (state) {
884
    case XDM_COLLECT_QUERY:
1025
    case XDM_COLLECT_QUERY:
885
	state = XDM_QUERY;
1026
	state = XDM_QUERY;
Lines 887-892 Link Here
887
    case XDM_COLLECT_BROADCAST_QUERY:
1028
    case XDM_COLLECT_BROADCAST_QUERY:
888
	state = XDM_BROADCAST;
1029
	state = XDM_BROADCAST;
889
	break;
1030
	break;
1031
#ifdef IPv6
1032
    case XDM_COLLECT_MULTICAST_QUERY:
1033
	state = XDM_MULTICAST;
1034
	break;
1035
#endif
890
    case XDM_COLLECT_INDIRECT_QUERY:
1036
    case XDM_COLLECT_INDIRECT_QUERY:
891
	state = XDM_INDIRECT;
1037
	state = XDM_INDIRECT;
892
	break;
1038
	break;
Lines 988-993 Link Here
988
#else
1134
#else
989
    int soopts = 1;
1135
    int soopts = 1;
990
1136
1137
#ifdef IPv6
1138
    if ((xdmcpSocket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
1139
	XdmcpWarning("INET6 UDP socket creation failed");
1140
#endif
991
    if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
1141
    if ((xdmcpSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
992
	XdmcpWarning("UDP socket creation failed");
1142
	XdmcpWarning("UDP socket creation failed");
993
#ifdef SO_BROADCAST
1143
#ifdef SO_BROADCAST
Lines 996-1003 Link Here
996
	    XdmcpWarning("UDP set broadcast socket-option failed");
1146
	    XdmcpWarning("UDP set broadcast socket-option failed");
997
#endif /* SO_BROADCAST */
1147
#endif /* SO_BROADCAST */
998
    if (xdmcpSocket >= 0 && xdm_from != NULL) {
1148
    if (xdmcpSocket >= 0 && xdm_from != NULL) {
999
	if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress,
1149
	if (bind(xdmcpSocket, (struct sockaddr *)&FromAddress, 
1000
		 sizeof(FromAddress)) < 0) {
1150
		 FromAddressLen) < 0) {
1001
	    ErrorF("Xserver: failed to bind to -from address: %s\n", xdm_from);
1151
	    ErrorF("Xserver: failed to bind to -from address: %s\n", xdm_from);
1002
	    exit(1);
1152
	    exit(1);
1003
	}
1153
	}
Lines 1010-1016 Link Here
1010
{
1160
{
1011
    XdmcpHeader	header;
1161
    XdmcpHeader	header;
1012
    Bool	broadcast = FALSE;
1162
    Bool	broadcast = FALSE;
1163
#ifdef IPv6
1164
    Bool	multicast = FALSE;
1165
#endif
1013
    int		i;
1166
    int		i;
1167
    int 	socketfd = xdmcpSocket;
1014
1168
1015
    header.version = XDM_PROTOCOL_VERSION;
1169
    header.version = XDM_PROTOCOL_VERSION;
1016
    switch(state){
1170
    switch(state){
Lines 1023-1028 Link Here
1023
	state = XDM_COLLECT_BROADCAST_QUERY;
1177
	state = XDM_COLLECT_BROADCAST_QUERY;
1024
	broadcast = TRUE;
1178
	broadcast = TRUE;
1025
	break;
1179
	break;
1180
#ifdef IPv6
1181
    case XDM_MULTICAST:
1182
	header.opcode = (CARD16) BROADCAST_QUERY;
1183
	state = XDM_COLLECT_MULTICAST_QUERY;
1184
	multicast = TRUE;
1185
	break;
1186
#endif
1026
    case XDM_INDIRECT:
1187
    case XDM_INDIRECT:
1027
	header.opcode = (CARD16) INDIRECT_QUERY;
1188
	header.opcode = (CARD16) INDIRECT_QUERY;
1028
	state = XDM_COLLECT_INDIRECT_QUERY;
1189
	state = XDM_COLLECT_INDIRECT_QUERY;
Lines 1044-1059 Link Here
1044
	    XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &BroadcastAddresses[i],
1205
	    XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &BroadcastAddresses[i],
1045
			sizeof (struct sockaddr_in));
1206
			sizeof (struct sockaddr_in));
1046
    }
1207
    }
1208
#ifdef IPv6
1209
    else if (multicast)
1210
    {
1211
	struct multicastinfo *mcl;
1212
	struct addrinfo *ai;
1213
1214
	for (mcl = mcastlist; mcl != NULL; mcl = mcl->next) {
1215
	    for (ai = mcl->ai ; ai != NULL; ai = ai->ai_next) {
1216
		if (ai->ai_family == AF_INET) {
1217
		    unsigned char hopflag = (unsigned char) mcl->hops;
1218
		    socketfd = xdmcpSocket;
1219
		    setsockopt(socketfd, IPPROTO_IP, IP_MULTICAST_TTL,
1220
		      &hopflag, sizeof(hopflag));
1221
		} else if (ai->ai_family == AF_INET6) {
1222
		    int hopflag6 = mcl->hops;
1223
		    socketfd = xdmcpSocket6;
1224
		    setsockopt(socketfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
1225
		      &hopflag6, sizeof(hopflag6));
1226
		} else {
1227
		    continue;
1228
		}
1229
		XdmcpFlush (socketfd, &buffer, 
1230
		  	    (XdmcpNetaddr) ai->ai_addr, ai->ai_addrlen);
1231
		break;
1232
	    }
1233
	}
1234
    }
1235
#endif
1047
    else
1236
    else
1048
    {
1237
    {
1049
	XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &ManagerAddress,
1238
#ifdef IPv6
1239
	if (ManagerAddress.ss_family == AF_INET6)
1240
	    socketfd = xdmcpSocket6;
1241
#endif	
1242
	XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &ManagerAddress,
1050
		    sizeof (ManagerAddress));
1243
		    sizeof (ManagerAddress));
1051
    }
1244
    }
1052
}
1245
}
1053
1246
1054
static void
1247
static void
1055
recv_willing_msg(
1248
recv_willing_msg(
1056
    struct sockaddr_in	*from,
1249
    struct sockaddr	*from,
1057
    int			fromlen,
1250
    int			fromlen,
1058
    unsigned		length)
1251
    unsigned		length)
1059
{
1252
{
Lines 1077-1082 Link Here
1077
	    	XdmcpSelectHost(from, fromlen, &authenticationName);
1270
	    	XdmcpSelectHost(from, fromlen, &authenticationName);
1078
	    	break;
1271
	    	break;
1079
	    case XDM_COLLECT_BROADCAST_QUERY:
1272
	    case XDM_COLLECT_BROADCAST_QUERY:
1273
#ifdef IPv6
1274
	    case XDM_COLLECT_MULTICAST_QUERY:
1275
#endif
1080
	    case XDM_COLLECT_INDIRECT_QUERY:
1276
	    case XDM_COLLECT_INDIRECT_QUERY:
1081
	    	XdmcpAddHost(from, fromlen, &authenticationName, &hostname, &status);
1277
	    	XdmcpAddHost(from, fromlen, &authenticationName, &hostname, &status);
1082
	    	break;
1278
	    	break;
Lines 1097-1102 Link Here
1097
    int		    length;
1293
    int		    length;
1098
    int		    i;
1294
    int		    i;
1099
    ARRAY8	    authenticationData;
1295
    ARRAY8	    authenticationData;
1296
    int		    socketfd = xdmcpSocket;
1100
1297
1101
    header.version = XDM_PROTOCOL_VERSION;
1298
    header.version = XDM_PROTOCOL_VERSION;
1102
    header.opcode = (CARD16) REQUEST;
1299
    header.opcode = (CARD16) REQUEST;
Lines 1136-1142 Link Here
1136
    XdmcpDisposeARRAY8 (&authenticationData);
1333
    XdmcpDisposeARRAY8 (&authenticationData);
1137
    XdmcpWriteARRAYofARRAY8 (&buffer, &AuthorizationNames);
1334
    XdmcpWriteARRAYofARRAY8 (&buffer, &AuthorizationNames);
1138
    XdmcpWriteARRAY8 (&buffer, &ManufacturerDisplayID);
1335
    XdmcpWriteARRAY8 (&buffer, &ManufacturerDisplayID);
1139
    if (XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen))
1336
#ifdef IPv6
1337
    if (req_sockaddr.ss_family == AF_INET6)
1338
	socketfd = xdmcpSocket6;
1339
#endif
1340
    if (XdmcpFlush (socketfd, &buffer, 
1341
			(XdmcpNetaddr) &req_sockaddr, req_socklen))
1140
	state = XDM_AWAIT_REQUEST_RESPONSE;
1342
	state = XDM_AWAIT_REQUEST_RESPONSE;
1141
}
1343
}
1142
1344
Lines 1220-1225 Link Here
1220
send_manage_msg(void)
1422
send_manage_msg(void)
1221
{
1423
{
1222
    XdmcpHeader	header;
1424
    XdmcpHeader	header;
1425
    int socketfd = xdmcpSocket;
1223
1426
1224
    header.version = XDM_PROTOCOL_VERSION;
1427
    header.version = XDM_PROTOCOL_VERSION;
1225
    header.opcode = (CARD16) MANAGE;
1428
    header.opcode = (CARD16) MANAGE;
Lines 1231-1237 Link Here
1231
    XdmcpWriteCARD16 (&buffer, DisplayNumber);
1434
    XdmcpWriteCARD16 (&buffer, DisplayNumber);
1232
    XdmcpWriteARRAY8 (&buffer, &DisplayClass);
1435
    XdmcpWriteARRAY8 (&buffer, &DisplayClass);
1233
    state = XDM_AWAIT_MANAGE_RESPONSE;
1436
    state = XDM_AWAIT_MANAGE_RESPONSE;
1234
    XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
1437
#ifdef IPv6
1438
    if (req_sockaddr.ss_family == AF_INET6)
1439
	socketfd = xdmcpSocket6;
1440
#endif
1441
    XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
1235
}
1442
}
1236
1443
1237
static void
1444
static void
Lines 1278-1283 Link Here
1278
send_keepalive_msg(void)
1485
send_keepalive_msg(void)
1279
{
1486
{
1280
    XdmcpHeader	header;
1487
    XdmcpHeader	header;
1488
    int socketfd = xdmcpSocket;
1281
1489
1282
    header.version = XDM_PROTOCOL_VERSION;
1490
    header.version = XDM_PROTOCOL_VERSION;
1283
    header.opcode = (CARD16) KEEPALIVE;
1491
    header.opcode = (CARD16) KEEPALIVE;
Lines 1288-1294 Link Here
1288
    XdmcpWriteCARD32 (&buffer, SessionID);
1496
    XdmcpWriteCARD32 (&buffer, SessionID);
1289
1497
1290
    state = XDM_AWAIT_ALIVE_RESPONSE;
1498
    state = XDM_AWAIT_ALIVE_RESPONSE;
1291
    XdmcpFlush (xdmcpSocket, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
1499
#ifdef IPv6
1500
    if (req_sockaddr.ss_family == AF_INET6)
1501
	socketfd = xdmcpSocket6;
1502
#endif
1503
    XdmcpFlush (socketfd, &buffer, (XdmcpNetaddr) &req_sockaddr, req_socklen);
1292
}
1504
}
1293
1505
1294
static void
1506
static void
Lines 1340-1419 Link Here
1340
}
1552
}
1341
1553
1342
static void
1554
static void
1343
get_manager_by_name(
1555
get_addr_by_name(
1344
    int	    argc,
1556
    char *	argtype,
1345
    char    **argv,
1557
    char *	namestr,
1346
    int	    i)
1558
    int		port,
1347
{
1559
    int		socktype,
1560
    SOCKADDR_TYPE *addr,
1561
    SOCKLEN_TYPE *addrlen
1562
#ifdef IPv6
1563
      ,
1564
    struct addrinfo **aip,
1565
    struct addrinfo **aifirstp
1566
#endif
1567
    )
1568
{
1569
#ifdef IPv6
1570
    struct addrinfo *ai;
1571
    struct addrinfo hints;
1572
    char portstr[6];
1573
    char *pport = portstr;
1574
    int gaierr;
1575
1576
    bzero(&hints, sizeof(hints));
1577
    hints.ai_socktype = socktype;
1578
1579
    if (port == 0) {
1580
	pport = NULL;
1581
    } else if (port > 0 && port < 65535) {
1582
	sprintf(portstr, "%d", port);
1583
    } else {
1584
	ErrorF("Xserver: port out of range: %d\n", port);
1585
	exit(1);
1586
    }
1587
1588
    if (*aifirstp != NULL) {
1589
	freeaddrinfo(*aifirstp);	
1590
	*aifirstp = NULL;
1591
    }
1592
1593
    if ((gaierr = getaddrinfo(namestr, pport, &hints, aifirstp)) == 0) {
1594
	for (ai = *aifirstp; ai != NULL; ai = ai->ai_next) {
1595
	    if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6)
1596
		break;
1597
	}
1598
	if ((ai == NULL) || (ai->ai_addrlen > sizeof(SOCKADDR_TYPE))) {
1599
	    ErrorF ("Xserver: %s host %s not on supported network type\n", 
1600
	      argtype, namestr);
1601
	    exit (1);
1602
	} else {
1603
	    *aip = ai;
1604
	    *addrlen = ai->ai_addrlen;
1605
	    memcpy(addr, ai->ai_addr, ai->ai_addrlen);
1606
	}
1607
    } else {
1608
	ErrorF("Xserver: %s: %s %s\n", gai_strerror(gaierr), argtype, namestr);
1609
	exit(1);
1610
    }    
1611
#else
1348
    struct hostent *hep;
1612
    struct hostent *hep;
1349
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
1613
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
1350
    _Xgethostbynameparams hparams;
1614
    _Xgethostbynameparams hparams;
1351
#endif
1615
#endif
1352
1616
1353
    if (i == argc)
1617
    if (!(hep = _XGethostbyname(namestr, hparams)))
1354
    {
1618
    {
1355
	ErrorF("Xserver: missing host name in command line\n");
1619
	ErrorF("Xserver: %s unknown host: %s\n", argtype, namestr);
1356
	exit(1);
1357
    }
1358
    if (!(hep = _XGethostbyname(argv[i], hparams)))
1359
    {
1360
	ErrorF("Xserver: unknown host: %s\n", argv[i]);
1361
	exit(1);
1620
	exit(1);
1362
    }
1621
    }
1363
    if (hep->h_length == sizeof (struct in_addr))
1622
    if (hep->h_length == sizeof (struct in_addr))
1364
    {
1623
    {
1365
	memmove(&ManagerAddress.sin_addr, hep->h_addr, hep->h_length);
1624
	memmove(&addr->sin_addr, hep->h_addr, hep->h_length);
1366
#ifdef BSD44SOCKETS
1625
	*addrlen = sizeof(struct sockaddr_in);
1367
	ManagerAddress.sin_len = sizeof(ManagerAddress);
1626
	addr->sin_family = AF_INET;
1368
#endif
1627
	addr->sin_port = htons (xdm_udp_port);
1369
	ManagerAddress.sin_family = AF_INET;
1370
	ManagerAddress.sin_port = htons (xdm_udp_port);
1371
    }
1628
    }
1372
    else
1629
    else
1373
    {
1630
    {
1374
	ErrorF ("Xserver: host on strange network %s\n", argv[i]);
1631
	ErrorF ("Xserver: %s host on strange network %s\n", argtype, namestr);
1375
	exit (1);
1632
	exit (1);
1376
    }
1633
    }
1634
#endif
1377
}
1635
}
1378
1636
1379
static void
1637
static void
1380
get_fromaddr_by_name(
1638
get_manager_by_name(
1381
    int	    argc,
1639
    int	    argc,
1382
    char    **argv,
1640
    char    **argv,
1383
    int	    i)
1641
    int	    i)
1384
{
1642
{
1385
    struct hostent *hep;
1386
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
1387
    _Xgethostbynameparams hparams;
1388
#endif
1389
1643
1390
    if (i == argc)
1644
    if ((i + 1) == argc)
1391
    {
1645
    {
1392
	ErrorF("Xserver: missing -from host name in command line\n");
1646
	ErrorF("Xserver: missing %s host name in command line\n", argv[i]);
1393
	exit(1);
1647
	exit(1);
1394
    }
1648
    }
1395
    if (!(hep = _XGethostbyname(argv[i], hparams)))
1649
1650
    get_addr_by_name(argv[i], argv[i+1], xdm_udp_port, SOCK_DGRAM, 
1651
      &ManagerAddress, &ManagerAddressLen
1652
#ifdef IPv6
1653
      , &mgrAddr, &mgrAddrFirst
1654
#endif
1655
	);
1656
}
1657
1658
1659
static void
1660
get_fromaddr_by_name(
1661
    int	    argc,
1662
    char    **argv,
1663
    int	    i)
1664
{
1665
#ifdef IPv6
1666
    struct addrinfo *ai = NULL;
1667
    struct addrinfo *aifirst = NULL;
1668
#endif
1669
    if (i == argc)
1396
    {
1670
    {
1397
	ErrorF("Xserver: unknown host: %s\n", argv[i]);
1671
	ErrorF("Xserver: missing -from host name in command line\n");
1398
	exit(1);
1672
	exit(1);
1399
    }
1673
    }
1400
    if (hep->h_length == sizeof (struct in_addr))
1674
    get_addr_by_name("-from", argv[i], 0, 0, &FromAddress, &FromAddressLen
1401
    {
1675
#ifdef IPv6
1402
	memset(&FromAddress, 0, sizeof(FromAddress));
1676
      , &ai, &aifirst
1403
	memmove(&FromAddress.sin_addr, hep->h_addr, hep->h_length);
1404
#ifdef BSD44SOCKETS
1405
	FromAddress.sin_len = sizeof(FromAddress);
1406
#endif
1677
#endif
1407
	FromAddress.sin_family = AF_INET;
1678
	);
1408
	FromAddress.sin_port = 0;
1679
    xdm_from = argv[i];
1680
}
1681
1682
1683
#ifdef IPv6
1684
static int
1685
get_mcast_options(argc, argv, i)
1686
    int	    argc, i;
1687
    char    **argv;
1688
{
1689
    char *address = "ff02::1";	/* Default address until IANA assigns one */
1690
    int hopcount = 1;
1691
    struct addrinfo hints;
1692
    char portstr[6];
1693
    int gaierr;
1694
    struct addrinfo *ai, *firstai;
1695
1696
    if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
1697
	address = argv[i++];
1698
	if ((i < argc) && (argv[i][0] != '-') && (argv[i][0] != '+')) {
1699
	    hopcount = strtol(argv[i++], NULL, 10);
1700
	    if ((hopcount < 1) || (hopcount > 255)) {
1701
		ErrorF("Xserver: multicast hop count out of range: %d\n",
1702
		  hopcount);
1703
		exit(1);
1704
	    }
1705
	}
1409
    }
1706
    }
1410
    else
1707
1411
    {
1708
    if (xdm_udp_port > 0 && xdm_udp_port < 65535) {
1412
	ErrorF ("Xserver: -from host on strange network %s\n", argv[i]);
1709
	sprintf(portstr, "%d", xdm_udp_port);
1413
	exit (1);
1710
    } else {
1711
	ErrorF("Xserver: port out of range: %d\n", xdm_udp_port);
1712
	exit(1);
1414
    }
1713
    }
1415
    xdm_from = argv[i];
1714
    bzero(&hints, sizeof(hints));
1715
    hints.ai_socktype = SOCK_DGRAM;
1716
1717
    if ((gaierr = getaddrinfo(address, portstr, &hints, &firstai)) == 0) {
1718
	for (ai = firstai; ai != NULL; ai = ai->ai_next) {
1719
	    if (((ai->ai_family == AF_INET) && 
1720
	      	IN_MULTICAST(((struct sockaddr_in *) ai->ai_addr)
1721
							  ->sin_addr.s_addr))
1722
		|| ((ai->ai_family == AF_INET6) && 
1723
		  IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *) ai->ai_addr)
1724
							    ->sin6_addr)))
1725
		break;
1726
	}
1727
	if (ai == NULL) {
1728
	    ErrorF ("Xserver: address not supported multicast type %s\n", 
1729
	      address);
1730
	    exit (1);
1731
	} else {
1732
	    struct multicastinfo	*mcastinfo, *mcl;
1733
	    
1734
	    mcastinfo = malloc(sizeof(struct multicastinfo));
1735
	    mcastinfo->next = NULL;
1736
	    mcastinfo->ai = firstai;
1737
	    mcastinfo->hops = hopcount;
1738
1739
	    if (mcastlist == NULL) {
1740
		mcastlist = mcastinfo;
1741
	    } else {
1742
		for (mcl = mcastlist; mcl->next != NULL; mcl = mcl->next) {
1743
		    /* Do nothing  - just find end of list */
1744
		}
1745
		mcl->next = mcastinfo;
1746
	    }
1747
	}
1748
    } else {
1749
	ErrorF("Xserver: %s: %s\n", gai_strerror(gaierr), address);
1750
	exit(1);
1751
    }    
1752
    return i;
1416
}
1753
}
1754
#endif
1417
1755
1418
#else
1756
#else
1419
static int xdmcp_non_empty; /* avoid complaint by ranlib */
1757
static int xdmcp_non_empty; /* avoid complaint by ranlib */
(-)4.3.0/xc/programs/fslsfonts/fslsfonts.c (-1 / +1 lines)
Lines 1-4 Link Here
1
/* $Xorg: fslsfonts.c,v 1.4 2001/02/09 02:05:30 xorgcvs Exp $ */
1
/* $Id$ */
2
/*
2
/*
3
 
3
 
4
Copyright 1990, 1998  The Open Group
4
Copyright 1990, 1998  The Open Group
(-)4.3.0/xc/programs/fstobdf/fstobdf.c (-3 / +8 lines)
Lines 1-4 Link Here
1
/* $Xorg: fstobdf.c,v 1.4 2001/02/09 02:05:30 xorgcvs Exp $ */
1
/* $Id$ */
2
/*
2
/*
3
 
3
 
4
Copyright 1990, 1998  The Open Group
4
Copyright 1990, 1998  The Open Group
Lines 104-111 Link Here
104
104
105
    fontServer = FSOpenServer(serverName);
105
    fontServer = FSOpenServer(serverName);
106
    if (!fontServer) {
106
    if (!fontServer) {
107
	fprintf(stderr, "can't open font server \"%s\"\n",
107
	char *sn = FSServerName(serverName);
108
		FSServerName(serverName));
108
	if (sn)
109
	    fprintf(stderr, "%s: can't open font server \"%s\"\n",
110
	      	    argv[0], sn);
111
	else
112
	    fprintf(stderr, "%s:  No font server specified.\n",
113
		    argv[0]);
109
	exit(0);
114
	exit(0);
110
    }
115
    }
111
    bitmapFormat = 0;
116
    bitmapFormat = 0;
(-)4.3.0/xc/programs/lbxproxy/di/Imakefile (+5 lines)
Lines 39-45 Link Here
39
LintLibraryTarget(dilbx,$(SRCS))
39
LintLibraryTarget(dilbx,$(SRCS))
40
NormalLintTarget($(SRCS))
40
NormalLintTarget($(SRCS))
41
41
42
#ifdef IPv6Flags
43
    IPv6_FLAGS = IPv6Flags
44
#endif
45
42
SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(EXT_DEFINES))
46
SpecialCObjectRule(dispatch,$(ICONFIGFILES),$(EXT_DEFINES))
43
SpecialCObjectRule(utils,$(ICONFIGFILES),$(UTIL_DEFINES))
47
SpecialCObjectRule(utils,$(ICONFIGFILES),$(UTIL_DEFINES))
48
SpecialCObjectRule(pm,$(ICONFIGFILES),$(IPv6_FLAGS))
44
49
45
DependTarget()
50
DependTarget()
(-)4.3.0/xc/programs/lbxproxy/di/pm.c (-6 / +38 lines)
Lines 1-5 Link Here
1
/* $Xorg: pm.c,v 1.5 2001/02/09 02:05:31 xorgcvs Exp $ */
1
/* $Xorg: pm.c,v 1.5 2001/02/09 02:05:31 xorgcvs Exp $ */
2
2
/* Updated for IPv6 */
3
/*
3
/*
4
Copyright 1996, 1998  The Open Group
4
Copyright 1996, 1998  The Open Group
5
5
Lines 374-395 Link Here
374
	 * If gethostbyname fails, try to connect anyhow because
374
	 * If gethostbyname fails, try to connect anyhow because
375
	 * the display name could be something like :0, local:0
375
	 * the display name could be something like :0, local:0
376
	 * or unix:0.
376
	 * or unix:0.
377
	 *
378
	 * Search for last colon to allow IPv6 numeric addresses.
377
	 */
379
	 */
378
	colon = strchr (serverAddress, ':');
380
	colon = strrchr (serverAddress, ':');
379
	if (colon)
381
	if (colon)
380
	{
382
	{
383
#ifdef IPv6
384
	    struct addrinfo *ai, hints;
385
	    int res;
386
#else
381
	    struct hostent *hostent;
387
	    struct hostent *hostent;
388
#endif
389
	    char *canonhost = NULL;
390
	    char *hoststart = strchr(serverAddress, '/');
391
392
	    if (hoststart == NULL)
393
		hoststart = serverAddress;
394
395
	    /* DECnet :: addresses */
396
	    if (*(colon - 1) == ':') {
397
		colon--;
398
	    }
382
399
383
	    *colon = '\0';
400
	    *colon = '\0';
384
	    hostent = gethostbyname (serverAddress);
401
#ifdef IPv6
402
	    hints.ai_flags = AI_CANONNAME;
403
	    if (getaddrinfo(hoststart, NULL, &hints, &ai) == 0)
404
		canonhost = ai->ai_canonname;
405
	    else 
406
		ai = NULL;
407
#else
408
	    hostent = gethostbyname (hoststart);
409
	    if (hostent && hostent->h_name)
410
		canonhost = hostent->h_name;
411
#endif
385
	    *colon = ':';
412
	    *colon = ':';
386
413
387
	    if (hostent && hostent->h_name) {
414
388
		tmpAddress = (char *) malloc (strlen (hostent->h_name) + 
415
	    if (canonhost) {
416
		tmpAddress = (char *) malloc (strlen (canonhost) + 
389
					      strlen (colon) + 1);
417
					      strlen (colon) + 1);
390
		(void) sprintf (tmpAddress, "%s%s", hostent->h_name, colon);
418
		(void) sprintf (tmpAddress, "%s%s", canonhost, colon);
391
	        serverAddress = tmpAddress;
419
	        serverAddress = tmpAddress;
392
	    }
420
	    }
421
#ifdef IPv6
422
	    if (ai != NULL)
423
		freeaddrinfo(ai);
424
#endif
393
	}
425
	}
394
	display_name = serverAddress;
426
	display_name = serverAddress;
395
427
(-)4.3.0/xc/programs/proxymngr/Imakefile (-2 / +6 lines)
Lines 10-19 Link Here
10
         DEPLIBS = $(DEPXTOOLLIB) $(DEPXLIB)
10
         DEPLIBS = $(DEPXTOOLLIB) $(DEPXLIB)
11
 LOCAL_LIBRARIES = $(XTOOLLIB) $(XLIB)
11
 LOCAL_LIBRARIES = $(XTOOLLIB) $(XLIB)
12
12
13
#ifdef IPv6Flags
14
      IPv6_FLAGS = IPv6Flags
15
#endif
16
13
         HEADERS = PM.h PMproto.h
17
         HEADERS = PM.h PMproto.h
14
18
15
           SRCS1 = main.c pmdb.c config.c
19
           SRCS1 = main.c pmdb.c config.c
16
                   
20
17
           OBJS1 = main.o pmdb.o config.o
21
           OBJS1 = main.o pmdb.o config.o
18
22
19
        PROGRAMS = ProgramTargetName(proxymngr)
23
        PROGRAMS = ProgramTargetName(proxymngr)
Lines 32-37 Link Here
32
InstallMultipleFlags($(HEADERS),$(INCDIR)/X11/PM,$(INSTINCFLAGS))
36
InstallMultipleFlags($(HEADERS),$(INCDIR)/X11/PM,$(INSTINCFLAGS))
33
37
34
ComplexProgramTarget_1(proxymngr,$(LOCAL_LIBRARIES),NullParameter)
38
ComplexProgramTarget_1(proxymngr,$(LOCAL_LIBRARIES),NullParameter)
35
SpecialCObjectRule(main,$(_NOOP_),'-DCONFIG_FILE="'$(PROXYMANAGERDIR)'/pmconfig"')
39
SpecialCObjectRule(main,$(_NOOP_),'-DCONFIG_FILE="'$(PROXYMANAGERDIR)'/pmconfig"' $(IPv6_FLAGS))
36
40
37
InstallNonExecFile(pmconfig,$(PROXYMANAGERDIR))
41
InstallNonExecFile(pmconfig,$(PROXYMANAGERDIR))
(-)4.3.0/xc/programs/proxymngr/main.c (-5 / +31 lines)
Lines 483-499 Link Here
483
	     * different host than the client or the client host, 
483
	     * different host than the client or the client host, 
484
	     * proxy host and the server host may all be different, 
484
	     * proxy host and the server host may all be different, 
485
	     * thus a serverAddress of :0 or :0.0 is not useful.  
485
	     * thus a serverAddress of :0 or :0.0 is not useful.  
486
	     * Therefore, change serverAddrees to use the client's 
486
	     * Therefore, change serverAddress to use the client's 
487
	     * hostname.
487
	     * hostname.
488
	     */
488
	     */
489
	    char		*tmpName;
489
	    char		*tmpName;
490
490
491
	    tmpName = strchr (serverAddress, ':');
491
	    tmpName = strrchr (serverAddress, ':');
492
492
493
	    if (tmpName && ((serverAddress[0] == ':') || 
493
	    if (tmpName && ((tmpName == serverAddress) || 
494
			    (!strncmp (serverAddress, "unix:", 5))))
494
			    (!strncmp (serverAddress, "unix:", 5))))
495
	    {
495
	    {
496
#ifdef IPv6
497
		struct sockaddr_storage	serverSock;
498
#else
496
		struct sockaddr_in	serverSock;
499
		struct sockaddr_in	serverSock;
500
#endif
497
		int 			retVal;
501
		int 			retVal;
498
		int 			addrLen = sizeof(serverSock);
502
		int 			addrLen = sizeof(serverSock);
499
503
Lines 502-521 Link Here
502
				     (void *) &addrLen);
506
				     (void *) &addrLen);
503
		if (!retVal) 
507
		if (!retVal) 
504
		{
508
		{
509
		    char *canonname = NULL;
510
#ifdef IPv6
511
		    char hostname[NI_MAXHOST];
512
		    struct addrinfo *ai = NULL, hints;
513
514
		    if (getnameinfo((struct sockaddr *) &serverSock,
515
		      addrLen, hostname, sizeof(hostname), NULL, 0, 0) == 0) {
516
			hints.ai_flags = AI_CANONNAME;
517
			if (getaddrinfo(hostname, NULL, &hints, &ai) == 0) {
518
			    canonname = ai->ai_canonname;
519
			} else {
520
			    ai = NULL;
521
			}
522
		    }
523
#else
505
		    struct hostent *hostent;
524
		    struct hostent *hostent;
506
525
507
		    hostent = gethostbyname (inet_ntoa(serverSock.sin_addr));
526
		    hostent = gethostbyname (inet_ntoa(serverSock.sin_addr));
508
527
509
		    if (hostent && hostent->h_name) 
528
		    if (hostent && hostent->h_name) 
529
			canonname = hostent->h_name;
530
#endif
531
		    if (canonname)
510
		    {
532
		    {
511
			int		len;
533
			int		len;
512
			char		* pch = strdup (tmpName);
534
			char		* pch = strdup (tmpName);
513
535
514
			len = strlen(hostent->h_name) + strlen(tmpName) + 1;
536
			len = strlen(canonname) + strlen(tmpName) + 1;
515
			serverAddress = (char *) realloc (serverAddress, len);
537
			serverAddress = (char *) realloc (serverAddress, len);
516
			sprintf (serverAddress, "%s%s", hostent->h_name, pch);
538
			sprintf (serverAddress, "%s%s", canonname, pch);
517
			free (pch);
539
			free (pch);
518
		    }
540
		    }
541
#ifdef IPv6
542
		    if (ai != NULL)
543
			freeaddrinfo(ai);
544
#endif		    
519
		}
545
		}
520
	    }
546
	    }
521
	}
547
	}
(-)4.3.0/xc/programs/xauth/Imakefile (-1 / +1 lines)
Lines 14-18 Link Here
14
ComplexProgramTarget(xauth)
14
ComplexProgramTarget(xauth)
15
15
16
SpecialCObjectRule(gethost,$(ICONFIGFILES),$(CONN_DEFINES) $(SIGNAL_DEFINES))
16
SpecialCObjectRule(gethost,$(ICONFIGFILES),$(CONN_DEFINES) $(SIGNAL_DEFINES))
17
SpecialCObjectRule(process,$(ICONFIGFILES),$(SIGNAL_DEFINES))
17
SpecialCObjectRule(process,$(ICONFIGFILES),$(CONN_DEFINES) $(SIGNAL_DEFINES))
18
SpecialCObjectRule(parsedpy,$(ICONFIGFILES),$(CONN_DEFINES))
18
SpecialCObjectRule(parsedpy,$(ICONFIGFILES),$(CONN_DEFINES))
(-)4.3.0/xc/programs/xauth/gethost.c (-11 / +63 lines)
Lines 1-6 Link Here
1
/*
1
/*
2
 * $Xorg: gethost.c,v 1.5 2001/02/09 02:05:38 xorgcvs Exp $
2
 * $Xorg: gethost.c,v 1.5 2001/02/09 02:05:38 xorgcvs Exp $
3
 *
3
 * Updated for IPv6
4
 * 
4
 * 
5
Copyright 1989, 1998  The Open Group
5
Copyright 1989, 1998  The Open Group
6
6
Lines 59-67 Link Here
59
#include <arpa/inet.h>
59
#include <arpa/inet.h>
60
#ifdef SYSV
60
#ifdef SYSV
61
#ifdef i386
61
#ifdef i386
62
#ifndef sco
62
#if !defined(sco) && !defined(sun)
63
#include <net/errno.h>
63
#include <net/errno.h>
64
#endif /* !sco */
64
#endif /* !sco && !sun */
65
#endif /* i386 */
65
#endif /* i386 */
66
#endif /* SYSV */
66
#endif /* SYSV */
67
#endif /* !STREAMSCONN */
67
#endif /* !STREAMSCONN */
Lines 74-81 Link Here
74
#include <netdnet/dnetdb.h>
74
#include <netdnet/dnetdb.h>
75
#endif
75
#endif
76
76
77
#ifndef WIN32
78
#include <arpa/inet.h>
79
#endif
80
77
#ifdef SIGALRM
81
#ifdef SIGALRM
78
Bool nameserver_timedout = False;
82
volatile Bool nameserver_timedout = False;
79
83
80
84
81
/*
85
/*
Lines 107-112 Link Here
107
    Xauth *auth;
111
    Xauth *auth;
108
{
112
{
109
    static struct hostent *hp = NULL;
113
    static struct hostent *hp = NULL;
114
    int af;
115
#ifdef IPv6
116
    static char addr[INET6_ADDRSTRLEN];
117
#endif /* IPv6 */
110
#ifdef DNETCONN
118
#ifdef DNETCONN
111
    struct nodeent *np;
119
    struct nodeent *np;
112
    static char nodeaddr[4 + 2 * DN_MAXADDL];
120
    static char nodeaddr[4 + 2 * DN_MAXADDL];
Lines 115-121 Link Here
115
    if (auth->address_length == 0)
123
    if (auth->address_length == 0)
116
	return "Illegal Address";
124
	return "Illegal Address";
117
#ifdef TCPCONN
125
#ifdef TCPCONN
118
    if (auth->family == FamilyInternet) {
126
    if (auth->family == FamilyInternet
127
#ifdef IPv6
128
      || auth->family == FamilyInternetV6
129
#endif 
130
	)
131
    {
132
#ifdef IPv6
133
	if (auth->family == FamilyInternetV6)
134
	    af = AF_INET6;
135
	else
136
#endif
137
	    af = AF_INET;
119
#ifdef SIGALRM
138
#ifdef SIGALRM
120
	/* gethostbyaddr can take a LONG time if the host does not exist.
139
	/* gethostbyaddr can take a LONG time if the host does not exist.
121
	   Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
140
	   Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
Lines 128-142 Link Here
128
	alarm (4);
147
	alarm (4);
129
	if (setjmp(env) == 0) {
148
	if (setjmp(env) == 0) {
130
#endif
149
#endif
131
	    hp = gethostbyaddr (auth->address, auth->address_length, AF_INET);
150
	    hp = gethostbyaddr (auth->address, auth->address_length, af);
132
#ifdef SIGALRM
151
#ifdef SIGALRM
133
	}
152
	}
134
	alarm (0);
153
	alarm (0);
135
#endif
154
#endif
136
	if (hp)
155
	if (hp)
137
	  return (hp->h_name);
156
	  return (hp->h_name);
138
	else
157
	else {
158
#ifdef IPv6
159
	  inet_ntop(af, auth->address, addr, sizeof(addr));
160
          return addr;
161
#else
139
	  return (inet_ntoa(*((struct in_addr *)(auth->address))));
162
	  return (inet_ntoa(*((struct in_addr *)(auth->address))));
163
#endif
164
	}
140
    }
165
    }
141
#endif
166
#endif
142
#ifdef DNETCONN
167
#ifdef DNETCONN
Lines 155-161 Link Here
155
    return (NULL);
180
    return (NULL);
156
}
181
}
157
182
158
#ifdef TCPCONN
183
#if defined(TCPCONN) && !defined(IPv6)
159
/*
184
/*
160
 * cribbed from lib/X/XConnDis.c
185
 * cribbed from lib/X/XConnDis.c
161
 */
186
 */
Lines 212-218 Link Here
212
#endif
237
#endif
213
238
214
char *get_address_info (family, fulldpyname, prefix, host, lenp)
239
char *get_address_info (family, fulldpyname, prefix, host, lenp)
215
    int family;
240
    int *family;
216
    char *fulldpyname;
241
    char *fulldpyname;
217
    int prefix;
242
    int prefix;
218
    char *host;
243
    char *host;
Lines 220-229 Link Here
220
{
245
{
221
    char *retval = NULL;
246
    char *retval = NULL;
222
    int len = 0;
247
    int len = 0;
223
    char *src = NULL;
248
    void *src = NULL;
224
#ifdef TCPCONN
249
#ifdef TCPCONN
250
#ifdef IPv6
251
    struct addrinfo *firstai = NULL;
252
    struct addrinfo *ai = NULL;
253
#else
225
    unsigned int hostinetaddr;
254
    unsigned int hostinetaddr;
226
#endif
255
#endif
256
#endif
227
#ifdef DNETCONN
257
#ifdef DNETCONN
228
    struct dn_naddr dnaddr;
258
    struct dn_naddr dnaddr;
229
#endif
259
#endif
Lines 233-239 Link Here
233
     * based on the family, set the pointer src to the start of the address
263
     * based on the family, set the pointer src to the start of the address
234
     * information to be copied and set len to the number of bytes.
264
     * information to be copied and set len to the number of bytes.
235
     */
265
     */
236
    switch (family) {
266
    switch (*family) {
237
      case FamilyLocal:			/* hostname/unix:0 */
267
      case FamilyLocal:			/* hostname/unix:0 */
238
					/* handle unix:0 and :0 specially */
268
					/* handle unix:0 and :0 specially */
239
	if (prefix == 0 && (strncmp (fulldpyname, "unix:", 5) == 0 ||
269
	if (prefix == 0 && (strncmp (fulldpyname, "unix:", 5) == 0 ||
Lines 252-260 Link Here
252
	break;
282
	break;
253
      case FamilyInternet:		/* host:0 */
283
      case FamilyInternet:		/* host:0 */
254
#ifdef TCPCONN
284
#ifdef TCPCONN
285
#ifdef IPv6
286
      case FamilyInternetV6:
287
        if (getaddrinfo(host,NULL,NULL,&firstai) !=0) return NULL;
288
	for (ai = firstai; ai != NULL && src == NULL ; ai = ai->ai_next) {
289
	    if (ai->ai_family == AF_INET) {
290
		struct sockaddr_in *sin = (struct sockaddr_in *)ai->ai_addr;
291
		src = &(sin->sin_addr);
292
		len = sizeof(sin->sin_addr);
293
		*family = FamilyInternet;
294
	    } else if (ai->ai_family == AF_INET6) {
295
		struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ai->ai_addr;
296
		src = &(sin6->sin6_addr);
297
		len = sizeof(sin6->sin6_addr);
298
		*family = FamilyInternetV6;
299
	    }
300
	}
301
#else
255
	if (!get_inet_address (host, &hostinetaddr)) return NULL;
302
	if (!get_inet_address (host, &hostinetaddr)) return NULL;
256
	src = (char *) &hostinetaddr;
303
	src = (char *) &hostinetaddr;
257
	len = 4; /* sizeof inaddr.sin_addr, would fail on Cray */
304
	len = 4; /* sizeof inaddr.sin_addr, would fail on Cray */
305
#endif /* IPv6 */
258
	break;
306
	break;
259
#else
307
#else
260
	return NULL;
308
	return NULL;
Lines 283-287 Link Here
283
	memmove( retval, src, len);
331
	memmove( retval, src, len);
284
	*lenp = len;
332
	*lenp = len;
285
    }
333
    }
334
#ifdef IPv6
335
    if (firstai != NULL)
336
	freeaddrinfo(firstai);
337
#endif
286
    return retval;
338
    return retval;
287
}
339
}
(-)4.3.0/xc/programs/xauth/parsedpy.c (-3 / +4 lines)
Lines 1-5 Link Here
1
/*
1
/*
2
 * $Xorg: parsedpy.c,v 1.4 2001/02/09 02:05:38 xorgcvs Exp $
2
 * $Xorg: parsedpy.c,v 1.4 2001/02/09 02:05:38 xorgcvs Exp $
3
 * Updated for IPv6
3
 *
4
 *
4
 * parse_displayname - utility routine for splitting up display name strings
5
 * parse_displayname - utility routine for splitting up display name strings
5
 *
6
 *
Lines 111-120 Link Here
111
    if (!displayname || !displayname[0]) return False;
112
    if (!displayname || !displayname[0]) return False;
112
113
113
					/* must have at least :number */
114
					/* must have at least :number */
114
    ptr = strchr(displayname, ':');
115
    ptr = strrchr(displayname, ':');
115
    if (!ptr || !ptr[1]) return False;
116
    if (!ptr || !ptr[1]) return False;
116
    if (ptr[1] == ':') {
117
    if ((ptr != displayname) && (*(ptr - 1) == ':')) {
117
	if (ptr[2] == '\0') return False;
118
	ptr--;
118
	dnet = True;
119
	dnet = True;
119
    }
120
    }
120
121
(-)4.3.0/xc/programs/xauth/process.c (-2 / +6 lines)
Lines 1-4 Link Here
1
/* $Xorg: process.c,v 1.6 2001/02/09 02:05:38 xorgcvs Exp $ */
1
/* $Xorg: process.c,v 1.6 2001/02/09 02:05:38 xorgcvs Exp $ */
2
/* Updated for IPv6 */
2
/*
3
/*
3
4
4
Copyright 1989, 1998  The Open Group
5
Copyright 1989, 1998  The Open Group
Lines 485-492 Link Here
485
	return False;
486
	return False;
486
    }
487
    }
487
488
489
    proto.address = get_address_info(&family, displayname, prelen, host, &len);
488
    proto.family = family;
490
    proto.family = family;
489
    proto.address = get_address_info (family, displayname, prelen, host, &len);
490
    if (proto.address) {
491
    if (proto.address) {
491
	char buf[40];			/* want to hold largest display num */
492
	char buf[40];			/* want to hold largest display num */
492
493
Lines 606-612 Link Here
606
static Bool xauth_allowed = True;	/* if allowed to write auth file */
607
static Bool xauth_allowed = True;	/* if allowed to write auth file */
607
static Bool xauth_locked = False;     /* if has been locked */
608
static Bool xauth_locked = False;     /* if has been locked */
608
static char *xauth_filename = NULL;
609
static char *xauth_filename = NULL;
609
static Bool dieing = False;
610
static volatile Bool dieing = False;
610
611
611
#ifdef SIGNALRETURNSINT
612
#ifdef SIGNALRETURNSINT
612
#define _signal_t int
613
#define _signal_t int
Lines 975-980 Link Here
975
	    fprintf (fp, "/unix");
976
	    fprintf (fp, "/unix");
976
	    break;
977
	    break;
977
	  case FamilyInternet:
978
	  case FamilyInternet:
979
#ifdef IPv6
980
	  case FamilyInternetV6:
981
#endif
978
	  case FamilyDECnet:
982
	  case FamilyDECnet:
979
	    dpyname = get_hostname (auth);
983
	    dpyname = get_hostname (auth);
980
	    if (dpyname) {
984
	    if (dpyname) {
(-)4.3.0/xc/programs/xauth/xauth.h (-1 / +1 lines)
Lines 44-50 Link Here
44
#include <stdlib.h>
44
#include <stdlib.h>
45
45
46
extern char *get_hostname ( Xauth *auth );
46
extern char *get_hostname ( Xauth *auth );
47
extern char *get_address_info ( int family, char *fulldpyname, int prefix, char *host, int *lenp );
47
extern char *get_address_info ( int *family, char *fulldpyname, int prefix, char *host, int *lenp );
48
extern char *copystring ( char *src, int len );
48
extern char *copystring ( char *src, int len );
49
extern char *get_local_hostname ( char *buf, int maxlen );
49
extern char *get_local_hostname ( char *buf, int maxlen );
50
extern Bool parse_displayname ( char *displayname, int *familyp, char **hostp, int *dpynump, int *scrnump, char **restp );
50
extern Bool parse_displayname ( char *displayname, int *familyp, char **hostp, int *dpynump, int *scrnump, char **restp );
(-)4.3.0/xc/programs/xdm/Imakefile (-10 / +38 lines)
Lines 1-9 Link Here
1
XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:54:14 cpqbld Exp $
1
XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:54:14 cpqbld Exp $
2
XCOMM Updated for IPv6
2
3
3
4
4
5
5
6
XCOMM $Id$
6
XCOMM $XFree86: xc/programs/xdm/Imakefile,v 3.52 2002/12/07 20:31:04 herrb Exp $
7
7
8
#define IHaveSubdirs
8
#define IHaveSubdirs
9
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
9
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
Lines 43-48 Link Here
43
KRBIVLIB = KrbIVLibraries
43
KRBIVLIB = KrbIVLibraries
44
#endif
44
#endif
45
45
46
#if HasKrbIV
47
KRBIV_DEFINES = KrbIVDefines
48
KRBIV_INCLUDES = KrbIVIncludes
49
KRBIVLIB = KrbIVLibraries
50
#endif
51
46
#if HasKrb5
52
#if HasKrb5
47
KRB5_DEFINES = Krb5Defines
53
KRB5_DEFINES = Krb5Defines
48
KRB5_INCLUDE = Krb5Includes
54
KRB5_INCLUDE = Krb5Includes
Lines 131-144 Link Here
131
FRAGILE_DEFINES = -DFRAGILE_DEV_MEM
137
FRAGILE_DEFINES = -DFRAGILE_DEV_MEM
132
#endif
138
#endif
133
139
134
#if defined(NetBSDArchitecture) && \
140
#ifdef RandomDefines
135
    ((OSMajorVersion > 1) || \
141
RANDOM_DEFINES = RandomDefines
136
     (OSMajorVersion == 1 && OSMinorVersion > 3))
142
#else
137
RANDOM_DEFINES = -DDEV_RANDOM=\"/dev/urandom\"
138
#endif
139
140
#ifdef OpenBSDArchitecture
143
#ifdef OpenBSDArchitecture
141
RANDOM_DEFINES = -DARC4_RANDOM
144
RANDOM_DEFINES = -DARC4_RANDOM
145
#else
146
/* Replaced with equivalent RandomDefines in NetBSD.cf
147
 * #if defined(NetBSDArchitecture) && \
148
 *   ((OSMajorVersion > 1) || \
149
 *    (OSMajorVersion == 1 && OSMinorVersion > 3))
150
 * RANDOM_DEFINES = -DDEV_RANDOM=\"/dev/urandom\"
151
 * #endif
152
 */
153
#endif
142
#endif
154
#endif
143
155
144
#if HasVFork
156
#if HasVFork
Lines 164-169 Link Here
164
SNPRINTFOBJS = snprintf.o
176
SNPRINTFOBJS = snprintf.o
165
#endif
177
#endif
166
178
179
#ifdef HasSunC
180
#if HasSunC
181
XCOMM auth.c & chooser.c must be compiled with -Xa (ANSI compatible) instead
182
XCOMM of -Xc (strict ANSI compliance) in order to access the definition for
183
XCOMM struct lifreq, which uses "long long" type variables.
184
LIFREQ_FLAGS = -Xa
185
#endif
186
#endif
187
167
  SYS_LIBRARIES = $(SYS_LIBRARIES1) $(SYS_LIBRARIES2) $(SYS_LIBRARIES3)
188
  SYS_LIBRARIES = $(SYS_LIBRARIES1) $(SYS_LIBRARIES2) $(SYS_LIBRARIES3)
168
189
169
   XDMCONFIGDIR = XdmConfigurationSubdirectory
190
   XDMCONFIGDIR = XdmConfigurationSubdirectory
Lines 235-240 Link Here
235
		-DOSMINORVERSION=$(OSMINORVERSION) \
256
		-DOSMINORVERSION=$(OSMINORVERSION) \
236
		$(XKB_CLIENT_DEFINES) $(USER_CONTEXT_DEFINES) \
257
		$(XKB_CLIENT_DEFINES) $(USER_CONTEXT_DEFINES) \
237
		$(XPM_DEFINES) $(XINERAMA_DEFINES) $(PROCTITLE_DEFINES)
258
		$(XPM_DEFINES) $(XINERAMA_DEFINES) $(PROCTITLE_DEFINES)
259
   EXTRAMANDEFS = $(RANDOM_DEFINES)
238
260
239
XCOMM
261
XCOMM
240
XCOMM Special definitions for compiling default resources; these parameters
262
XCOMM Special definitions for compiling default resources; these parameters
Lines 261-270 Link Here
261
		  '-DDEF_GREETER_LIB="$(XDMDIR)/libXdmGreet.so"'
283
		  '-DDEF_GREETER_LIB="$(XDMDIR)/libXdmGreet.so"'
262
284
263
ComplexProgramTarget_1(xdm,$(LOCAL_LIBRARIES),NullParameter)
285
ComplexProgramTarget_1(xdm,$(LOCAL_LIBRARIES),NullParameter)
286
#ifdef LinkConfDirectory
264
LinkConfDirectory(xdm,.,xdm,.)
287
LinkConfDirectory(xdm,.,xdm,.)
265
#ifdef VarDbDirectory
288
#ifdef VarDbDirectory
266
LinkConfDirectoryLong(xdm,xdm,authdir,authdir,$(CONFDIR),$(VARDBDIR))
289
LinkConfDirectoryLong(xdm,xdm,authdir,authdir,$(CONFDIR),$(VARDBDIR))
267
#endif
290
#endif
291
#else
292
#ifdef VarDirectory
293
LinkVarDirectory(xdm,.,xdm,.)
294
#endif
295
#endif
268
NormalProgramTarget(xdmshell,$(OBJS2),NullParameter,NullParameter,NullParameter)
296
NormalProgramTarget(xdmshell,$(OBJS2),NullParameter,NullParameter,NullParameter)
269
NormalProgramTarget(sessreg,$(OBJS4),NullParameter,NullParameter,NullParameter)
297
NormalProgramTarget(sessreg,$(OBJS4),NullParameter,NullParameter,NullParameter)
270
InstallProgram(sessreg,$(BINDIR))
298
InstallProgram(sessreg,$(BINDIR))
Lines 275-281 Link Here
275
#endif
303
#endif
276
304
277
#if BuildChooser
305
#if BuildChooser
278
SpecialCObjectRule(chooser, $(ICONFIGFILES), $(SOCK_DEFINES))
306
SpecialCObjectRule(chooser, $(ICONFIGFILES), $(SOCK_DEFINES) $(LIFREQ_FLAGS))
279
NormalProgramTarget(chooser,$(OBJS3),$(DEPLIBS3),$(LIBS3),NullParameter)
307
NormalProgramTarget(chooser,$(OBJS3),$(DEPLIBS3),$(LIBS3),NullParameter)
280
InstallProgram(chooser,$(XDMDIR))
308
InstallProgram(chooser,$(XDMDIR))
281
InstallAppDefaults(Chooser)
309
InstallAppDefaults(Chooser)
Lines 285-291 Link Here
285
InstallProgram(xdm-shadow,$(BINDIR))
313
InstallProgram(xdm-shadow,$(BINDIR))
286
#endif
314
#endif
287
315
288
SpecialCObjectRule(auth,$(ICONFIGFILES),$(SOCK_DEFINES))
316
SpecialCObjectRule(auth,$(ICONFIGFILES),$(SOCK_DEFINES) $(LIFREQ_FLAGS))
289
SpecialCObjectRule(policy,$(ICONFIGFILES),$(_NOOP_))
317
SpecialCObjectRule(policy,$(ICONFIGFILES),$(_NOOP_))
290
SpecialCObjectRule(resource,$(ICONFIGFILES),$(RES_DEFINES))
318
SpecialCObjectRule(resource,$(ICONFIGFILES),$(RES_DEFINES))
291
SpecialCObjectRule(socket,$(ICONFIGFILES),$(SOCK_DEFINES))
319
SpecialCObjectRule(socket,$(ICONFIGFILES),$(SOCK_DEFINES))
(-)4.3.0/xc/programs/xdm/access.c (-12 / +164 lines)
Lines 2-7 Link Here
2
 * $Xorg: access.c,v 1.5 2001/02/09 02:05:40 xorgcvs Exp $
2
 * $Xorg: access.c,v 1.5 2001/02/09 02:05:40 xorgcvs Exp $
3
 *
3
 *
4
Copyright 1990, 1998  The Open Group
4
Copyright 1990, 1998  The Open Group
5
Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
5
6
6
Permission to use, copy, modify, distribute, and sell this software and its
7
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
documentation for any purpose is hereby granted without fee, provided that
Lines 19-27 Link Here
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
22
Except as contained in this notice, the name of The Open Group shall not be
23
Except as contained in this notice, the name of a copyright holder shall not be
23
used in advertising or otherwise to promote the sale, use or other dealings
24
used in advertising or otherwise to promote the sale, use or other dealings
24
in this Software without prior written authorization from The Open Group.
25
in this Software without prior written authorization from the copyright holder.
25
 *
26
 *
26
 * Author:  Keith Packard, MIT X Consortium
27
 * Author:  Keith Packard, MIT X Consortium
27
 */
28
 */
Lines 53-64 Link Here
53
#define CHOOSER_STRING	    "CHOOSER"
54
#define CHOOSER_STRING	    "CHOOSER"
54
#define BROADCAST_STRING    "BROADCAST"
55
#define BROADCAST_STRING    "BROADCAST"
55
#define NOBROADCAST_STRING  "NOBROADCAST"
56
#define NOBROADCAST_STRING  "NOBROADCAST"
57
#define LISTEN_STRING	    "LISTEN"
58
#define WILDCARD_STRING	    "*"
56
59
57
#define HOST_ALIAS	    0
60
#define HOST_ALIAS	    0
58
#define HOST_ADDRESS	    1
61
#define HOST_ADDRESS	    1
59
#define HOST_BROADCAST	    2
62
#define HOST_BROADCAST	    2
60
#define HOST_CHOOSER	    3
63
#define HOST_CHOOSER	    3
61
#define HOST_NOBROADCAST    4
64
#define HOST_NOBROADCAST    4
65
#define HOST_ANYADDR	    5
62
66
63
typedef struct _hostEntry {
67
typedef struct _hostEntry {
64
    struct _hostEntry	*next;
68
    struct _hostEntry	*next;
Lines 67-77 Link Here
67
	char	*aliasName;
71
	char	*aliasName;
68
	ARRAY8	hostAddress;
72
	ARRAY8	hostAddress;
69
    } entry;
73
    } entry;
74
    int			hopCount;
70
} HostEntry;
75
} HostEntry;
71
76
72
#define DISPLAY_ALIAS	    0
77
#define DISPLAY_ALIAS	    0
73
#define DISPLAY_PATTERN	    1
78
#define DISPLAY_PATTERN	    1
74
#define DISPLAY_ADDRESS	    2
79
#define DISPLAY_ADDRESS	    2
80
#define DISPLAY_LISTEN	    3
75
81
76
typedef struct _displayEntry {
82
typedef struct _displayEntry {
77
    struct _displayEntry    *next;
83
    struct _displayEntry    *next;
Lines 101-111 Link Here
101
    
107
    
102
    if (!haveLocalAddress)
108
    if (!haveLocalAddress)
103
    {
109
    {
110
#ifdef IPv6
111
	struct addrinfo *ai;
112
113
	if (getaddrinfo(localHostname(), NULL, NULL, &ai) != 0) {
114
	    XdmcpAllocARRAY8 (&localAddress, 4);
115
	    localAddress.data[0] = 127;
116
	    localAddress.data[1] = 0;
117
	    localAddress.data[2] = 0;
118
	    localAddress.data[3] = 1;
119
	} else {
120
	    XdmcpAllocARRAY8 (&localAddress, 4);
121
	    if (ai->ai_addr->sa_family == AF_INET) {
122
		XdmcpAllocARRAY8 (&localAddress, sizeof(struct in_addr));
123
		memcpy(localAddress.data, 
124
		  &((struct sockaddr_in *)ai->ai_addr)->sin_addr,
125
		  sizeof(struct in_addr));
126
	    } else if (ai->ai_addr->sa_family == AF_INET6) {
127
		XdmcpAllocARRAY8 (&localAddress, sizeof(struct in6_addr));
128
		memcpy(localAddress.data, 
129
		  &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr,
130
		  sizeof(struct in6_addr));
131
	    }	      
132
	    freeaddrinfo(ai);
133
	}
134
#else
104
	struct hostent	*hostent;
135
	struct hostent	*hostent;
105
136
106
	hostent = gethostbyname (localHostname());
137
	hostent = gethostbyname (localHostname());
107
	XdmcpAllocARRAY8 (&localAddress, hostent->h_length);
138
	XdmcpAllocARRAY8 (&localAddress, hostent->h_length);
108
	memmove( localAddress.data, hostent->h_addr, hostent->h_length);
139
	memmove( localAddress.data, hostent->h_addr, hostent->h_length);
140
#endif
141
109
    }
142
    }
110
    return &localAddress;
143
    return &localAddress;
111
}
144
}
Lines 140-145 Link Here
140
    case DISPLAY_ADDRESS:
173
    case DISPLAY_ADDRESS:
141
	XdmcpDisposeARRAY8 (&d->entry.displayAddress.clientAddress);
174
	XdmcpDisposeARRAY8 (&d->entry.displayAddress.clientAddress);
142
	break;
175
	break;
176
    case DISPLAY_LISTEN:
177
	/* do nothing - this case doesn't use the d->entry union */
178
	break;
143
    }
179
    }
144
    for (h = d->hosts; h; h = next) {
180
    for (h = d->hosts; h; h = next) {
145
	next = h->next;
181
	next = h->next;
Lines 217-223 Link Here
217
		continue;
253
		continue;
218
	    }
254
	    }
219
	default:
255
	default:
220
	    *wordp++ = c;
256
	    if (wordp < &(wordBuffer[WORD_LEN]))
257
	      *wordp++ = c;
221
	    break;
258
	    break;
222
	}
259
	}
223
	quoted = FALSE;
260
	quoted = FALSE;
Lines 230-242 Link Here
230
{
267
{
231
    char	    *hostOrAlias;
268
    char	    *hostOrAlias;
232
    HostEntry	    *h;
269
    HostEntry	    *h;
233
    struct hostent  *hostent;
234
270
235
tryagain:
271
tryagain:
236
    hostOrAlias = ReadWord (file, TRUE);
272
    hostOrAlias = ReadWord (file, TRUE);
237
    if (!hostOrAlias)
273
    if (!hostOrAlias)
238
	return NULL;
274
	return NULL;
239
    h = (HostEntry *) malloc (sizeof (DisplayEntry));
275
    h = (HostEntry *) malloc (sizeof (DisplayEntry));
276
    h->hopCount = 1;
240
    if (*hostOrAlias == ALIAS_CHARACTER)
277
    if (*hostOrAlias == ALIAS_CHARACTER)
241
    {
278
    {
242
	h->type = HOST_ALIAS;
279
	h->type = HOST_ALIAS;
Lines 259-282 Link Here
259
    {
296
    {
260
	h->type = HOST_NOBROADCAST;
297
	h->type = HOST_NOBROADCAST;
261
    }
298
    }
299
    else if (!strcmp (hostOrAlias, WILDCARD_STRING))
300
    {
301
	h->type = HOST_ANYADDR;
302
	h->entry.hostAddress.length = 0;
303
    }
262
    else
304
    else
263
    {
305
    {
306
	void *addr=NULL;
307
	size_t addr_length=0;
308
#ifdef IPv6
309
	struct addrinfo *ai;
310
#else
311
	struct hostent  *hostent = gethostbyname (hostOrAlias);
312
#endif	
313
	char *hops = strrchr(hostOrAlias, '/');
314
315
	if (hops) {
316
	    *(hops++) = '\0';
317
	    h->hopCount = strtol(hops, NULL, 10);
318
	    if (h->hopCount < 1)
319
		h->hopCount = 1;
320
	}
321
322
#ifdef IPv6
323
	if (getaddrinfo(hostOrAlias, NULL, NULL, &ai) == 0) {
324
	    if (ai->ai_addr->sa_family == AF_INET) {
325
		addr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr;
326
		addr_length = sizeof(struct in_addr);
327
	    } else if (ai->ai_addr->sa_family == AF_INET6) {
328
		addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr;
329
		addr_length = sizeof(struct in6_addr);
330
	    }	      
331
	}
332
#else
333
	if (hostent) {
334
	    addr = &(hostent->h_addr);
335
	    addr_length = hostent->h_length;
336
	}
337
#endif
264
	h->type = HOST_ADDRESS;
338
	h->type = HOST_ADDRESS;
265
	hostent = gethostbyname (hostOrAlias);
339
266
	if (!hostent)
340
	if (!addr)
267
	{
341
	{
268
	    Debug ("No such host %s\n", hostOrAlias);
342
	    Debug ("No such host %s\n", hostOrAlias);
269
	    LogError ("Access file \"%s\", host \"%s\" not found\n", accessFile, hostOrAlias);
343
	    LogError ("Access file \"%s\", host \"%s\" not found\n", accessFile, hostOrAlias);
270
	    free ((char *) h);
344
	    free ((char *) h);
271
	    goto tryagain;
345
	    goto tryagain;
272
	}
346
	}
273
	if (!XdmcpAllocARRAY8 (&h->entry.hostAddress, hostent->h_length))
347
	if (!XdmcpAllocARRAY8 (&h->entry.hostAddress, addr_length))
274
	{
348
	{
275
	    LogOutOfMem ("ReadHostEntry\n");
349
	    LogOutOfMem ("ReadHostEntry\n");
276
	    free ((char *) h);
350
	    free ((char *) h);
277
	    return NULL;
351
	    return NULL;
278
	}
352
	}
279
	memmove( h->entry.hostAddress.data, hostent->h_addr, hostent->h_length);
353
	memmove( h->entry.hostAddress.data, addr, addr_length);
354
#ifdef IPv6
355
	freeaddrinfo(ai);
356
#endif
280
    }
357
    }
281
    return h;
358
    return h;
282
}
359
}
Lines 301-307 Link Here
301
    DisplayEntry    *d;
378
    DisplayEntry    *d;
302
    struct _display *display;
379
    struct _display *display;
303
    HostEntry	    *h, **prev;
380
    HostEntry	    *h, **prev;
304
    struct hostent  *hostent;
305
    
381
    
306
    displayOrAlias = ReadWord (file, FALSE);
382
    displayOrAlias = ReadWord (file, FALSE);
307
    if (!displayOrAlias)
383
    if (!displayOrAlias)
Lines 321-326 Link Here
321
	}
397
	}
322
	strcpy (d->entry.aliasName, displayOrAlias);
398
	strcpy (d->entry.aliasName, displayOrAlias);
323
    }
399
    }
400
    else if (!strcmp(displayOrAlias, LISTEN_STRING)) 
401
    {
402
	d->type = DISPLAY_LISTEN;
403
    }
324
    else
404
    else
325
    {
405
    {
326
	if (*displayOrAlias == NEGATE_CHARACTER)
406
	if (*displayOrAlias == NEGATE_CHARACTER)
Lines 341-361 Link Here
341
    	}
421
    	}
342
    	else
422
    	else
343
    	{
423
    	{
424
	    void *addr = NULL;
425
	    size_t addr_length = 0;
426
	    int addrtype = 0;
427
428
#ifdef IPv6
429
	    struct addrinfo *ai;
430
431
	    if (getaddrinfo(displayOrAlias, NULL, NULL, &ai) == 0) {
432
		addrtype = ai->ai_addr->sa_family;
433
		if (addrtype == AF_INET) {
434
		    addr = &((struct sockaddr_in *)ai->ai_addr)->sin_addr;
435
		    addr_length = sizeof(struct in_addr);
436
		} else if (addrtype == AF_INET6) {
437
		    addr = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr;
438
		    addr_length = sizeof(struct in6_addr);
439
		}	      
440
	    }
441
#else
442
	    struct hostent  *hostent;
443
344
	    if ((hostent = gethostbyname (displayOrAlias)) == NULL)
444
	    if ((hostent = gethostbyname (displayOrAlias)) == NULL)
345
	    {
445
	    {
446
		addr = &(hostent->h_addr);
447
		addrtype = hostent->h_addrtype;
448
		addr_length = hostent->h_length;
449
	    }
450
#endif
451
	    if (addr == NULL)
452
	    {
346
		LogError ("Access file %s, display %s unknown\n", accessFile, displayOrAlias);
453
		LogError ("Access file %s, display %s unknown\n", accessFile, displayOrAlias);
347
		free ((char *) d);
454
		free ((char *) d);
348
		return NULL;
455
		return NULL;
349
	    }
456
	    }
350
	    d->type = DISPLAY_ADDRESS;
457
	    d->type = DISPLAY_ADDRESS;
351
	    display = &d->entry.displayAddress;
458
	    display = &d->entry.displayAddress;
352
	    if (!XdmcpAllocARRAY8 (&display->clientAddress, hostent->h_length))
459
	    if (!XdmcpAllocARRAY8 (&display->clientAddress, addr_length))
353
	    {
460
	    {
354
	    	free ((char *) d);
461
	    	free ((char *) d);
355
	    	return NULL;
462
	    	return NULL;
356
	    }
463
	    }
357
	    memmove( display->clientAddress.data, hostent->h_addr, hostent->h_length);
464
	    memmove( display->clientAddress.data, addr, addr_length);
358
	    switch (hostent->h_addrtype)
465
	    switch (addrtype)
359
	    {
466
	    {
360
#ifdef AF_UNIX
467
#ifdef AF_UNIX
361
	    case AF_UNIX:
468
	    case AF_UNIX:
Lines 367-372 Link Here
367
	    	display->connectionType = FamilyInternet;
474
	    	display->connectionType = FamilyInternet;
368
	    	break;
475
	    	break;
369
#endif
476
#endif
477
#ifdef IPv6
478
	    case AF_INET6:
479
	    	display->connectionType = FamilyInternetV6;
480
	    	break;
481
#endif
370
#ifdef AF_DECnet
482
#ifdef AF_DECnet
371
	    case AF_DECnet:
483
	    case AF_DECnet:
372
	    	display->connectionType = FamilyDECnet;
484
	    	display->connectionType = FamilyDECnet;
Lines 388-393 Link Here
388
	} else if (h->type == HOST_NOBROADCAST) {
500
	} else if (h->type == HOST_NOBROADCAST) {
389
	    FreeHostEntry (h);
501
	    FreeHostEntry (h);
390
	    d->notBroadcast = 1;
502
	    d->notBroadcast = 1;
503
	} else if (h->type == HOST_ANYADDR) {
504
	    if (d->type == DISPLAY_LISTEN) {
505
		*prev = h;
506
		prev = &h->next;
507
	    } else {
508
		Debug("Wildcard host specified in Xaccess for type other than LISTEN -- ignoring\n");
509
		FreeHostEntry (h);
510
	    }
391
	} else {
511
	} else {
392
	    *prev = h;
512
	    *prev = h;
393
	    prev = &h->next;
513
	    prev = &h->next;
Lines 574-579 Link Here
574
    {
694
    {
575
    	switch (d->type) {
695
    	switch (d->type) {
576
    	case DISPLAY_ALIAS:
696
    	case DISPLAY_ALIAS:
697
	case DISPLAY_LISTEN:
577
	    continue;
698
	    continue;
578
    	case DISPLAY_PATTERN:
699
    	case DISPLAY_PATTERN:
579
	    if (!clientName)
700
	    if (!clientName)
Lines 628-633 Link Here
628
    {
749
    {
629
    	switch (d->type) {
750
    	switch (d->type) {
630
    	case DISPLAY_ALIAS:
751
    	case DISPLAY_ALIAS:
752
	case DISPLAY_LISTEN:
631
	    continue;
753
	    continue;
632
    	case DISPLAY_PATTERN:
754
    	case DISPLAY_PATTERN:
633
	    if (!clientName)
755
	    if (!clientName)
Lines 675-680 Link Here
675
    {
797
    {
676
    	switch (d->type) {
798
    	switch (d->type) {
677
    	case DISPLAY_ALIAS:
799
    	case DISPLAY_ALIAS:
800
	case DISPLAY_LISTEN:
678
	    continue;
801
	    continue;
679
    	case DISPLAY_PATTERN:
802
    	case DISPLAY_PATTERN:
680
	    if (!clientName)
803
	    if (!clientName)
Lines 734-739 Link Here
734
	    continue;
857
	    continue;
735
    	switch (d->type) {
858
    	switch (d->type) {
736
    	case DISPLAY_ALIAS:
859
    	case DISPLAY_ALIAS:
860
    	case DISPLAY_LISTEN:
737
	    continue;
861
	    continue;
738
    	case DISPLAY_PATTERN:
862
    	case DISPLAY_PATTERN:
739
	    if (!clientName)
863
	    if (!clientName)
Lines 758-762 Link Here
758
    return (d != 0) && (d->notAllowed == 0)
882
    return (d != 0) && (d->notAllowed == 0)
759
	&& (type == BROADCAST_QUERY ? d->notBroadcast == 0 : 1);
883
	&& (type == BROADCAST_QUERY ? d->notBroadcast == 0 : 1);
760
}
884
}
885
886
void ForEachListenAddr (
887
    ListenFunc	listenfunction,
888
    ListenFunc	mcastfunction,
889
    void	**closure)
890
{
891
    DisplayEntry    *d;
892
    HostEntry	    *h;
893
    int		    listenFound = 0;
894
895
    for (d = database; d != NULL ; d = d->next)
896
    {
897
    	if (d->type == DISPLAY_LISTEN) {
898
	    listenFound = 1;
899
	    h = d->hosts;
900
	    if (h != NULL) {
901
		(*listenfunction) (&h->entry.hostAddress, closure);
902
	    }
903
	    for (h = h->next; h != NULL; h = h->next) {
904
		(*mcastfunction) (&h->entry.hostAddress, closure);
905
	    }
906
	}
907
    }
908
    if (!listenFound) {
909
	(*listenfunction) (NULL, closure);
910
    }
911
}
912
761
913
762
#endif /* XDMCP */
914
#endif /* XDMCP */
(-)4.3.0/xc/programs/xdm/auth.c (-14 / +94 lines)
Lines 88-94 Link Here
88
#include <net/if.h>
88
#include <net/if.h>
89
#endif /* __GNU__ */
89
#endif /* __GNU__ */
90
90
91
#if ((defined(SVR4) && !defined(sun)) || defined(ISC)) && defined(SIOCGIFCONF)
91
/* Solaris provides an extended interface SIOCGLIFCONF.  Other systems
92
 * may have this as well, but the code has only been tested on Solaris
93
 * so far, so we only enable it there.  Other platforms may be added as
94
 * needed.
95
 */
96
#ifdef SIOCGLIFCONF
97
#if defined(sun)
98
#define USE_SIOCGLIFCONF
99
#endif
100
#endif
101
102
#if ((defined(SVR4) && !defined(sun)) || defined(ISC)) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF)
92
#define SYSV_SIOCGIFCONF
103
#define SYSV_SIOCGIFCONF
93
#endif
104
#endif
94
105
Lines 270-276 Link Here
270
MakeServerAuthFile (struct display *d)
281
MakeServerAuthFile (struct display *d)
271
{
282
{
272
    int len;
283
    int len;
273
#ifdef SYSV
284
#if defined(SYSV) && !defined(SVR4)
274
#define NAMELEN	14
285
#define NAMELEN	14
275
#else
286
#else
276
#define NAMELEN	255
287
#define NAMELEN	255
Lines 851-857 Link Here
851
862
852
#else /* WINTCP */
863
#else /* WINTCP */
853
864
854
#ifdef SIOCGIFCONF
865
#if defined(SIOCGIFCONF) || defined (USE_SIOCGLIFCONF)
866
867
#ifdef USE_SIOCGLIFCONF
868
#define ifr_type    struct lifreq
869
#else
870
#define ifr_type    struct ifreq
871
#endif
855
872
856
/* Handle variable length ifreq in BNR2 and later */
873
/* Handle variable length ifreq in BNR2 and later */
857
#ifdef VARIABLE_IFREQ
874
#ifdef VARIABLE_IFREQ
Lines 859-865 Link Here
859
		     (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
876
		     (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
860
		      p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
877
		      p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
861
#else
878
#else
862
#define ifr_size(p) (sizeof (struct ifreq))
879
#define ifr_size(p) (sizeof (ifr_type))
863
#endif
880
#endif
864
881
865
/* Define this host for access control.  Find all the hosts the OS knows about 
882
/* Define this host for access control.  Find all the hosts the OS knows about 
Lines 869-910 Link Here
869
DefineSelf (int fd, FILE *file, Xauth *auth)
886
DefineSelf (int fd, FILE *file, Xauth *auth)
870
{
887
{
871
    char		buf[2048], *cp, *cplim;
888
    char		buf[2048], *cp, *cplim;
872
    struct ifconf	ifc;
873
    int 		len;
889
    int 		len;
874
    char 		*addr;
890
    char 		*addr;
875
    int 		family;
891
    int 		family;
876
    register struct ifreq *ifr;
892
    register ifr_type  *ifr;
893
#ifdef USE_SIOCGLIFCONF
894
    int			n;
895
    void *		bufptr = buf;
896
    size_t		buflen = sizeof(buf);
897
    struct lifconf	ifc;
898
#ifdef SIOCGLIFNUM
899
    struct lifnum	ifn;
900
#endif
901
#else
902
    struct ifconf	ifc;
903
#endif
877
    
904
    
905
#if defined(SIOCGLIFNUM) && defined(SIOCGLIFCONF)
906
    ifn.lifn_family = AF_UNSPEC;
907
    ifn.lifn_flags = 0;
908
    if (ioctl (fd, (int) SIOCGLIFNUM, (char *) &ifn) < 0)
909
	LogError ("Failed getting interface count");
910
    if (buflen < (ifn.lifn_count * sizeof(struct lifreq))) {
911
	buflen = ifn.lifn_count * sizeof(struct lifreq);
912
	bufptr = malloc(buflen);
913
    }
914
#endif
915
916
#ifdef USE_SIOCGLIFCONF
917
    ifc.lifc_family = AF_UNSPEC;
918
    ifc.lifc_flags = 0;
919
    ifc.lifc_len = buflen;
920
    ifc.lifc_buf = bufptr;
921
922
#define IFC_IOCTL_REQ SIOCGLIFCONF
923
#define IFC_IFC_REQ ifc.lifc_req
924
#define IFC_IFC_LEN ifc.lifc_len
925
#define IFR_IFR_ADDR ifr->lifr_addr
926
#define IFR_IFR_NAME ifr->lifr_name
927
928
#else    
878
    ifc.ifc_len = sizeof (buf);
929
    ifc.ifc_len = sizeof (buf);
879
    ifc.ifc_buf = buf;
930
    ifc.ifc_buf = buf;
880
    if (ifioctl (fd, SIOCGIFCONF, (char *) &ifc) < 0)
881
        LogError ("Trouble getting network interface configuration");
882
931
932
#define IFC_IOCTL_REQ SIOCGIFCONF
883
#ifdef ISC
933
#ifdef ISC
884
#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf
934
#define IFC_IFC_REQ (struct ifreq *) ifc.ifc_buf
885
#else
935
#else
886
#define IFC_IFC_REQ ifc.ifc_req
936
#define IFC_IFC_REQ ifc.ifc_req
887
#endif
937
#endif
938
#define IFC_IFC_LEN ifc.ifc_len
939
#define IFR_IFR_ADDR ifr->ifr_addr
940
#define IFR_IFR_NAME ifr->ifr_name
941
#endif
942
943
    if (ifioctl (fd, IFC_IOCTL_REQ, (char *) &ifc) < 0)
944
        LogError ("Trouble getting network interface configuration");
945
946
    if (ifioctl (fd, IFC_IOCTL_REQ, (char *) &ifc) < 0) {
947
        LogError ("Trouble getting network interface configuration");
948
#ifdef USE_SIOCGLIFCONF
949
	if (bufptr != buf) {
950
	    free(bufptr);
951
	}
952
#endif
953
	return;
954
    }
888
955
889
    cplim = (char *) IFC_IFC_REQ + ifc.ifc_len;
956
    cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN;
890
957
891
    for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
958
    for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
892
    {
959
    {
893
	ifr = (struct ifreq *) cp;
960
	ifr = (ifr_type *) cp;
894
#ifdef DNETCONN
961
#ifdef DNETCONN
895
	/*
962
	/*
896
	 * this is ugly but SIOCGIFCONF returns decnet addresses in
963
	 * this is ugly but SIOCGIFCONF returns decnet addresses in
897
	 * a different form from other decnet calls
964
	 * a different form from other decnet calls
898
	 */
965
	 */
899
	if (ifr->ifr_addr.sa_family == AF_DECnet) {
966
	if (IFR_IFR_ADDR.sa_family == AF_DECnet) {
900
		len = sizeof (struct dn_naddr);
967
		len = sizeof (struct dn_naddr);
901
		addr = (char *)ifr->ifr_addr.sa_data;
968
		addr = (char *)ifr->ifr_addr.sa_data;
902
		family = FamilyDECnet;
969
		family = FamilyDECnet;
903
	} else
970
	} else
904
#endif
971
#endif
905
	{
972
	{
906
	    if (ConvertAddr ((XdmcpNetaddr) &ifr->ifr_addr, &len, &addr) < 0)
973
	    family = ConvertAddr ((XdmcpNetaddr) &IFR_IFR_ADDR, &len, &addr);
974
	    if (family < 0)
907
		continue;
975
		continue;
976
908
	    if (len == 0)
977
	    if (len == 0)
909
 	    {
978
 	    {
910
		Debug ("Skipping zero length address\n");
979
		Debug ("Skipping zero length address\n");
Lines 917-930 Link Here
917
	     * the local entry anyway, so this one can
986
	     * the local entry anyway, so this one can
918
	     * be tossed.
987
	     * be tossed.
919
	     */
988
	     */
920
	    if (len == 4 &&
989
	    if (family == FamilyInternet && len == 4 &&
921
		addr[0] == 127 && addr[1] == 0 &&
990
		addr[0] == 127 && addr[1] == 0 &&
922
		addr[2] == 0 && addr[3] == 1)
991
		addr[2] == 0 && addr[3] == 1)
923
	    {
992
	    {
924
		    Debug ("Skipping localhost address\n");
993
		    Debug ("Skipping localhost address\n");
925
		    continue;
994
		    continue;
926
	    }
995
	    }
927
	    family = FamilyInternet;
996
#ifdef IPv6
997
	    if(family == FamilyInternetV6) {
998
		if (IN6_IS_ADDR_LOOPBACK(((struct in6_addr *)addr))) {
999
		    Debug ("Skipping IPv6 localhost address\n");
1000
		    continue;
1001
		}
1002
	    }
1003
#endif
928
	}
1004
	}
929
	Debug ("DefineSelf: write network address, length %d\n", len);
1005
	Debug ("DefineSelf: write network address, length %d\n", len);
930
	writeAddr (family, len, addr, file, auth);
1006
	writeAddr (family, len, addr, file, auth);
Lines 1022-1028 Link Here
1022
    t_close (fd);
1098
    t_close (fd);
1023
#endif
1099
#endif
1024
#ifdef TCPCONN
1100
#ifdef TCPCONN
1101
#ifdef IPv6
1102
    fd = socket (AF_INET6, SOCK_STREAM, 0);
1103
#else
1025
    fd = socket (AF_INET, SOCK_STREAM, 0);
1104
    fd = socket (AF_INET, SOCK_STREAM, 0);
1105
#endif
1026
    DefineSelf (fd, file, auth);
1106
    DefineSelf (fd, file, auth);
1027
    close (fd);
1107
    close (fd);
1028
#endif
1108
#endif
(-)4.3.0/xc/programs/xdm/choose.c (-4 / +22 lines)
Lines 43-48 Link Here
43
#include <sys/types.h>
43
#include <sys/types.h>
44
44
45
#include "dm_socket.h"
45
#include "dm_socket.h"
46
#include <arpa/inet.h>
46
47
47
#ifndef X_NO_SYS_UN
48
#ifndef X_NO_SYS_UN
48
#ifndef Lynx
49
#ifndef Lynx
Lines 197-215 Link Here
197
    netfamily = NetaddrFamily((XdmcpNetaddr)addr_buf);
198
    netfamily = NetaddrFamily((XdmcpNetaddr)addr_buf);
198
    switch (netfamily) {
199
    switch (netfamily) {
199
    case AF_INET:
200
    case AF_INET:
201
#ifdef IPv6
202
    case AF_INET6:
203
#endif
200
	{
204
	{
201
	    char *port;
205
	    char *port;
202
	    int portlen;
206
	    int portlen;
203
	    ARRAY8Ptr localAddress;
207
	    ARRAY8Ptr localAddress = getLocalAddress ();
208
209
#ifdef IPv6
210
	    if (localAddress->length == 16)
211
		netfamily = AF_INET6;
212
	    else
213
		netfamily = AF_INET;
214
#endif
204
215
205
	    port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen);
216
	    port = NetaddrPort((XdmcpNetaddr)addr_buf, &portlen);
206
	    result_buf[0] = netfamily >> 8;
217
	    result_buf[0] = netfamily >> 8;
207
	    result_buf[1] = netfamily & 0xFF;
218
	    result_buf[1] = netfamily & 0xFF;
208
	    result_buf[2] = port[0];
219
	    result_buf[2] = port[0];
209
	    result_buf[3] = port[1];
220
	    result_buf[3] = port[1];
210
	    localAddress = getLocalAddress ();
221
	    memmove( (char *)result_buf+4, (char *)localAddress->data, 
211
	    memmove( (char *)result_buf+4, (char *)localAddress->data, 4);
222
	      localAddress->length);
212
	    result_len = 8;
223
	    result_len = 4 + localAddress->length;
213
	}
224
	}
214
	break;
225
	break;
215
#ifdef AF_DECnet
226
#ifdef AF_DECnet
Lines 372-377 Link Here
372
    {
383
    {
373
	*argp = parseArgs (*argp, "BROADCAST");
384
	*argp = parseArgs (*argp, "BROADCAST");
374
    }
385
    }
386
#ifdef IPv6
387
    else if ( (addr->length == 16) && 
388
      (inet_ntop(AF_INET6, addr->data, hostbuf, sizeof(hostbuf))))
389
    {
390
	*argp = parseArgs (*argp, hostbuf);
391
    }
392
#endif
375
    else if (ARRAY8ToDottedDecimal (addr, hostbuf, sizeof (hostbuf)))
393
    else if (ARRAY8ToDottedDecimal (addr, hostbuf, sizeof (hostbuf)))
376
    {
394
    {
377
	*argp = parseArgs (*argp, hostbuf);
395
	*argp = parseArgs (*argp, hostbuf);
(-)4.3.0/xc/programs/xdm/chooser.c (-9 / +123 lines)
Lines 194-199 Link Here
194
static HostName    *hostNamedb;
194
static HostName    *hostNamedb;
195
195
196
static int  socketFD;
196
static int  socketFD;
197
#ifdef IPv6
198
static int  socket6FD;
199
#endif
197
200
198
static int  pingTry;
201
static int  pingTry;
199
202
Lines 262-274 Link Here
262
PingHosts (XtPointer closure, XtIntervalId *id)
265
PingHosts (XtPointer closure, XtIntervalId *id)
263
{
266
{
264
    HostAddr	*hosts;
267
    HostAddr	*hosts;
268
    int		 sfd = socketFD;
265
269
266
    for (hosts = hostAddrdb; hosts; hosts = hosts->next)
270
    for (hosts = hostAddrdb; hosts; hosts = hosts->next)
267
    {
271
    {
272
#ifdef IPv6
273
	if ( ((struct sockaddr *) hosts->addr)->sa_family == AF_INET6 )
274
	    sfd = socket6FD;
275
	else
276
	    sfd = socketFD;
277
#endif
268
	if (hosts->type == QUERY)
278
	if (hosts->type == QUERY)
269
	    XdmcpFlush (socketFD, &directBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen);
279
	    XdmcpFlush (sfd, &directBuffer, 
280
			(XdmcpNetaddr) hosts->addr, hosts->addrlen);
270
	else
281
	else
271
	    XdmcpFlush (socketFD, &broadcastBuffer, (XdmcpNetaddr) hosts->addr, hosts->addrlen);
282
	    XdmcpFlush (sfd, &broadcastBuffer, 
283
			(XdmcpNetaddr) hosts->addr, hosts->addrlen);
272
    }
284
    }
273
    if (++pingTry < TRIES)
285
    if (++pingTry < TRIES)
274
	XtAddTimeOut (PING_INTERVAL, PingHosts, (XtPointer) 0);
286
	XtAddTimeOut (PING_INTERVAL, PingHosts, (XtPointer) 0);
Lines 321-326 Link Here
321
	hostAddr.length = 4;
333
	hostAddr.length = 4;
322
	connectionType = FamilyInternet;
334
	connectionType = FamilyInternet;
323
	break;
335
	break;
336
#ifdef IPv6
337
    case AF_INET6:
338
	hostAddr.data = (CARD8 *) &((struct sockaddr_in6 *) addr)->sin6_addr;
339
	hostAddr.length = 16;
340
	connectionType = FamilyInternetV6;
341
	break;
342
#endif
324
    default:
343
    default:
325
	hostAddr.data = (CARD8 *) "";
344
	hostAddr.data = (CARD8 *) "";
326
	hostAddr.length = 0;
345
	hostAddr.length = 0;
Lines 350-360 Link Here
350
	    switch (addr->sa_family)
369
	    switch (addr->sa_family)
351
	    {
370
	    {
352
	    case AF_INET:
371
	    case AF_INET:
372
#ifdef IPv6
373
	    case AF_INET6:
374
#endif
353
	    	{
375
	    	{
354
	    	    struct hostent  *hostent;
376
	    	    struct hostent  *hostent;
355
		    char	    *host;
377
		    char	    *host;
356
    	
378
    	
357
	    	    hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, AF_INET);
379
	    	    hostent = gethostbyaddr ((char *)hostAddr.data, hostAddr.length, addr->sa_family);
358
	    	    if (hostent)
380
	    	    if (hostent)
359
	    	    {
381
	    	    {
360
			XdmcpDisposeARRAY8 (hostname);
382
			XdmcpDisposeARRAY8 (hostname);
Lines 464-474 Link Here
464
    ARRAY8	    hostname;
486
    ARRAY8	    hostname;
465
    ARRAY8	    status;
487
    ARRAY8	    status;
466
    int		    saveHostname = 0;
488
    int		    saveHostname = 0;
489
#ifdef IPv6
490
    struct sockaddr_storage addr;
491
#else
467
    struct sockaddr addr;
492
    struct sockaddr addr;
493
#endif
468
    int		    addrlen;
494
    int		    addrlen;
495
    int		    sfd = * (int *) closure;
469
496
470
    addrlen = sizeof (addr);
497
    addrlen = sizeof (addr);
471
    if (!XdmcpFill (socketFD, &buffer, (XdmcpNetaddr) &addr, &addrlen))
498
    if (!XdmcpFill (sfd, &buffer, (XdmcpNetaddr) &addr, &addrlen))
472
	return;
499
	return;
473
    if (!XdmcpReadHeader (&buffer, &header))
500
    if (!XdmcpReadHeader (&buffer, &header))
474
	return;
501
	return;
Lines 486-492 Link Here
486
	    if (header.length == 6 + authenticationName.length +
513
	    if (header.length == 6 + authenticationName.length +
487
	    	hostname.length + status.length)
514
	    	hostname.length + status.length)
488
	    {
515
	    {
489
		if (AddHostname (&hostname, &status, &addr, header.opcode == (int) WILLING))
516
		if (AddHostname (&hostname, &status, (struct sockaddr *) &addr,
517
		  		 header.opcode == (int) WILLING))
490
		    saveHostname = 1;
518
		    saveHostname = 1;
491
	    }
519
	    }
492
    	}
520
    	}
Lines 498-504 Link Here
498
    	{
526
    	{
499
	    if (header.length == 4 + hostname.length + status.length)
527
	    if (header.length == 4 + hostname.length + status.length)
500
	    {
528
	    {
501
		if (AddHostname (&hostname, &status, &addr, header.opcode == (int) WILLING))
529
		if (AddHostname (&hostname, &status, (struct sockaddr *) &addr,
530
		  		 header.opcode == (int) WILLING))
502
		    saveHostname = 1;
531
		    saveHostname = 1;
503
532
504
	    }
533
	    }
Lines 558-564 Link Here
558
static void
587
static void
559
RegisterHostname (char *name)
588
RegisterHostname (char *name)
560
{
589
{
590
#ifndef IPv6
561
    struct hostent	*hostent;
591
    struct hostent	*hostent;
592
#endif
562
    struct sockaddr_in	in_addr;
593
    struct sockaddr_in	in_addr;
563
    struct ifconf	ifc;
594
    struct ifconf	ifc;
564
    register struct ifreq *ifr;
595
    register struct ifreq *ifr;
Lines 673-685 Link Here
673
    }
704
    }
674
    else
705
    else
675
    {
706
    {
676
677
	/* address as hex string, e.g., "12180022" (depreciated) */
707
	/* address as hex string, e.g., "12180022" (depreciated) */
678
	if (strlen(name) == 8 &&
708
	if (strlen(name) == 8 &&
679
	    FromHex(name, (char *)&in_addr.sin_addr, strlen(name)) == 0)
709
	    FromHex(name, (char *)&in_addr.sin_addr, strlen(name)) == 0)
680
	{
710
	{
681
	    in_addr.sin_family = AF_INET;
711
	    in_addr.sin_family = AF_INET;
712
	    in_addr.sin_port = htons (XDM_UDP_PORT);
713
#ifdef BSD44SOCKETS
714
	    in_addr.sin_len = sizeof(in_addr);
715
#endif
716
	    RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
717
				QUERY);
682
	}
718
	}
719
	else {
720
721
#ifdef IPv6
722
	    char sport[8];
723
	    struct addrinfo *ai, *nai, hints;
724
	    bzero(&hints,sizeof(hints));
725
	    hints.ai_socktype = SOCK_DGRAM;
726
	    sprintf(sport, "%d", XDM_UDP_PORT);
727
	    if (getaddrinfo(name, sport, &hints, &ai) == 0) {
728
		for (nai = ai ; nai != NULL ; nai = nai->ai_next) {
729
		    if ((nai->ai_family == AF_INET) || 
730
		        (nai->ai_family == AF_INET6)) {
731
			if (((nai->ai_family == AF_INET) && 
732
			  IN_MULTICAST(((struct sockaddr_in *) nai->ai_addr)
733
			    ->sin_addr.s_addr))
734
			  || ((nai->ai_family == AF_INET6) && 
735
			    IN6_IS_ADDR_MULTICAST(
736
				&((struct sockaddr_in6 *) nai->ai_addr)
737
				  ->sin6_addr))) 
738
			{
739
			    RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, 
740
			      BROADCAST_QUERY);
741
			} else {
742
			    RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, 
743
			      QUERY);
744
			}
745
		    }
746
		}
747
	    }
748
#else
683
	/* Per RFC 1123, check first for IP address in dotted-decimal form */
749
	/* Per RFC 1123, check first for IP address in dotted-decimal form */
684
	else if ((in_addr.sin_addr.s_addr = inet_addr(name)) != -1)
750
	else if ((in_addr.sin_addr.s_addr = inet_addr(name)) != -1)
685
	    in_addr.sin_family = AF_INET;
751
	    in_addr.sin_family = AF_INET;
Lines 699-704 Link Here
699
#endif
765
#endif
700
	RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
766
	RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
701
			  QUERY);
767
			  QUERY);
768
#endif /* IPv6 */
769
	}
770
771
702
    }
772
    }
703
}
773
}
704
#else /* __GNU__ */
774
#else /* __GNU__ */
Lines 723-729 Link Here
723
	    FromHex(name, (char *)&in_addr.sin_addr, strlen(name)) == 0)
793
	    FromHex(name, (char *)&in_addr.sin_addr, strlen(name)) == 0)
724
	{
794
	{
725
	    in_addr.sin_family = AF_INET;
795
	    in_addr.sin_family = AF_INET;
726
	}
796
	    in_addr.sin_port = htons (XDM_UDP_PORT);
797
	    RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
798
				QUERY);
799
	} else {
800
#ifdef IPv6
801
	    char sport[8];
802
	    struct addrinfo *ai, *nai, hints;
803
	    bzero(&hints,sizeof(hints));
804
	    hints.ai_socktype = SOCK_DGRAM;
805
	    sprintf(sport, "%d", XDM_UDP_PORT);
806
	    if (getaddrinfo(name, sport, &hints, &ai) == 0) {
807
		for (nai = ai ; nai != NULL ; nai = nai->ai_next) {
808
		    if ((nai->ai_family == AF_INET) || 
809
		        (nai->ai_family == AF_INET6)) {
810
			RegisterHostaddr(nai->ai_addr, nai->ai_addrlen, QUERY);
811
		    }
812
		}
813
	    }
814
#else
727
	/* Per RFC 1123, check first for IP address in dotted-decimal form */
815
	/* Per RFC 1123, check first for IP address in dotted-decimal form */
728
	else if ((in_addr.sin_addr.s_addr = inet_addr(name)) != -1)
816
	else if ((in_addr.sin_addr.s_addr = inet_addr(name)) != -1)
729
	    in_addr.sin_family = AF_INET;
817
	    in_addr.sin_family = AF_INET;
Lines 740-745 Link Here
740
	in_addr.sin_port = htons (XDM_UDP_PORT);
828
	in_addr.sin_port = htons (XDM_UDP_PORT);
741
	RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
829
	RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
742
			  QUERY);
830
			  QUERY);
831
#endif
832
	}
833
743
    }
834
    }
744
}
835
}
745
#endif /* __GNU__ */
836
#endif /* __GNU__ */
Lines 820-825 Link Here
820
#else
911
#else
821
    if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
912
    if ((socketFD = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
822
	return 0;
913
	return 0;
914
#ifdef IPv6
915
    socket6FD = socket (AF_INET6, SOCK_DGRAM, 0);
916
#endif
823
#endif
917
#endif
824
#ifndef STREAMSCONN
918
#ifndef STREAMSCONN
825
#ifdef SO_BROADCAST
919
#ifdef SO_BROADCAST
Lines 830-836 Link Here
830
#endif
924
#endif
831
    
925
    
832
    XtAddInput (socketFD, (XtPointer) XtInputReadMask, ReceivePacket,
926
    XtAddInput (socketFD, (XtPointer) XtInputReadMask, ReceivePacket,
833
		(XtPointer) 0);
927
		(XtPointer) &socketFD);
928
#ifdef IPv6
929
    XtAddInput (socket6FD, (XtPointer) XtInputReadMask, ReceivePacket,
930
		(XtPointer) &socket6FD);
931
#endif
834
    while (*argv)
932
    while (*argv)
835
    {
933
    {
836
	RegisterHostname (*argv);
934
	RegisterHostname (*argv);
Lines 847-852 Link Here
847
    if (app_resources.xdmAddress)
945
    if (app_resources.xdmAddress)
848
    {
946
    {
849
	struct sockaddr_in  in_addr;
947
	struct sockaddr_in  in_addr;
948
#ifdef IPv6
949
	struct sockaddr_in6 in6_addr;
950
#endif
850
	struct sockaddr	*addr = NULL;
951
	struct sockaddr	*addr = NULL;
851
	int		family;
952
	int		family;
852
	int		len = 0;
953
	int		len = 0;
Lines 871-876 Link Here
871
	    addr = (struct sockaddr *) &in_addr;
972
	    addr = (struct sockaddr *) &in_addr;
872
	    len = sizeof (in_addr);
973
	    len = sizeof (in_addr);
873
	    break;
974
	    break;
975
#ifdef IPv6
976
	case AF_INET6:
977
	    bzero(&in6_addr, sizeof(in6_addr));
978
#ifdef SIN6_LEN
979
	    in6_addr.sin6_len = sizeof(in6_addr);
980
#endif
981
	    in6_addr.sin6_family = family;
982
	    memmove( &in6_addr.sin6_port, xdm + 2, 2);
983
	    memmove( &in6_addr.sin6_addr, xdm + 4, 16);
984
	    addr = (struct sockaddr *) &in6_addr;
985
	    len = sizeof (in6_addr);
986
	    break;
987
#endif
874
	}
988
	}
875
#if defined(STREAMSCONN)
989
#if defined(STREAMSCONN)
876
	if ((fd = t_open ("/dev/tcp", O_RDWR, NULL)) == -1)
990
	if ((fd = t_open ("/dev/tcp", O_RDWR, NULL)) == -1)
(-)4.3.0/xc/programs/xdm/config/Xaccess (-1 / +22 lines)
Lines 1-5 Link Here
1
# $Xorg: Xaccess,v 1.3 2000/08/17 19:54:17 cpqbld Exp $
1
# $Xorg: Xaccess,v 1.3 2000/08/17 19:54:17 cpqbld Exp $
2
#
2
# Updated for IPv6
3
# $XFree86: xc/programs/xdm/config/Xaccess,v 1.3 2001/01/17 23:45:24 dawes Exp $
3
# $XFree86: xc/programs/xdm/config/Xaccess,v 1.3 2001/01/17 23:45:24 dawes Exp $
4
#
4
#
5
# Access control file for XDMCP connections
5
# Access control file for XDMCP connections
Lines 24-29 Link Here
24
#
24
#
25
#       %name		list of hosts ...
25
#       %name		list of hosts ...
26
#
26
#
27
# To control which addresses xdm listens for requests on:
28
#
29
#	LISTEN		address [list of multicast groups ... ]
30
#
27
# The first form tells xdm which displays to respond to itself.
31
# The first form tells xdm which displays to respond to itself.
28
# The second form tells xdm to forward indirect queries from hosts matching
32
# The second form tells xdm to forward indirect queries from hosts matching
29
# the specified pattern to the indicated list of hosts.
33
# the specified pattern to the indicated list of hosts.
Lines 32-37 Link Here
32
# address and display the results on the terminal.
36
# address and display the results on the terminal.
33
# The fourth form is similar to the third, except instead of using the
37
# The fourth form is similar to the third, except instead of using the
34
# broadcast address, it sends DirectQuerys to each of the hosts in the list
38
# broadcast address, it sends DirectQuerys to each of the hosts in the list
39
# The fifth form tells xdm which addresses to listen for incoming connections
40
# on.  If present, xdm will only listen for connections on the specified 
41
# interfaces and/or multicast groups.
35
#
42
#
36
# In all cases, xdm uses the first entry which matches the terminal;
43
# In all cases, xdm uses the first entry which matches the terminal;
37
# for IndirectQuery messages only entries with right hand sides can
44
# for IndirectQuery messages only entries with right hand sides can
Lines 68-70 Link Here
68
#%hostlist	host-a host-b
75
#%hostlist	host-a host-b
69
76
70
#*		CHOOSER %hostlist	#
77
#*		CHOOSER %hostlist	#
78
79
#
80
# If you have a machine with multiple network interfaces or IP addresses
81
# you can control which interfaces accept XDMCP packets by listing a LISTEN
82
# line for each interface you want to listen on.  You can additionally list
83
# one or more multicast groups after each address to listen on those groups
84
# on that address.
85
#
86
# If no LISTEN is specified, the default is the same as "LISTEN *" - listen on
87
# all unicast interfaces, but not for multicast packets.  If any LISTEN lines
88
# are specified, then only the listed interfaces will be listened on.
89
#
90
91
#LISTEN		* ff02::1 
(-)4.3.0/xc/programs/xdm/dm.c (-2 / +5 lines)
Lines 73-79 Link Here
73
#endif
73
#endif
74
74
75
75
76
#if defined(SVR4) && !defined(SCO)
76
#if defined(SVR4) && !defined(SCO) && !defined(sun)
77
extern FILE    *fdopen();
77
extern FILE    *fdopen();
78
#endif
78
#endif
79
79
Lines 86-92 Link Here
86
static void	StartDisplays (void);
86
static void	StartDisplays (void);
87
static void	TerminateProcess (int pid, int signal);
87
static void	TerminateProcess (int pid, int signal);
88
88
89
int		Rescan;
89
volatile int	Rescan;
90
static long	ServersModTime, ConfigModTime, AccessFileModTime;
90
static long	ServersModTime, ConfigModTime, AccessFileModTime;
91
91
92
int nofork_session = 0;
92
int nofork_session = 0;
Lines 177-182 Link Here
177
    SetAccessFileTime ();
177
    SetAccessFileTime ();
178
#ifdef XDMCP
178
#ifdef XDMCP
179
    ScanAccessDatabase ();
179
    ScanAccessDatabase ();
180
    UpdateListenSockets ();
180
#endif
181
#endif
181
    ScanServers ();
182
    ScanServers ();
182
    StartDisplays ();
183
    StartDisplays ();
Lines 281-286 Link Here
281
    SetAccessFileTime ();
282
    SetAccessFileTime ();
282
#ifdef XDMCP
283
#ifdef XDMCP
283
    ScanAccessDatabase ();
284
    ScanAccessDatabase ();
285
    UpdateListenSockets ();
284
#endif
286
#endif
285
    StartDisplays ();
287
    StartDisplays ();
286
}
288
}
Lines 339-344 Link Here
339
	    LogInfo ("Rereading access file %s\n", accessFile);
341
	    LogInfo ("Rereading access file %s\n", accessFile);
340
	    AccessFileModTime = statb.st_mtime;
342
	    AccessFileModTime = statb.st_mtime;
341
	    ScanAccessDatabase ();
343
	    ScanAccessDatabase ();
344
	    UpdateListenSockets();
342
	}
345
	}
343
    }
346
    }
344
#endif
347
#endif
(-)4.3.0/xc/programs/xdm/dm.h (-1 / +24 lines)
Lines 116-121 Link Here
116
#endif
116
#endif
117
#endif
117
#endif
118
118
119
#ifdef USE_PAM
120
#include <security/pam_appl.h>
121
#endif
122
123
#ifdef CSRG_BASED
124
#include <sys/param.h>
125
#ifdef HAS_SETUSERCONTEXT
126
#include <login_cap.h>
127
#include <pwd.h>
128
#ifdef USE_BSDAUTH
129
#include <bsd_auth.h>
130
#endif
131
#endif
132
#endif
133
119
# define waitCompose(sig,core,code) ((sig) * 256 + (core) * 128 + (code))
134
# define waitCompose(sig,core,code) ((sig) * 256 + (core) * 128 + (code))
120
# define waitVal(w)	waitCompose(waitSig(w), waitCore(w), waitCode(w))
135
# define waitVal(w)	waitCompose(waitSig(w), waitCore(w), waitCode(w))
121
136
Lines 186-191 Link Here
186
	int		useChooser;	/* Run the chooser for this display */
201
	int		useChooser;	/* Run the chooser for this display */
187
	ARRAY8		clientAddr;	/* for chooser picking */
202
	ARRAY8		clientAddr;	/* for chooser picking */
188
	CARD16		connectionType;	/* ... */
203
	CARD16		connectionType;	/* ... */
204
	int		xdmcpFd;
189
#endif
205
#endif
190
	/* server management resources */
206
	/* server management resources */
191
	int		serverAttempts;	/* number of attempts at running X */
207
	int		serverAttempts;	/* number of attempts at running X */
Lines 279-284 Link Here
279
#endif
295
#endif
280
296
281
typedef void (*ChooserFunc)(CARD16 connectionType, ARRAY8Ptr addr, char *closure);
297
typedef void (*ChooserFunc)(CARD16 connectionType, ARRAY8Ptr addr, char *closure);
298
typedef void (*ListenFunc)(ARRAY8Ptr addr, void **closure);
282
299
283
struct verify_info {
300
struct verify_info {
284
	int		uid;		/* user id */
301
	int		uid;		/* user id */
Lines 352-357 Link Here
352
extern int ScanAccessDatabase (void);
369
extern int ScanAccessDatabase (void);
353
extern int UseChooser (ARRAY8Ptr clientAddress, CARD16 connectionType);
370
extern int UseChooser (ARRAY8Ptr clientAddress, CARD16 connectionType);
354
extern void ForEachChooserHost (ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure);
371
extern void ForEachChooserHost (ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure);
372
extern void ForEachListenAddr(ListenFunc listenfunction,
373
  ListenFunc mcastfcuntion, void **closure);
355
374
356
/* in choose.c */
375
/* in choose.c */
357
extern ARRAY8Ptr IndirectChoice (ARRAY8Ptr clientAddress, CARD16 connectionType);
376
extern ARRAY8Ptr IndirectChoice (ARRAY8Ptr clientAddress, CARD16 connectionType);
Lines 439-447 Link Here
439
extern int WaitForServer (struct display *d);
458
extern int WaitForServer (struct display *d);
440
extern void ResetServer (struct display *d);
459
extern void ResetServer (struct display *d);
441
460
442
/* socket.c */
461
/* socket.c or streams.c */
443
extern int GetChooserAddr (char *addr, int *lenp);
462
extern int GetChooserAddr (char *addr, int *lenp);
444
extern void CreateWellKnownSockets (void);
463
extern void CreateWellKnownSockets (void);
464
extern void UpdateListenSockets (void);
465
extern void CloseListenSockets (void);
466
extern void ProcessListenSockets (fd_set *readmask);
445
467
446
/* in util.c */
468
/* in util.c */
447
extern char *localHostname (void);
469
extern char *localHostname (void);
Lines 467-472 Link Here
467
extern void WaitForSomething (void);
489
extern void WaitForSomething (void);
468
extern void init_session_id(void);
490
extern void init_session_id(void);
469
extern void registerHostname(char *name, int namelen);
491
extern void registerHostname(char *name, int namelen);
492
extern void ProcessRequestSocket(int fd);
470
493
471
/*
494
/*
472
 * CloseOnFork flags
495
 * CloseOnFork flags
(-)4.3.0/xc/programs/xdm/dpylist.c (+1 lines)
Lines 258-263 Link Here
258
    d->clientAddr.data = NULL;
258
    d->clientAddr.data = NULL;
259
    d->clientAddr.length = 0;
259
    d->clientAddr.length = 0;
260
    d->connectionType = 0;
260
    d->connectionType = 0;
261
    d->xdmcpFd = -1;
261
#endif
262
#endif
262
    d->version = 1;		/* registered with The Open Group */
263
    d->version = 1;		/* registered with The Open Group */
263
    displays = d;
264
    displays = d;
(-)4.3.0/xc/programs/xdm/genauth.c (-15 / +43 lines)
Lines 47-52 Link Here
47
47
48
static unsigned char	key[8];
48
static unsigned char	key[8];
49
49
50
#ifdef DEV_RANDOM
51
extern char	*randomDevice;
52
#endif
53
50
#ifdef HASXDMAUTH
54
#ifdef HASXDMAUTH
51
55
52
typedef unsigned char auth_cblock[8];	/* block size */
56
typedef unsigned char auth_cblock[8];	/* block size */
Lines 66-74 Link Here
66
70
67
#endif
71
#endif
68
72
73
#ifdef POLL_DEV_RANDOM
74
#include <poll.h>
75
static int
76
pollRandomDevice (int fd)
77
{
78
    struct pollfd fds;
79
80
    fds.fd = fd;
81
    fds.events = POLLIN | POLLRDNORM;
82
    /* Wait up to 5 seconds for entropy to accumulate */
83
    return poll(&fds, 1, 5000);
84
}
85
#else
86
#define pollRandomDevice 1
87
#endif
88
69
# define FILE_LIMIT	1024	/* no more than this many buffers */
89
# define FILE_LIMIT	1024	/* no more than this many buffers */
70
90
71
#if !defined(ARC4_RANDOM) && !defined(DEV_RANDOM)
91
#if !defined(ARC4_RANDOM) 
72
static int
92
static int
73
sumFile (char *name, long sum[2])
93
sumFile (char *name, long sum[2])
74
{
94
{
Lines 120-131 Link Here
120
140
121
    _XdmcpWrapperToOddParity(sum, key);
141
    _XdmcpWrapperToOddParity(sum, key);
122
142
123
#elif defined(DEV_RANDOM)
143
#else
124
    int fd;
125
    unsigned char   tmpkey[8];
144
    unsigned char   tmpkey[8];
145
    long	    sum[2];
146
147
#ifdef DEV_RANDOM
148
    int fd;
126
    
149
    
127
    if ((fd = open(DEV_RANDOM, O_RDONLY)) >= 0) {
150
    if ((fd = open(randomDevice, O_RDONLY)) >= 0) {
128
	if (read(fd, tmpkey, 8) == 8) {
151
	if (pollRandomDevice(fd) && read(fd, tmpkey, 8) == 8) {
129
	    tmpkey[0] = 0;
152
	    tmpkey[0] = 0;
130
	    _XdmcpWrapperToOddParity(tmpkey, key);
153
	    _XdmcpWrapperToOddParity(tmpkey, key);
131
	    close(fd);
154
	    close(fd);
Lines 133-143 Link Here
133
	} else {
156
	} else {
134
	    close(fd);
157
	    close(fd);
135
	}
158
	}
159
    } else {
160
	LogError("Cannot open randomDevice \"%s\", errno = %d\n", 
161
	  randomDevice, errno);
136
    }
162
    }
137
#else    
163
#endif    
138
    long	    sum[2];
139
    unsigned char   tmpkey[8];
140
141
    if (!sumFile (randomFile, sum)) {
164
    if (!sumFile (randomFile, sum)) {
142
	sum[0] = time ((Time_t *) 0);
165
	sum[0] = time ((Time_t *) 0);
143
	sum[1] = time ((Time_t *) 0);
166
	sum[1] = time ((Time_t *) 0);
Lines 231-248 Link Here
231
#ifdef ARC4_RANDOM
254
#ifdef ARC4_RANDOM
232
	    localkey[0] = arc4random();
255
	    localkey[0] = arc4random();
233
	    localkey[1] = arc4random();
256
	    localkey[1] = arc4random();
234
#elif defined(DEV_RANDOM)
257
#else
258
#ifdef DEV_RANDOM
235
	    int fd;
259
	    int fd;
236
    
260
    
237
	    if ((fd = open(DEV_RANDOM, O_RDONLY)) >= 0) {
261
	    if ((fd = open(randomDevice, O_RDONLY)) >= 0) {
238
		if (read(fd, (char *)localkey, 8) != 8) {
262
		if (pollRandomDevice(fd) && 
239
		    localkey[0] = 1;
263
		  read(fd, (char *)localkey, 8) != 8) {
264
		    localkey[0] = 0; localkey[1] = 0;
240
		}
265
		}
241
		close(fd);
266
		close(fd);
242
	    } else {
267
	    } else {
243
		localkey[0] = 1;
268
		LogError("Cannot open randomDevice \"%s\", errno = %d\n", 
269
		  randomDevice, errno);
244
	    }
270
	    }
245
#else 
271
	    /* Fallback if not able to get from /dev/random */
272
	    if ( (localkey[0] == 0) && (localkey[1] == 0) )
273
#endif
246
    	    if (!sumFile (randomFile, localkey)) {
274
    	    if (!sumFile (randomFile, localkey)) {
247
		localkey[0] = 1; /* To keep from continually calling sumFile() */
275
		localkey[0] = 1; /* To keep from continually calling sumFile() */
248
    	    }
276
    	    }
(-)4.3.0/xc/programs/xdm/greet.h (-1 / +1 lines)
Lines 37-43 Link Here
37
/*
37
/*
38
 * Do this rather than break a build over a const-mismatch
38
 * Do this rather than break a build over a const-mismatch
39
 */
39
 */
40
#if defined(__linux__) || defined(CSRG_BASED)
40
#if defined(__linux__) || defined(CSRG_BASED) || (defined(sun) && defined(SVR4))
41
#define CRYPT_ARGS    const char *s1, const char *s2
41
#define CRYPT_ARGS    const char *s1, const char *s2
42
#define GETSPNAM_ARGS const char *name
42
#define GETSPNAM_ARGS const char *name
43
#define GETPWNAM_ARGS const char *name
43
#define GETPWNAM_ARGS const char *name
(-)4.3.0/xc/programs/xdm/greeter/Login.c (-1 / +6 lines)
Lines 137-143 Link Here
137
    {XtNpasswdPrompt, XtCPasswdPrompt, XtRString, sizeof (char *),
137
    {XtNpasswdPrompt, XtCPasswdPrompt, XtRString, sizeof (char *),
138
	offset(passwdPrompt), XtRString, "Password:  "},
138
	offset(passwdPrompt), XtRString, "Password:  "},
139
    {XtNfail, XtCFail, XtRString, sizeof (char *),
139
    {XtNfail, XtCFail, XtRString, sizeof (char *),
140
	offset(fail), XtRString, "Login incorrect"},
140
	offset(fail), XtRString, 
141
#if defined(sun) && defined(SVR4)
142
     "Login incorrect or not on system console if root"},
143
#else
144
     "Login incorrect"},
145
#endif
141
    {XtNfailTimeout, XtCFailTimeout, XtRInt, sizeof (int),
146
    {XtNfailTimeout, XtCFailTimeout, XtRInt, sizeof (int),
142
	offset(failTimeout), XtRImmediate, (XtPointer) 10},
147
	offset(failTimeout), XtRImmediate, (XtPointer) 10},
143
    {XtNnotifyDone, XtCCallback, XtRFunction, sizeof (XtPointer),
148
    {XtNnotifyDone, XtCCallback, XtRFunction, sizeof (XtPointer),
(-)4.3.0/xc/programs/xdm/greeter/greet.c (-3 / +30 lines)
Lines 145-152 Link Here
145
	    data->name, strlen (data->passwd));
145
	    data->name, strlen (data->passwd));
146
    switch (status) {
146
    switch (status) {
147
    case NOTIFY_OK:
147
    case NOTIFY_OK:
148
	strcpy (name, data->name);
148
	strncpy (name, data->name, sizeof(name));
149
	strcpy (password, data->passwd);
149
	name[sizeof(name)-1] = '\0';
150
	strncpy (password, data->passwd, sizeof(password));
151
	password[sizeof(password)-1] = '\0';
150
	bzero (data->passwd, PASSWORD_LEN);
152
	bzero (data->passwd, PASSWORD_LEN);
151
	code = 0;
153
	code = 0;
152
	done = 1;
154
	done = 1;
Lines 280-285 Link Here
280
    Debug ("Greet connection closed\n");
282
    Debug ("Greet connection closed\n");
281
}
283
}
282
284
285
#define WHITESPACE 0
286
#define ARGUMENT 1
287
283
static int
288
static int
284
Greet (struct display *d, struct greet_info *greet)
289
Greet (struct display *d, struct greet_info *greet)
285
{
290
{
Lines 306-312 Link Here
306
    Debug ("Done dispatch %s\n", d->name);
311
    Debug ("Done dispatch %s\n", d->name);
307
    if (code == 0)
312
    if (code == 0)
308
    {
313
    {
309
	greet->name = name;
314
	char *ptr;
315
	unsigned int c,state = WHITESPACE;
316
 
317
       /*
318
        * process the name string to get rid of
319
        * white spaces.
320
        */
321
 
322
	for (ptr = name; state == WHITESPACE; ptr++)
323
	{
324
		c = (unsigned int)(*ptr);
325
                if ( c == ' ')
326
		{
327
			continue;
328
                }
329
                else
330
                {
331
                         state = ARGUMENT;
332
                         break;
333
                }
334
        }
335
 
336
        greet->name = ptr;
310
	greet->password = password;
337
	greet->password = password;
311
	XtSetArg (arglist[0], XtNsessionArgument, (char *) &(greet->string));
338
	XtSetArg (arglist[0], XtNsessionArgument, (char *) &(greet->string));
312
	XtSetArg (arglist[1], XtNallowNullPasswd, (char *) &(greet->allow_null_passwd));
339
	XtSetArg (arglist[1], XtNallowNullPasswd, (char *) &(greet->allow_null_passwd));
(-)4.3.0/xc/programs/xdm/greeter/verify.c (+41 lines)
Lines 304-309 Link Here
304
	char		**argv;
304
	char		**argv;
305
305
306
	Debug ("Verify %s ...\n", greet->name);
306
	Debug ("Verify %s ...\n", greet->name);
307
308
#if defined(sun) && defined(SVR4)
309
	/* Solaris: If CONSOLE is set to /dev/console in /etc/default/login, 
310
	   then root can only login on system console */
311
312
# define SOLARIS_LOGIN_DEFAULTS "/etc/default/login"
313
314
	if (strcmp(greet->name, "root") == 0) {
315
	    char *console = NULL, *tmp = NULL;
316
	    FILE *fs;
317
318
	    if ((fs= fopen(SOLARIS_LOGIN_DEFAULTS, "r")) != NULL)
319
	    {   
320
		char str[120];
321
		while (!feof(fs))
322
		{
323
		    fgets(str, 120, fs);
324
		    if(str[0] == '#' || strlen(str) < 8)
325
			continue;
326
		    if((tmp = strstr(str, "CONSOLE=")) != NULL)
327
			console = strdup((tmp+8));
328
		}
329
		fclose(fs);
330
                if ( console != NULL && 
331
		  (strncmp(console, "/dev/console", 12) == 0) && 
332
		  (strncmp(d->name,":0",2) != 0) )
333
		{
334
                        Debug("Not on system console\n");
335
                        bzero(greet->password, strlen(greet->password));
336
             		XFree(console); 
337
	                return 0;
338
                }
339
		Xfree(console);	
340
	    }
341
	    else
342
	    {
343
		Debug("Could not open %s\n", SOLARIS_LOGIN_DEFAULTS);
344
	    }	
345
	}
346
#endif    
347
307
#ifndef USE_PAM
348
#ifndef USE_PAM
308
	p = getpwnam (greet->name);
349
	p = getpwnam (greet->name);
309
	endpwent();
350
	endpwent();
(-)4.3.0/xc/programs/xdm/netaddr.c (+39 lines)
Lines 85-90 Link Here
85
    case AF_INET:
85
    case AF_INET:
86
	*lenp = 2;
86
	*lenp = 2;
87
	return (char *)&(((struct sockaddr_in *)netaddrp)->sin_port);
87
	return (char *)&(((struct sockaddr_in *)netaddrp)->sin_port);
88
#ifdef IPv6
89
    case AF_INET6:
90
	*lenp = 2;
91
	return (char *)&(((struct sockaddr_in6 *)netaddrp)->sin6_port);
92
#endif
88
    default:
93
    default:
89
	*lenp = 0;
94
	*lenp = 0;
90
	return NULL;
95
	return NULL;
Lines 112-117 Link Here
112
    case AF_INET:
117
    case AF_INET:
113
        *lenp = sizeof (struct in_addr);
118
        *lenp = sizeof (struct in_addr);
114
        return (char *) &(((struct sockaddr_in *)netaddrp)->sin_addr);
119
        return (char *) &(((struct sockaddr_in *)netaddrp)->sin_addr);
120
#ifdef IPv6
121
    case AF_INET6:
122
    {
123
	struct in6_addr *a = &(((struct sockaddr_in6 *)netaddrp)->sin6_addr);
124
	if (IN6_IS_ADDR_V4MAPPED(a)) {
125
	    *lenp = sizeof (struct in_addr);
126
	    return ((char *) &(a->s6_addr))+12;
127
	} else {
128
	    *lenp = sizeof (struct in6_addr);
129
	    return (char *) &(a->s6_addr);
130
	}
131
    }
132
#endif
115
#endif
133
#endif
116
#ifdef DNETCONN
134
#ifdef DNETCONN
117
    case AF_DECnet:
135
    case AF_DECnet:
Lines 163-168 Link Here
163
      case AF_INET:
181
      case AF_INET:
164
        retval = FamilyInternet;
182
        retval = FamilyInternet;
165
	break;
183
	break;
184
#ifdef IPv6
185
      case AF_INET6:
186
	if (*len == sizeof(struct in_addr)) 
187
	    retval = FamilyInternet;
188
	else  
189
	    retval = FamilyInternetV6;
190
	break;
191
#endif
166
#endif
192
#endif
167
#ifdef DNETCONN
193
#ifdef DNETCONN
168
      case AF_DECnet:
194
      case AF_DECnet:
Lines 231-238 Link Here
231
	Debug ("port %d, host %d.%d.%d.%d\n",
257
	Debug ("port %d, host %d.%d.%d.%d\n",
232
		(p[0] << 8) + p[1], t[0], t[1], t[2], t[3]);
258
		(p[0] << 8) + p[1], t[0], t[1], t[2], t[3]);
233
	break;
259
	break;
260
#endif
261
#ifdef IPv6
262
    case AF_INET6:
263
    {
264
	char astr[INET6_ADDRSTRLEN] = "";
265
	
266
	inet_ntop(a->sa_family, &((struct sockaddr_in6 *) a)->sin6_addr,
267
	  astr, sizeof(astr));
268
	p = (unsigned char *) &((struct sockaddr_in6 *) a)->sin6_port;
269
		
270
	Debug ("port %d, host %s\n", (p[0] << 8) + p[1], astr);
271
	break;
234
    }
272
    }
235
#endif
273
#endif
274
    }
236
}
275
}
237
#endif
276
#endif
238
277
(-)4.3.0/xc/programs/xdm/resource.c (-5 / +66 lines)
Lines 58-63 Link Here
58
char	*accessFile;
58
char	*accessFile;
59
char	**exportList;
59
char	**exportList;
60
char	*randomFile;
60
char	*randomFile;
61
#ifdef DEV_RANDOM
62
char	*randomDevice;
63
#endif
61
char	*greeterLib;
64
char	*greeterLib;
62
char	*willing;
65
char	*willing;
63
int	choiceTimeout;	/* chooser choice timeout */
66
int	choiceTimeout;	/* chooser choice timeout */
Lines 72-77 Link Here
72
 * parameters set util/imake.includes/site.def (or *.macros in that directory
75
 * parameters set util/imake.includes/site.def (or *.macros in that directory
73
 * if it is server-specific).  DO NOT CHANGE THESE DEFINITIONS!
76
 * if it is server-specific).  DO NOT CHANGE THESE DEFINITIONS!
74
 */
77
 */
78
#ifndef __EMX__
75
#ifndef DEF_SERVER_LINE 
79
#ifndef DEF_SERVER_LINE 
76
#define DEF_SERVER_LINE ":0 local /usr/bin/X11/X :0"
80
#define DEF_SERVER_LINE ":0 local /usr/bin/X11/X :0"
77
#endif
81
#endif
Lines 119-133 Link Here
119
#define DEF_ACCESS_FILE	""
123
#define DEF_ACCESS_FILE	""
120
#endif
124
#endif
121
#ifndef DEF_RANDOM_FILE
125
#ifndef DEF_RANDOM_FILE
122
# ifdef linux
126
#define DEF_RANDOM_FILE "/dev/mem"
123
#  define DEF_RANDOM_FILE "/dev/urandom"
124
# else
125
#  define DEF_RANDOM_FILE "/dev/mem"
126
# endif
127
#endif
127
#endif
128
#ifndef DEF_GREETER_LIB
128
#ifndef DEF_GREETER_LIB
129
#define DEF_GREETER_LIB "/usr/lib/X11/xdm/libXdmGreet.so"
129
#define DEF_GREETER_LIB "/usr/lib/X11/xdm/libXdmGreet.so"
130
#endif
130
#endif
131
#else
132
/* unfortunately I have to declare all of them, because there is a limit
133
 * in argument size in OS/2
134
 * but everything needs to be fixed again
135
 */
136
#define DEF_SERVER_LINE ":0 local /XFree86/bin/X :0"
137
#ifndef XRDB_PROGRAM
138
#define XRDB_PROGRAM "/XFree86/bin/xrdb"
139
#endif
140
#ifndef DEF_SESSION
141
#define DEF_SESSION "/XFree86/bin/xterm -ls"
142
#endif
143
#ifndef DEF_USER_PATH
144
#define DEF_USER_PATH "c:\\os2;c:\\os2\apps;\\XFree86\\bin"
145
#endif
146
#ifndef DEF_SYSTEM_PATH
147
#define DEF_SYSTEM_PATH "c:\\os2;c:\\os2\apps;\\XFree86\\bin"
148
#endif
149
#ifndef DEF_SYSTEM_SHELL
150
#define DEF_SYSTEM_SHELL "sh"
151
#endif
152
#ifndef DEF_FAILSAFE_CLIENT
153
#define DEF_FAILSAFE_CLIENT "/XFree86/bin/xterm"
154
#endif
155
#ifndef DEF_XDM_CONFIG
156
#define DEF_XDM_CONFIG "/XFree86/lib/X11/xdm/xdm-config"
157
#endif
158
#ifndef DEF_CHOOSER
159
#define DEF_CHOOSER "/XFree86/lib/X11/xdm/chooser"
160
#endif
161
#ifndef DEF_AUTH_NAME
162
#ifdef HASXDMAUTH
163
#define DEF_AUTH_NAME	"XDM-AUTHORIZATION-1 MIT-MAGIC-COOKIE-1"
164
#else
165
#define DEF_AUTH_NAME	"MIT-MAGIC-COOKIE-1"
166
#endif
167
#endif
168
#ifndef DEF_AUTH_DIR
169
#define DEF_AUTH_DIR "/XFree86/lib/X11/xdm"
170
#endif
171
#ifndef DEF_USER_AUTH_DIR
172
#define DEF_USER_AUTH_DIR	"/tmp"
173
#endif
174
#ifndef DEF_KEY_FILE
175
#define DEF_KEY_FILE	""
176
#endif
177
#ifndef DEF_ACCESS_FILE
178
#define DEF_ACCESS_FILE	""
179
#endif
180
#ifndef DEF_RANDOM_FILE
181
#define DEF_RANDOM_FILE ""
182
#endif
183
#ifndef DEF_GREETER_LIB
184
#define DEF_GREETER_LIB "/XFree86/lib/X11/xdm/libXdmGreet.so"
185
#endif
186
187
#endif /* __EMX__ */
131
188
132
#define DEF_UDP_PORT	"177"	    /* registered XDMCP port, dont change */
189
#define DEF_UDP_PORT	"177"	    /* registered XDMCP port, dont change */
133
190
Lines 165-170 Link Here
165
				""} ,
222
				""} ,
166
{ "randomFile",	"RandomFile",	DM_STRING,	&randomFile,
223
{ "randomFile",	"RandomFile",	DM_STRING,	&randomFile,
167
				DEF_RANDOM_FILE} ,
224
				DEF_RANDOM_FILE} ,
225
#ifdef DEV_RANDOM
226
{ "randomDevice", "RandomDevice", DM_STRING,	&randomDevice,
227
				DEV_RANDOM} ,
228
#endif
168
{ "greeterLib",	"GreeterLib",	DM_STRING,	&greeterLib,
229
{ "greeterLib",	"GreeterLib",	DM_STRING,	&greeterLib,
169
				DEF_GREETER_LIB} ,
230
				DEF_GREETER_LIB} ,
170
{ "choiceTimeout","ChoiceTimeout",DM_INT,	(char **) &choiceTimeout,
231
{ "choiceTimeout","ChoiceTimeout",DM_INT,	(char **) &choiceTimeout,
(-)4.3.0/xc/programs/xdm/session.c (-1 / +14 lines)
Lines 54-59 Link Here
54
#ifdef SECURE_RPC
54
#ifdef SECURE_RPC
55
# include <rpc/rpc.h>
55
# include <rpc/rpc.h>
56
# include <rpc/key_prot.h>
56
# include <rpc/key_prot.h>
57
extern int key_setnet(struct key_netstarg *arg); 
57
#endif
58
#endif
58
#ifdef K5AUTH
59
#ifdef K5AUTH
59
# include <krb5/krb5.h>
60
# include <krb5/krb5.h>
Lines 68-74 Link Here
68
69
69
static	int	runAndWait (char **args, char **environ);
70
static	int	runAndWait (char **args, char **environ);
70
71
71
#if defined(CSRG_BASED) || defined(__osf__) || defined(__DARWIN__) || defined(__QNXNTO__)
72
#if defined(CSRG_BASED) || defined(__osf__) || defined(__DARWIN__) || defined(__QNXNTO__) || defined(sun)
72
#include <sys/types.h>
73
#include <sys/types.h>
73
#include <grp.h>
74
#include <grp.h>
74
#else
75
#else
Lines 79-87 Link Here
79
#endif
80
#endif
80
81
81
#ifdef USESHADOW
82
#ifdef USESHADOW
83
#if defined(SVR4)
84
#include <shadow.h>
85
#else
82
extern	struct spwd	*getspnam(GETSPNAM_ARGS);
86
extern	struct spwd	*getspnam(GETSPNAM_ARGS);
83
extern	void	endspent(void);
87
extern	void	endspent(void);
84
#endif
88
#endif
89
#endif
85
#if defined(CSRG_BASED)
90
#if defined(CSRG_BASED)
86
#include <pwd.h>
91
#include <pwd.h>
87
#include <unistd.h>
92
#include <unistd.h>
Lines 652-657 Link Here
652
	    char    netname[MAXNETNAMELEN+1], secretkey[HEXKEYBYTES+1];
657
	    char    netname[MAXNETNAMELEN+1], secretkey[HEXKEYBYTES+1];
653
	    int	    nameret, keyret;
658
	    int	    nameret, keyret;
654
	    int	    len;
659
	    int	    len;
660
	    struct  key_netstarg netst;
655
	    int     key_set_ok = 0;
661
	    int     key_set_ok = 0;
656
662
657
	    nameret = getnetname (netname);
663
	    nameret = getnetname (netname);
Lines 662-667 Link Here
662
	    keyret = getsecretkey(netname,secretkey,passwd);
668
	    keyret = getsecretkey(netname,secretkey,passwd);
663
	    Debug ("getsecretkey returns %d, key length %d\n",
669
	    Debug ("getsecretkey returns %d, key length %d\n",
664
		    keyret, strlen (secretkey));
670
		    keyret, strlen (secretkey));
671
	    memcpy(&(netst.st_priv_key), secretkey, HEXKEYBYTES);
672
	    netst.st_netname = strdup(netname);
673
	    memset(netst.st_pub_key, 0, HEXKEYBYTES);
674
            if (key_setnet(&netst) < 0) {
675
		Debug("Could not set secret key.\n");
676
            }
677
	    free(netst.st_netname);	    
665
	    /* is there a key, and do we have the right password? */
678
	    /* is there a key, and do we have the right password? */
666
	    if (keyret == 1)
679
	    if (keyret == 1)
667
	    {
680
	    {
(-)4.3.0/xc/programs/xdm/socket.c (-38 / +415 lines)
Lines 2-7 Link Here
2
/*
2
/*
3
3
4
Copyright 1988, 1998  The Open Group
4
Copyright 1988, 1998  The Open Group
5
Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
5
6
6
Permission to use, copy, modify, distribute, and sell this software and its
7
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
documentation for any purpose is hereby granted without fee, provided that
Lines 15-29 Link Here
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
22
OTHER DEALINGS IN THE SOFTWARE.
22
23
23
Except as contained in this notice, the name of The Open Group shall
24
Except as contained in this notice, the name of a copyright holder shall
24
not be used in advertising or otherwise to promote the sale, use or
25
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
26
other dealings in this Software without prior written authorization
26
from The Open Group.
27
from the copyright holder.
27
28
28
*/
29
*/
29
/* $XFree86: xc/programs/xdm/socket.c,v 3.10 2001/12/14 20:01:24 dawes Exp $ */
30
/* $XFree86: xc/programs/xdm/socket.c,v 3.10 2001/12/14 20:01:24 dawes Exp $ */
Lines 52-60 Link Here
52
#endif
53
#endif
53
#endif
54
#endif
54
#include <netdb.h>
55
#include <netdb.h>
56
#include <arpa/inet.h>
55
57
56
57
extern int	xdmcpFd;
58
extern int	chooserFd;
58
extern int	chooserFd;
59
59
60
extern FD_TYPE	WellKnownSocketsMask;
60
extern FD_TYPE	WellKnownSocketsMask;
Lines 63-101 Link Here
63
void
63
void
64
CreateWellKnownSockets (void)
64
CreateWellKnownSockets (void)
65
{
65
{
66
    struct sockaddr_in	sock_addr;
66
    char *name = localHostname ();
67
    char *name;
68
69
    if (request_port == 0)
70
	    return;
71
    Debug ("creating socket %d\n", request_port);
72
    xdmcpFd = socket (AF_INET, SOCK_DGRAM, 0);
73
    if (xdmcpFd == -1) {
74
	LogError ("XDMCP socket creation failed, errno %d\n", errno);
75
	return;
76
    }
77
    name = localHostname ();
78
    registerHostname (name, strlen (name));
67
    registerHostname (name, strlen (name));
79
    RegisterCloseOnFork (xdmcpFd);
80
    /* zero out the entire structure; this avoids 4.4 incompatibilities */
81
    bzero ((char *) &sock_addr, sizeof (sock_addr));
82
#ifdef BSD44SOCKETS
83
    sock_addr.sin_len = sizeof(sock_addr);
84
#endif
85
    sock_addr.sin_family = AF_INET;
86
    sock_addr.sin_port = htons ((short) request_port);
87
    sock_addr.sin_addr.s_addr = htonl (INADDR_ANY);
88
    if (bind (xdmcpFd, (struct sockaddr *)&sock_addr, sizeof (sock_addr)) == -1)
89
    {
90
	LogError ("error %d binding socket address %d\n", errno, request_port);
91
	close (xdmcpFd);
92
	xdmcpFd = -1;
93
	return;
94
    }
95
    WellKnownSocketsMax = xdmcpFd;
96
    FD_SET (xdmcpFd, &WellKnownSocketsMask);
97
68
69
#ifdef IPv6
70
    chooserFd = socket (AF_INET6, SOCK_STREAM, 0);
71
#else
98
    chooserFd = socket (AF_INET, SOCK_STREAM, 0);
72
    chooserFd = socket (AF_INET, SOCK_STREAM, 0);
73
#endif
99
    Debug ("Created chooser socket %d\n", chooserFd);
74
    Debug ("Created chooser socket %d\n", chooserFd);
100
    if (chooserFd == -1)
75
    if (chooserFd == -1)
101
    {
76
    {
Lines 113-129 Link Here
113
    char	*addr,
88
    char	*addr,
114
    int		*lenp)
89
    int		*lenp)
115
{
90
{
91
#ifdef IPv6
92
    struct sockaddr_storage in_addr;
93
#else
116
    struct sockaddr_in	in_addr;
94
    struct sockaddr_in	in_addr;
95
#endif
117
    int			len;
96
    int			len;
97
    int			retval = 0;
118
98
119
    len = sizeof in_addr;
99
    len = sizeof in_addr;
100
    if (chooserFd < 0) 
101
	return -1;	/* TODO check other listening sockets */
120
    if (getsockname (chooserFd, (struct sockaddr *)&in_addr, (void *)&len) < 0)
102
    if (getsockname (chooserFd, (struct sockaddr *)&in_addr, (void *)&len) < 0)
121
	return -1;
103
	return -1;
122
    Debug ("Chooser socket port: %d\n", ntohs(in_addr.sin_port));
104
#ifdef IPv6
123
    memmove( addr, (char *) &in_addr, len);
105
    if (in_addr.ss_family == AF_INET6)
106
	Debug ("Chooser socket port: %d (IPv6)\n", 
107
	  ntohs(((struct sockaddr_in6 *) &in_addr)->sin6_port));
108
    else
109
#endif
110
	Debug ("Chooser socket port: %d\n", 
111
	  ntohs(((struct sockaddr_in *) &in_addr)->sin_port));
112
    if (*lenp < len)  
113
	retval = -2;
114
    else
115
	memmove( addr, (char *) &in_addr, len);
124
    *lenp = len;
116
    *lenp = len;
125
117
126
    return 0;
118
    return retval;
119
}
120
121
static int
122
CreateListeningSocket (struct sockaddr *sock_addr, int salen)
123
{
124
    int fd;
125
    const char *addrstring = "unknown";
126
#ifdef IPv6
127
    char addrbuf[INET6_ADDRSTRLEN];
128
#endif
129
130
    if (request_port == 0)
131
	    return -1;
132
133
    if (debugLevel > 0) {
134
#ifdef IPv6
135
	void *ipaddr;
136
	if (sock_addr->sa_family == AF_INET6) {
137
	    ipaddr = & ((struct sockaddr_in6 *) sock_addr)->sin6_addr;
138
	} else {
139
	    ipaddr = & ((struct sockaddr_in *) sock_addr)->sin_addr;
140
	}
141
	addrstring =
142
	  inet_ntop(sock_addr->sa_family, ipaddr, addrbuf, sizeof(addrbuf));
143
144
#else
145
	addrstring = inet_ntoa(((struct sockaddr_in *) sock_addr)->sin_addr);
146
#endif
147
148
	Debug ("creating socket to listen on port %d of address %s\n", 
149
	  request_port,addrstring);
150
    }
151
152
    fd = socket (sock_addr->sa_family, SOCK_DGRAM, 0);
153
154
    if (fd == -1) {
155
	LogError ("XDMCP socket creation failed, errno %d\n", errno);
156
	return fd;
157
    }
158
    RegisterCloseOnFork (fd);
159
160
    if (bind (fd, sock_addr, salen) == -1)
161
    {
162
	LogError ("error %d binding socket address %d\n", errno, request_port);
163
	close (fd);
164
	fd = -1;
165
	return fd;
166
    }
167
    if (fd > WellKnownSocketsMax)
168
	WellKnownSocketsMax = fd;
169
    FD_SET (fd, &WellKnownSocketsMask);
170
    return fd;
171
}
172
173
struct socklist {
174
    struct socklist *	next;
175
    struct socklist *	mcastgroups;
176
    struct sockaddr *	addr;
177
    int			salen;
178
    int			addrlen;
179
    int			fd;
180
    int			ref;	/* referenced bit - see UpdateListenSockets */
181
};
182
183
static struct socklist *listensocks;
184
185
static void
186
DestroyListeningSocket (struct socklist *s)
187
{
188
    if (s->fd >= 0) {
189
	FD_CLR (s->fd, &WellKnownSocketsMask);
190
	close(s->fd);
191
	s->fd = -1;
192
    }
193
    if (s->addr) {
194
	free(s->addr);
195
	s->addr = NULL;
196
    }
197
    if (s->mcastgroups) {
198
	struct socklist *g, *n;
199
200
	for (g = s->mcastgroups; g != NULL; g = n) {
201
	    n = g->next;
202
	    if (g->addr)
203
		free(g->addr);
204
	    free(g);
205
	}
206
	s->mcastgroups = NULL;
207
    }
208
}
209
210
static struct socklist*
211
FindInList(struct socklist *list, ARRAY8Ptr addr)
212
{
213
    struct socklist *s;
214
215
    for (s = list; s != NULL; s = s->next) {
216
	if (s->addrlen == addr->length) {
217
	    char *addrdata;
218
219
	    switch (s->addr->sa_family) {
220
	    case AF_INET:
221
		addrdata = (char *)
222
		  &(((struct sockaddr_in *)s->addr)->sin_addr.s_addr);
223
		break;
224
#ifdef IPv6
225
	    case AF_INET6:
226
		addrdata = (char *)
227
		  &(((struct sockaddr_in6 *)s->addr)->sin6_addr.s6_addr);
228
		break;
229
#endif
230
	    default:
231
		/* Unrecognized address family */
232
		continue;
233
	    }	
234
	    if (memcmp(addrdata, addr->data, addr->length) == 0) {
235
		return s;
236
	    }
237
	}
238
    }
239
    return NULL;
240
}
241
242
static struct socklist *
243
CreateSocklistEntry(ARRAY8Ptr addr)
244
{
245
    struct socklist *s = malloc (sizeof(struct socklist));
246
    if (s == NULL) 
247
	LogOutOfMem("CreateSocklistEntry");
248
249
    bzero(s, sizeof(struct socklist));
250
251
    if (addr->length == 4) /* IPv4 */ 
252
    {
253
	struct sockaddr_in *sin;
254
	sin = malloc (sizeof(struct sockaddr_in));
255
	if (sin == NULL) 
256
	    LogOutOfMem("CreateSocklistEntry");
257
	s->addr = (struct sockaddr *) sin;
258
259
	bzero (sin, sizeof (struct sockaddr_in));
260
#ifdef BSD44SOCKETS
261
	sin->sin_len = sizeof(struct sockaddr_in);
262
#endif
263
	s->salen = sizeof(struct sockaddr_in);
264
	s->addrlen = sizeof(struct in_addr);
265
	sin->sin_family = AF_INET;
266
	sin->sin_port = htons ((short) request_port);
267
	memcpy(&sin->sin_addr, addr->data, addr->length);
268
    }
269
#ifdef IPv6
270
    else if (addr->length == 16) /* IPv6 */
271
    {
272
	struct sockaddr_in6 *sin6;
273
	sin6 = malloc (sizeof(struct sockaddr_in6));
274
	if (sin6 == NULL) 
275
	    LogOutOfMem("CreateSocklistEntry");
276
	s->addr = (struct sockaddr *) sin6;
277
278
	bzero (sin6, sizeof (struct sockaddr_in6));
279
#ifdef SIN6_LEN
280
	sin6->sin6_len = sizeof(struct sockaddr_in6);
281
#endif
282
	s->salen = sizeof(struct sockaddr_in6);
283
	s->addrlen = sizeof(struct in6_addr);
284
	sin6->sin6_family = AF_INET6;
285
	sin6->sin6_port = htons ((short) request_port);
286
	memcpy(&sin6->sin6_addr, addr->data, addr->length);
287
    } 
288
#endif
289
    else {
290
	/* Unknown address type */
291
	free(s);
292
	s = NULL;
293
    }
294
    return s;
295
}
296
297
static void 
298
UpdateListener(ARRAY8Ptr addr, void **closure)
299
{
300
    struct socklist *s;
301
    ARRAY8 tmpaddr;
302
303
    *closure = NULL;
304
305
    if (addr == NULL || addr->length == 0) {
306
#ifdef IPv6
307
	struct in6_addr in6 = in6addr_any;
308
	tmpaddr.length = sizeof(in6);
309
	tmpaddr.data = (CARD8Ptr) &in6;
310
#else
311
	struct in_addr in;
312
	in.s_addr = htonl (INADDR_ANY);
313
	tmpaddr.length = sizeof(in);
314
	tmpaddr.data = (CARD8Ptr) &in;
315
#endif
316
	addr = &tmpaddr;
317
    }
318
    
319
    s = FindInList(listensocks, addr);
320
321
    if (s) {
322
	*closure = (void *) s;
323
	s->ref = 1;
324
	return;
325
    }
326
    
327
    s = CreateSocklistEntry(addr);
328
329
    if (s == NULL)
330
	return;
331
332
    s->fd = CreateListeningSocket(s->addr, s->salen);
333
    if (s->fd < 0) {
334
	free(s->addr);
335
	free(s);
336
	return;
337
    }
338
    s->ref = 1;
339
    s->next = listensocks;
340
    listensocks = s;
341
    *closure = (void *) s;
342
}
343
344
#define JOIN_MCAST_GROUP 0
345
#define LEAVE_MCAST_GROUP 1
346
347
static void
348
ChangeMcastMembership(struct socklist *s, struct socklist *g, int op)
349
{
350
    int sockopt;
351
352
    switch (s->addr->sa_family) 
353
    {
354
        case AF_INET:
355
        {
356
	    struct ip_mreq mreq;
357
	    memcpy(&mreq.imr_multiaddr, 
358
	      &((struct sockaddr_in *) g->addr)->sin_addr, 
359
	      sizeof(struct in_addr));
360
	    memcpy(&mreq.imr_interface,
361
	      &((struct sockaddr_in *) s->addr)->sin_addr, 
362
	      sizeof(struct in_addr));
363
	    if (op == JOIN_MCAST_GROUP) {
364
		sockopt = IP_ADD_MEMBERSHIP;
365
	    } else {
366
		sockopt = IP_DROP_MEMBERSHIP;
367
	    }
368
	    if (setsockopt(s->fd, IPPROTO_IP, sockopt,
369
	      &mreq, sizeof(mreq)) < 0) {
370
		LogError ("XDMCP socket multicast %s to %s failed, errno %d\n",
371
		  (op == JOIN_MCAST_GROUP) ? "join" : "drop",
372
		  inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr),
373
		  errno);
374
		return;
375
	    } else if (debugLevel > 0) {
376
		Debug ("XDMCP socket multicast %s to %s succeeded\n", 
377
		  (op == JOIN_MCAST_GROUP) ? "join" : "drop",
378
		  inet_ntoa(((struct sockaddr_in *) g->addr)->sin_addr));
379
	    }
380
	}
381
#ifdef IPv6
382
	case AF_INET6:
383
	{
384
	    struct ipv6_mreq mreq6;
385
	    memcpy(&mreq6.ipv6mr_multiaddr, 
386
	      &((struct sockaddr_in6 *) g->addr)->sin6_addr, 
387
	      sizeof(struct in6_addr));
388
	    mreq6.ipv6mr_interface = 0;  /* TODO: fix this */
389
	    if (op == JOIN_MCAST_GROUP) {
390
		sockopt = IPV6_ADD_MEMBERSHIP;
391
	    } else {
392
		sockopt = IPV6_DROP_MEMBERSHIP;
393
	    }
394
	    if (setsockopt(s->fd, IPPROTO_IPV6, sockopt,
395
	      &mreq6, sizeof(mreq6)) < 0) {
396
		int saveerr = errno;
397
		char addrbuf[INET6_ADDRSTRLEN];
398
399
		inet_ntop(s->addr->sa_family, 
400
		  &((struct sockaddr_in6 *) g->addr)->sin6_addr,
401
		  addrbuf, sizeof(addrbuf));
402
403
		LogError ("XDMCP socket multicast %s to %s failed, errno %d\n",
404
		  (op == JOIN_MCAST_GROUP) ? "join" : "drop", addrbuf,
405
		  saveerr);
406
		return;
407
	    } else if (debugLevel > 0) {
408
		char addrbuf[INET6_ADDRSTRLEN];
409
410
		inet_ntop(s->addr->sa_family, 
411
		  &((struct sockaddr_in6 *) g->addr)->sin6_addr,
412
		  addrbuf, sizeof(addrbuf));
413
414
		Debug ("XDMCP socket multicast %s to %s succeeded\n", 
415
		  (op == JOIN_MCAST_GROUP) ? "join" : "drop", addrbuf);
416
	    }
417
	}
418
#endif
419
    }
420
}
421
422
static void 
423
UpdateMcastGroup(ARRAY8Ptr addr, void **closure)
424
{
425
    struct socklist *s = (struct socklist *) *closure;
426
    struct socklist *g;
427
	
428
    g = FindInList(s->mcastgroups, addr);
429
430
    if (g) { /* Already in the group, mark & continue */
431
	g->ref = 1;
432
	return;
433
    }
434
435
    /* Need to join the group */
436
    g = CreateSocklistEntry(addr);
437
    if (g == NULL)
438
	return;
439
440
    ChangeMcastMembership(s, g, JOIN_MCAST_GROUP);
441
}
442
443
/* Open or close listening sockets to match the current settings read in
444
   from the access database. */
445
void UpdateListenSockets (void)
446
{
447
    struct socklist *s, *g, **ls, **lg, *ns, *ng;
448
    void *tmpPtr = NULL;
449
450
    /* Clear Ref bits - any not marked by UpdateCallback will be closed */
451
    for (s = listensocks; s != NULL; s = s->next) {
452
	s->ref = 0;
453
	for (g = s->mcastgroups; g != NULL ; g = g->next) {
454
	    g->ref = 0;
455
	}
456
    }
457
    ForEachListenAddr(UpdateListener, UpdateMcastGroup, &tmpPtr);
458
    for (s = listensocks, ls = &listensocks; s != NULL; s = ns) {
459
	ns = s->next;
460
	if (s->ref == 0) {
461
	    DestroyListeningSocket(s);
462
	    *ls = s->next;
463
	    free(s);
464
	} else {
465
	    ls = &(s->next);
466
	    for (lg = &s->mcastgroups, g = *lg; g != NULL ; g = ng) {
467
		ng = g->next;
468
		if (g->ref == 0) {
469
		    ChangeMcastMembership(s,g,LEAVE_MCAST_GROUP);
470
		    *lg = g->next;
471
		    free(g);
472
		} else {
473
		    lg = &(g->next);
474
		}
475
	    }
476
	}
477
    }    
478
}
479
480
/* Close all additional listening sockets beyond the basic chooserFd and
481
   remove them from the WellKnownSocketsMask. */
482
void CloseListenSockets (void)
483
{
484
    struct socklist *s, *n;
485
486
    for (s = listensocks; s != NULL; s = n) {
487
	n = s->next;
488
	DestroyListeningSocket(s);
489
	free(s);
490
    }
491
    listensocks = NULL;
492
}
493
494
/* For each listening socket identified in readmask, process the incoming
495
   XDMCP request */
496
void ProcessListenSockets (fd_set *readmask)
497
{
498
    struct socklist *s;
499
500
    for (s = listensocks; s != NULL; s = s->next) {
501
	if (FD_ISSET(s->fd, readmask))
502
	    ProcessRequestSocket(s->fd);
503
    }    
127
}
504
}
128
505
129
#endif /* !STREAMSCONN */
506
#endif /* !STREAMSCONN */
(-)4.3.0/xc/programs/xdm/streams.c (+19 lines)
Lines 146-150 Link Here
146
    return retval;
146
    return retval;
147
}
147
}
148
148
149
/* TODO: Implement support for controlling which interfaces are listened on
150
   and for listening to multicast addresses.  See the sockets equivalent in
151
   sockets.c for details. */
152
153
void UpdateListenSockets (void)
154
{
155
    return;
156
}
157
158
void CloseListenSockets (void)
159
{
160
    return;
161
}
162
163
void ProcessListenSockets (fd_set *readmask)
164
{
165
    return;
166
}
167
149
#endif /* STREAMSCONN */
168
#endif /* STREAMSCONN */
150
#endif /* XDMCP */
169
#endif /* XDMCP */
(-)4.3.0/xc/programs/xdm/xdm.man (-1 / +77 lines)
Lines 92-97 Link Here
92
.I chooser
92
.I chooser
93
or X terminals themselves.
93
or X terminals themselves.
94
.PP
94
.PP
95
.I Xdm
96
can be configured to ignore BroadcastQuery messages from selected hosts.
97
This is useful when you don't want the host to appear in menus produced
98
by
99
.I chooser
100
or X terminals themselves.
101
.PP
95
Because
102
Because
96
.I xdm
103
.I xdm
97
provides the first interface that users will see, it is designed to be
104
provides the first interface that users will see, it is designed to be
Lines 144-150 Link Here
144
At the end of the session, the \fIXreset\fP script is run to clean up,
151
At the end of the session, the \fIXreset\fP script is run to clean up,
145
the X server is reset, and the cycle starts over.
152
the X server is reset, and the cycle starts over.
146
.PP
153
.PP
147
The file \fI__projectroot__/lib/X11/xdm/xdm-errors\fP will contain error 
154
The file \fI __projectroot__/lib/X11/xdm/xdm-errors\fP will contain error 
148
messages from
155
messages from
149
.I xdm
156
.I xdm
150
and anything output to stderr by \fIXsetup, Xstartup, Xsession\fP
157
and anything output to stderr by \fIXsetup, Xstartup, Xsession\fP
Lines 349-354 Link Here
349
A file to checksum to generate the seed of authorization keys.
356
A file to checksum to generate the seed of authorization keys.
350
This should be a file that changes frequently.
357
This should be a file that changes frequently.
351
The default is \fI/dev/mem\fP.
358
The default is \fI/dev/mem\fP.
359
#ifdef DEV_RANDOM
360
.IP \fBDisplayManager.randomDevice\fP
361
A file to read 8 bytes from to generate the seed of authorization keys.
362
The default is \fI DEV_RANDOM \fP. If this file cannot be read, or if a 
363
read blocks for more than 5 seconds, xdm falls back to using a checksum 
364
of \fBDisplayManager.randomFile\fP to generate the seed.
365
#endif
352
.IP \fBDisplayManager.greeterLib\fP
366
.IP \fBDisplayManager.greeterLib\fP
353
On systems that support a dynamically-loadable greeter library, the
367
On systems that support a dynamically-loadable greeter library, the
354
name of the library.  The default is
368
name of the library.  The default is
Lines 632-637 Link Here
632
This can be used to prevent an xdm server from appearing on
646
This can be used to prevent an xdm server from appearing on
633
menus based on Broadcast queries.
647
menus based on Broadcast queries.
634
.PP
648
.PP
649
To only respond to Direct queries for a host or pattern,
650
it can be followed by the optional ``NOBROADCAST'' keyword.
651
This can be used to prevent an xdm server from appearing on
652
menus based on Broadcast queries.
653
.PP
635
An Indirect entry also contains a host name or pattern,
654
An Indirect entry also contains a host name or pattern,
636
but follows it with a list of
655
but follows it with a list of
637
host names or macros to which indirect queries should be sent.
656
host names or macros to which indirect queries should be sent.
Lines 686-691 Link Here
686
!xtra.lcs.mit.edu	dummy	#disallow indirect access
705
!xtra.lcs.mit.edu	dummy	#disallow indirect access
687
*.lcs.mit.edu	%HOSTS	#all others get to choose
706
*.lcs.mit.edu	%HOSTS	#all others get to choose
688
.fi
707
.fi
708
.PP
709
If compiled with IPv6 support, multicast address groups may also be included 
710
in the list of addresses indirect queries are set to.  Multicast addresses 
711
may be followed by an optional / character and hop count. If no hop count is 
712
specified, the multicast hop count defaults to 1, keeping the packet on the 
713
local network. For IPv4 multicasting, the hop count is used as the TTL.
714
.PP
715
Examples: 
716
.LP
717
.ta 2.1i 4.5i
718
.nf
719
rincewind.sample.net	ff02::1	#IPv6 Multicast to ff02::1
720
		#with a hop count of 1
721
ponder.sample.net	CHOOSER 239.192.1.1/16  #Offer a menu of hosts
722
		#who respond to IPv4 Multicast 
723
		# to 239.192.1.1 with a TTL of 16
724
.fi
689
.SH CHOOSER
725
.SH CHOOSER
690
.PP
726
.PP
691
For X terminals that do not offer a host menu for use with Broadcast
727
For X terminals that do not offer a host menu for use with Broadcast
Lines 725-730 Link Here
725
\fBDisplayManager.choiceTimeout\fP seconds) and forwards the request
761
\fBDisplayManager.choiceTimeout\fP seconds) and forwards the request
726
to the chosen host, which starts a session on that display.
762
to the chosen host, which starts a session on that display.
727
.\"
763
.\"
764
.SH LISTEN
765
The following configuration directive is also defined for the Xaccess
766
configuration file:
767
.IP "\fBLISTEN\fP \fIinterface\fP \fI[list of multicast group addresses]\fP"
768
\fIinterface\fP may be a hostname or IP addresss representing a
769
network interface on this machine, or the wildcard * to represent all
770
available network interfaces.
771
.PP
772
If one or more LISTEN lines are specified, xdm only listens for XDMCP
773
connections on the specified interfaces. If multicast group addresses
774
are listed on a listen line, xdm joins the multicast groups on the
775
given interface.
776
.PP
777
If no LISTEN lines are given, the original behavior of listening on
778
all interfaces is preserved for backwards compatibility.
779
Additionally, if no LISTEN is specified, xdm joins the default XDMCP
780
IPv6 multicast group, when compiled with IPv6 support.
781
.PP
782
To disable listening for XDMCP connections altogther, a line of LISTEN
783
with no addresses may be specified, or the previously supported method
784
of setting DisplayManager.requestPort to 0 may be used.
785
.PP
786
Examples: 
787
.ta 2i 4i
788
.nf
789
LISTEN * ff02::1	# Listen on all interfaces and to the 
790
	# ff02::1 IPv6 multicast group.
791
LISTEN 10.11.12.13	# Listen only on this interface, as long 
792
	# as no other listen directives appear in 
793
	# file. 
794
.fi
728
.SH "LOCAL SERVER SPECIFICATION"
795
.SH "LOCAL SERVER SPECIFICATION"
729
.PP
796
.PP
730
The resource \fBDisplayManager.servers\fP gives a server specification
797
The resource \fBDisplayManager.servers\fP gives a server specification
Lines 830-835 Link Here
830
	SHELL	the value of \fBDisplayManager.\fP\fIDISPLAY\fP\fB.systemShell\fP
897
	SHELL	the value of \fBDisplayManager.\fP\fIDISPLAY\fP\fB.systemShell\fP
831
	XAUTHORITY	may be set to an authority file
898
	XAUTHORITY	may be set to an authority file
832
.fi
899
.fi
900
.IP "\fBxlogin.Login.allowRootLogin\fP"
901
If set to ``false'', don't allow root (and any other user with uid = 0) to
902
log in directly.
903
The default is ``true''.
904
.IP "\fBxlogin.Login.allowNullPasswd\fP"
905
If set to ``true'', allow an otherwise failing password match to succeed
906
if the account does not require a password at all.
907
The default is ``false'', so only users that have passwords assigned can
908
log in.
833
.PP
909
.PP
834
Note that since \fIxdm\fP grabs the keyboard, any other windows will not be
910
Note that since \fIxdm\fP grabs the keyboard, any other windows will not be
835
able to receive keyboard input.  They will be able to interact with
911
able to receive keyboard input.  They will be able to interact with
(-)4.3.0/xc/programs/xdm/xdmcp.c (-77 / +323 lines)
Lines 26-32 Link Here
26
from The Open Group.
26
from The Open Group.
27
27
28
*/
28
*/
29
/* $XFree86: xc/programs/xdm/xdmcp.c,v 3.21 2002/12/10 22:37:17 tsi Exp $ */
29
/* $Id: xc/programs/xdm/xdmcp.c,v 3.21 2002/12/10 22:37:17 tsi Exp $ */
30
30
31
/*
31
/*
32
 * xdm - display manager daemon
32
 * xdm - display manager daemon
Lines 55-68 Link Here
55
#include	<un.h>
55
#include	<un.h>
56
#endif
56
#endif
57
#endif
57
#endif
58
#if defined(__SVR4) && defined(__sun)
59
	/*
60
	 * make sure we get the resolver's version of gethostbyname
61
	 * otherwise we may not get all the addresses!
62
	 */
63
#define gethostbyname res_gethostbyname
64
#endif
65
#include	<netdb.h>
58
#include	<netdb.h>
59
#ifdef IPv6
60
#include	<arpa/inet.h>
61
#endif
66
62
67
#include <time.h>
63
#include <time.h>
68
#define Time_t time_t
64
#define Time_t time_t
Lines 72-98 Link Here
72
/*
68
/*
73
 * misc externs
69
 * misc externs
74
 */
70
 */
75
extern int Rescan, ChildReady;
71
extern volatile int Rescan;
76
extern int sourceAddress;
72
extern int sourceAddress, ChildReady;
77
73
78
/*
74
/*
79
 * Forward reference
75
 * Forward reference
80
 */
76
 */
81
static void broadcast_respond (struct sockaddr *from, int fromlen, int length);
77
static void broadcast_respond (struct sockaddr *from, int fromlen, int length, int fd);
82
static void forward_respond (struct sockaddr *from, int fromlen, int length);
78
static void forward_respond (struct sockaddr *from, int fromlen, int length, int fd);
83
static void manage (struct sockaddr *from, int fromlen, int length);
79
static void manage (struct sockaddr *from, int fromlen, int length, int fd);
84
static void query_respond (struct sockaddr *from, int fromlen, int length);
80
static void query_respond (struct sockaddr *from, int fromlen, int length, int fd);
85
static void request_respond (struct sockaddr *from, int fromlen, int length);
81
static void request_respond (struct sockaddr *from, int fromlen, int length, int fd);
86
static void send_accept (struct sockaddr *to, int tolen, CARD32 sessionID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr authorizationName, ARRAY8Ptr authorizationData);
82
static void send_accept (struct sockaddr *to, int tolen, CARD32 sessionID, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr authorizationName, ARRAY8Ptr authorizationData, int fd);
87
static void send_alive (struct sockaddr *from, int fromlen, int length);
83
static void send_alive (struct sockaddr *from, int fromlen, int length, int fd);
88
static void send_decline (struct sockaddr *to, int tolen, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr status);
84
static void send_decline (struct sockaddr *to, int tolen, ARRAY8Ptr authenticationName, ARRAY8Ptr authenticationData, ARRAY8Ptr status, int fd);
89
static void send_failed (struct sockaddr *from, int fromlen, char *name, CARD32 sessionID, char *reason);
85
static void send_failed (struct sockaddr *from, int fromlen, char *name, CARD32 sessionID, char *reason, int fd);
90
static void send_refuse (struct sockaddr *from, int fromlen, CARD32 sessionID);
86
static void send_refuse (struct sockaddr *from, int fromlen, CARD32 sessionID, int fd);
91
static void send_unwilling (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status);
87
static void send_unwilling (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status, int fd);
92
static void send_willing (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status);
88
static void send_willing (struct sockaddr *from, int fromlen, ARRAY8Ptr authenticationName, ARRAY8Ptr status, int fd);
93
94
89
90
#ifdef STREAMSCONN
95
int	xdmcpFd = -1;
91
int	xdmcpFd = -1;
92
#endif
96
int	chooserFd = -1;
93
int	chooserFd = -1;
97
94
98
FD_TYPE	WellKnownSocketsMask;
95
FD_TYPE	WellKnownSocketsMask;
Lines 103-124 Link Here
103
void
100
void
104
DestroyWellKnownSockets (void)
101
DestroyWellKnownSockets (void)
105
{
102
{
103
#ifdef STREAMSCONN
106
    if (xdmcpFd != -1)
104
    if (xdmcpFd != -1)
107
    {
105
    {
108
	close (xdmcpFd);
106
	close (xdmcpFd);
107
	FD_CLR(xdmcpFd, &WellKnownSocketsMask);
109
	xdmcpFd = -1;
108
	xdmcpFd = -1;
110
    }
109
    }
110
#endif
111
    if (chooserFd != -1)
111
    if (chooserFd != -1)
112
    {
112
    {
113
	close (chooserFd);
113
	close (chooserFd);
114
	FD_CLR(chooserFd, &WellKnownSocketsMask);
114
	chooserFd = -1;
115
	chooserFd = -1;
115
    }
116
    }
117
    CloseListenSockets();
118
}
119
120
static int
121
FD_ANYSET(fd_set *fds)
122
{
123
    int i;
124
    char *mask = (char *) fds;
125
126
    for (i = 0 ; i < sizeof(fds); i++) {
127
	if (mask[i])
128
	    return TRUE;
129
    }
130
    return FALSE;
116
}
131
}
117
132
118
int
133
int
119
AnyWellKnownSockets (void)
134
AnyWellKnownSockets (void)
120
{
135
{
121
    return xdmcpFd != -1 || chooserFd != -1;
136
    return 
137
#ifdef STREAMS_CONN
138
      xdmcpFd != -1 ||
139
#endif
140
      chooserFd != -1 || FD_ANYSET(&WellKnownSocketsMask);
122
}
141
}
123
142
124
static XdmcpBuffer	buffer;
143
static XdmcpBuffer	buffer;
Lines 133-138 Link Here
133
#ifdef AF_INET
152
#ifdef AF_INET
134
    struct sockaddr_in	    in_addr;
153
    struct sockaddr_in	    in_addr;
135
#endif
154
#endif
155
#ifdef IPv6
156
    struct sockaddr_in6	    in6_addr;
157
#endif
136
#ifdef AF_DECnet
158
#ifdef AF_DECnet
137
#endif
159
#endif
138
    struct sockaddr	    *addr;
160
    struct sockaddr	    *addr;
Lines 155-167 Link Here
155
	addrlen = sizeof (struct sockaddr_in);
177
	addrlen = sizeof (struct sockaddr_in);
156
	break;
178
	break;
157
#endif
179
#endif
180
#ifdef IPv6
181
    case FamilyInternetV6:
182
	addr = (struct sockaddr *) &in6_addr;
183
	bzero ((char *) &in6_addr, sizeof (in6_addr));
184
#ifdef SIN6_LEN
185
	in6_addr.sin6_len = sizeof(in6_addr);
186
#endif
187
	in6_addr.sin6_family = AF_INET6;
188
	in6_addr.sin6_port = htons ((short) XDM_UDP_PORT);
189
	if (address->length != 16)
190
	    return;
191
	memmove( (char *) &in6_addr.sin6_addr, address->data, address->length);
192
	addrlen = sizeof (struct sockaddr_in6);
193
	break;
194
#endif
158
#ifdef AF_DECnet
195
#ifdef AF_DECnet
159
    case FamilyDECnet:
196
    case FamilyDECnet:
160
#endif
197
#endif
161
    default:
198
    default:
162
	return;
199
	return;
163
    }
200
    }
164
    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) addr, addrlen);
201
    XdmcpFlush (*((int *) closure), &buffer, (XdmcpNetaddr) addr, addrlen);
165
    return;
202
    return;
166
}
203
}
167
204
Lines 193-199 Link Here
193
    struct sockaddr	*from,
230
    struct sockaddr	*from,
194
    int			fromlen,
231
    int			fromlen,
195
    ARRAYofARRAY8Ptr	authenticationNames,
232
    ARRAYofARRAY8Ptr	authenticationNames,
196
    xdmOpCode		type)
233
    xdmOpCode		type,
234
    int			fd)
197
{
235
{
198
    ARRAY8Ptr	authenticationName;
236
    ARRAY8Ptr	authenticationName;
199
    ARRAY8	status;
237
    ARRAY8	status;
Lines 217-226 Link Here
217
255
218
    authenticationName = ChooseAuthentication (authenticationNames);
256
    authenticationName = ChooseAuthentication (authenticationNames);
219
    if (Willing (&addr, connectionType, authenticationName, &status, type))
257
    if (Willing (&addr, connectionType, authenticationName, &status, type))
220
	send_willing (from, fromlen, authenticationName, &status);
258
	send_willing (from, fromlen, authenticationName, &status, fd);
221
    else
259
    else
222
	if (type == QUERY)
260
	if (type == QUERY)
223
	    send_unwilling (from, fromlen, authenticationName, &status);
261
	    send_unwilling (from, fromlen, authenticationName, &status, fd);
224
    XdmcpDisposeARRAY8 (&status);
262
    XdmcpDisposeARRAY8 (&status);
225
}
263
}
226
264
Lines 228-234 Link Here
228
indirect_respond (
266
indirect_respond (
229
    struct sockaddr *from,
267
    struct sockaddr *from,
230
    int		    fromlen,
268
    int		    fromlen,
231
    int		    length)
269
    int		    length,
270
    int		    fd)
232
{
271
{
233
    ARRAYofARRAY8   queryAuthenticationNames;
272
    ARRAYofARRAY8   queryAuthenticationNames;
234
    ARRAY8	    clientAddress;
273
    ARRAY8	    clientAddress;
Lines 264-276 Link Here
264
    	XdmcpWriteARRAY8 (&buffer, &clientPort);
303
    	XdmcpWriteARRAY8 (&buffer, &clientPort);
265
    	XdmcpWriteARRAYofARRAY8 (&buffer, &queryAuthenticationNames);
304
    	XdmcpWriteARRAYofARRAY8 (&buffer, &queryAuthenticationNames);
266
305
267
	localHostAsWell = ForEachMatchingIndirectHost (&clientAddress, connectionType, sendForward, (char *) 0);
306
	localHostAsWell = ForEachMatchingIndirectHost (&clientAddress, connectionType, sendForward, (char *) &fd);
268
	
307
	
269
	XdmcpDisposeARRAY8 (&clientAddress);
308
	XdmcpDisposeARRAY8 (&clientAddress);
270
	XdmcpDisposeARRAY8 (&clientPort);
309
	XdmcpDisposeARRAY8 (&clientPort);
271
	if (localHostAsWell)
310
	if (localHostAsWell)
272
	    all_query_respond (from, fromlen, &queryAuthenticationNames,
311
	    all_query_respond (from, fromlen, &queryAuthenticationNames,
273
			   INDIRECT_QUERY);
312
			   INDIRECT_QUERY, fd);
274
    }
313
    }
275
    else
314
    else
276
    {
315
    {
Lines 279-294 Link Here
279
    XdmcpDisposeARRAYofARRAY8 (&queryAuthenticationNames);
318
    XdmcpDisposeARRAYofARRAY8 (&queryAuthenticationNames);
280
}
319
}
281
320
282
static void
321
void
283
ProcessRequestSocket (void)
322
ProcessRequestSocket (int fd)
284
{
323
{
285
    XdmcpHeader		header;
324
    XdmcpHeader		header;
325
#ifdef IPv6
326
    struct sockaddr_storage	addr;
327
#else
286
    struct sockaddr	addr;
328
    struct sockaddr	addr;
329
#endif
287
    int			addrlen = sizeof addr;
330
    int			addrlen = sizeof addr;
288
331
289
    Debug ("ProcessRequestSocket\n");
332
    Debug ("ProcessRequestSocket\n");
290
    bzero ((char *) &addr, sizeof (addr));
333
    bzero ((char *) &addr, sizeof (addr));
291
    if (!XdmcpFill (xdmcpFd, &buffer, (XdmcpNetaddr) &addr, &addrlen)) {
334
    if (!XdmcpFill (fd, &buffer, (XdmcpNetaddr) &addr, &addrlen)) {
292
	Debug ("XdmcpFill failed\n");
335
	Debug ("XdmcpFill failed\n");
293
	return;
336
	return;
294
    }
337
    }
Lines 305-329 Link Here
305
    switch (header.opcode)
348
    switch (header.opcode)
306
    {
349
    {
307
    case BROADCAST_QUERY:
350
    case BROADCAST_QUERY:
308
	broadcast_respond (&addr, addrlen, header.length);
351
	broadcast_respond ((struct sockaddr *) &addr, addrlen, header.length, fd);
309
	break;
352
	break;
310
    case QUERY:
353
    case QUERY:
311
	query_respond (&addr, addrlen, header.length);
354
	query_respond ((struct sockaddr *) &addr, addrlen, header.length, fd);
312
	break;
355
	break;
313
    case INDIRECT_QUERY:
356
    case INDIRECT_QUERY:
314
	indirect_respond (&addr, addrlen, header.length);
357
	indirect_respond ((struct sockaddr *) &addr, addrlen, header.length, fd);
315
	break;
358
	break;
316
    case FORWARD_QUERY:
359
    case FORWARD_QUERY:
317
	forward_respond (&addr, addrlen, header.length);
360
	forward_respond ((struct sockaddr *) &addr, addrlen, header.length, fd);
318
	break;
361
	break;
319
    case REQUEST:
362
    case REQUEST:
320
	request_respond (&addr, addrlen, header.length);
363
	request_respond ((struct sockaddr *) &addr, addrlen, header.length, fd);
321
	break;
364
	break;
322
    case MANAGE:
365
    case MANAGE:
323
	manage (&addr, addrlen, header.length);
366
	manage ((struct sockaddr *) &addr, addrlen, header.length, fd);
324
	break;
367
	break;
325
    case KEEPALIVE:
368
    case KEEPALIVE:
326
	send_alive (&addr, addrlen, header.length);
369
	send_alive ((struct sockaddr *) &addr, addrlen, header.length, fd);
327
	break;
370
	break;
328
    }
371
    }
329
}
372
}
Lines 342-356 Link Here
342
		nready, Rescan, ChildReady);
385
		nready, Rescan, ChildReady);
343
	if (nready > 0)
386
	if (nready > 0)
344
	{
387
	{
388
#ifdef STREAMSCONN
345
	    if (xdmcpFd >= 0 && FD_ISSET (xdmcpFd, &reads))
389
	    if (xdmcpFd >= 0 && FD_ISSET (xdmcpFd, &reads))
346
		ProcessRequestSocket ();
390
		ProcessRequestSocket ();
391
#endif
347
	    if (chooserFd >= 0 && FD_ISSET (chooserFd, &reads))
392
	    if (chooserFd >= 0 && FD_ISSET (chooserFd, &reads))
393
	    {
348
#ifdef ISC
394
#ifdef ISC
349
	        if (!ChildReady) {
395
	        if (!ChildReady) {
350
	           WaitForSomething ();
396
	           WaitForSomething ();
351
                } else
397
                } else
352
#endif
398
#endif
353
		ProcessChooserSocket (chooserFd);
399
		ProcessChooserSocket (chooserFd);
400
		FD_CLR(chooserFd, &reads);
401
	    }
402
	    ProcessListenSockets(&reads);
354
	}
403
	}
355
	if (ChildReady)
404
	if (ChildReady)
356
	{
405
	{
Lines 384-390 Link Here
384
    struct sockaddr *from,
433
    struct sockaddr *from,
385
    int		    fromlen,
434
    int		    fromlen,
386
    int		    length,
435
    int		    length,
387
    xdmOpCode	    type)
436
    xdmOpCode	    type,
437
    int		    fd)
388
{
438
{
389
    ARRAYofARRAY8   queryAuthenticationNames;
439
    ARRAYofARRAY8   queryAuthenticationNames;
390
    int		    expectedLen;
440
    int		    expectedLen;
Lines 396-402 Link Here
396
    for (i = 0; i < (int)queryAuthenticationNames.length; i++)
446
    for (i = 0; i < (int)queryAuthenticationNames.length; i++)
397
	expectedLen += 2 + queryAuthenticationNames.data[i].length;
447
	expectedLen += 2 + queryAuthenticationNames.data[i].length;
398
    if (length == expectedLen)
448
    if (length == expectedLen)
399
	all_query_respond (from, fromlen, &queryAuthenticationNames, type);
449
	all_query_respond (from, fromlen, &queryAuthenticationNames, type, fd);
400
    XdmcpDisposeARRAYofARRAY8 (&queryAuthenticationNames);
450
    XdmcpDisposeARRAYofARRAY8 (&queryAuthenticationNames);
401
}
451
}
402
452
Lines 404-422 Link Here
404
query_respond (
454
query_respond (
405
    struct sockaddr *from,
455
    struct sockaddr *from,
406
    int		    fromlen,
456
    int		    fromlen,
407
    int		    length)
457
    int		    length,
458
    int		    fd)
408
{
459
{
409
    Debug ("Query respond %d\n", length);
460
    Debug ("Query respond %d\n", length);
410
    direct_query_respond (from, fromlen, length, QUERY);
461
    direct_query_respond (from, fromlen, length, QUERY, fd);
411
}
462
}
412
463
413
static void
464
static void
414
broadcast_respond (
465
broadcast_respond (
415
    struct sockaddr *from,
466
    struct sockaddr *from,
416
    int		    fromlen,
467
    int		    fromlen,
417
    int		    length)
468
    int		    length,
469
    int		    fd)
418
{
470
{
419
    direct_query_respond (from, fromlen, length, BROADCAST_QUERY);
471
    direct_query_respond (from, fromlen, length, BROADCAST_QUERY, fd);
420
}
472
}
421
473
422
/* computes an X display name */
474
/* computes an X display name */
Lines 431-436 Link Here
431
    switch (connectionType)
483
    switch (connectionType)
432
    {
484
    {
433
    case FamilyInternet:
485
    case FamilyInternet:
486
#ifdef IPv6
487
    case FamilyInternetV6:
488
	{
489
	    CARD8		*data;
490
	    struct hostent	*hostent;
491
	    char 		*hostname = NULL;
492
	    char		*name;
493
	    char		*localhost;
494
	    int			 multiHomed = 0;
495
	    struct addrinfo	 hints, *ai = NULL, *nai;
496
	    int 		 type;
497
498
	    if (connectionType == FamilyInternetV6)
499
		type = AF_INET6;
500
	    else
501
		type = AF_INET;
502
503
	    data = connectionAddress->data;
504
	    hostent = gethostbyaddr ((char *)data,
505
				     connectionAddress->length, type);
506
	    if (hostent) {
507
		if (sourceAddress) {
508
		    bzero(&hints, sizeof(hints));
509
		    hints.ai_flags = AI_CANONNAME;
510
		    if (getaddrinfo(hostent->h_name, NULL, &hints, &ai) == 0) {
511
			hostname = ai->ai_canonname;
512
			while ((nai = ai->ai_next) != NULL) {
513
			    if ((ai->ai_protocol == nai->ai_protocol) &&
514
				(ai->ai_addrlen == nai->ai_addrlen) &&
515
			        (memcmp(ai->ai_addr,nai->ai_addr,
516
					ai->ai_addrlen) != 0) ) {
517
				multiHomed = 1;
518
			    }
519
			}
520
		    }
521
		} else {
522
		    hostname = hostent->h_name;
523
		}
524
	    }
525
526
	    localhost = localHostname ();
527
528
	    /* 
529
	     * protect against bogus host names 
530
	     */
531
	    if (hostname && hostname[0] && (hostname[0] != '.') 
532
			&& !multiHomed)
533
	    {
534
		if (!strcmp (localhost, hostname))
535
		{
536
		    if (!getString (name, 10))
537
			return 0;
538
		    sprintf (name, ":%d", displayNumber);
539
		}
540
		else
541
		{
542
		    if (removeDomainname)
543
		    {
544
		    	char    *localDot, *remoteDot;
545
    
546
			/* check for a common domain name.  This
547
			 * could reduce names by recognising common
548
			 * super-domain names as well, but I don't think
549
			 * this is as useful, and will confuse more
550
			 * people
551
 			 */
552
		    	if ((localDot = strchr(localhost, '.')) &&
553
		            (remoteDot = strchr(hostname, '.')))
554
			{
555
			    /* smash the name in place; it won't
556
			     * be needed later.
557
			     */
558
			    if (!strcmp (localDot+1, remoteDot+1))
559
				*remoteDot = '\0';
560
			}
561
		    }
562
563
		    if (!getString (name, strlen (hostname) + 10))
564
			return 0;
565
		    sprintf (name, "%s:%d", hostname, displayNumber);
566
		}
567
	    }
568
	    else
569
	    {
570
		if (!getString (name, INET6_ADDRSTRLEN + 10))
571
		    return 0;
572
		if (multiHomed) {
573
		    if (connectionType == FamilyInternet) {
574
			data = (CARD8 *) 
575
			  &((struct sockaddr_in *)originalAddress)->
576
			  sin_addr;
577
		    } else {
578
			data = (CARD8 *) 
579
			  &((struct sockaddr_in6 *)originalAddress)->sin6_addr;
580
		    }
581
		}
582
		if (inet_ntop(type, data, name, INET6_ADDRSTRLEN) == NULL) {
583
		    free(name);
584
		    return 0;
585
		} 
586
		sprintf(name + strlen(name), ":%d", displayNumber);
587
	    }
588
	    if (ai)
589
		freeaddrinfo(ai);
590
	    return name;
591
	}
592
#else /* IPv6 */
434
	{
593
	{
435
	    CARD8		*data;
594
	    CARD8		*data;
436
	    struct hostent	*hostent;
595
	    struct hostent	*hostent;
Lines 502-507 Link Here
502
	    }
661
	    }
503
	    return name;
662
	    return name;
504
	}
663
	}
664
#endif /* IPv6 */
505
#ifdef DNET
665
#ifdef DNET
506
    case FamilyDECnet:
666
    case FamilyDECnet:
507
	return NULL;
667
	return NULL;
Lines 516-522 Link Here
516
forward_respond (
676
forward_respond (
517
    struct sockaddr	*from,
677
    struct sockaddr	*from,
518
    int			fromlen,
678
    int			fromlen,
519
    int			length)
679
    int			length,
680
    int			fd)
520
{
681
{
521
    ARRAY8	    clientAddress;
682
    ARRAY8	    clientAddress;
522
    ARRAY8	    clientPort;
683
    ARRAY8	    clientPort;
Lines 576-582 Link Here
576
		    client = (struct sockaddr *) &in_addr;
737
		    client = (struct sockaddr *) &in_addr;
577
		    clientlen = sizeof (in_addr);
738
		    clientlen = sizeof (in_addr);
578
		    all_query_respond (client, clientlen, &authenticationNames,
739
		    all_query_respond (client, clientlen, &authenticationNames,
579
			       FORWARD_QUERY);
740
			       FORWARD_QUERY, fd);
741
		}
742
		break;
743
#endif
744
#ifdef IPv6
745
	    case AF_INET6:
746
		{
747
		    struct sockaddr_in6	in6_addr;
748
749
		    if (clientAddress.length != 16 ||
750
		        clientPort.length != 2)
751
		    {
752
			goto badAddress;
753
		    }
754
		    bzero ((char *) &in6_addr, sizeof (in6_addr));
755
#ifdef SIN6_LEN
756
		    in6_addr.sin6_len = sizeof(in6_addr);
757
#endif
758
		    in6_addr.sin6_family = AF_INET6;
759
		    memmove(&in6_addr,clientAddress.data,clientAddress.length);
760
		    memmove((char *) &in6_addr.sin6_port, clientPort.data, 2);
761
		    client = (struct sockaddr *) &in6_addr;
762
		    clientlen = sizeof (in6_addr);
763
		    all_query_respond (client, clientlen, &authenticationNames,
764
			       FORWARD_QUERY, fd);
580
		}
765
		}
581
		break;
766
		break;
582
#endif
767
#endif
Lines 599-605 Link Here
599
		    clientlen = sizeof (un_addr);
784
		    clientlen = sizeof (un_addr);
600
#endif
785
#endif
601
		    all_query_respond (client, clientlen, &authenticationNames,
786
		    all_query_respond (client, clientlen, &authenticationNames,
602
			       FORWARD_QUERY);
787
			       FORWARD_QUERY, fd);
603
		}
788
		}
604
		break;
789
		break;
605
#endif
790
#endif
Lines 629-635 Link Here
629
    struct sockaddr *from,
814
    struct sockaddr *from,
630
    int		    fromlen,
815
    int		    fromlen,
631
    ARRAY8Ptr	    authenticationName,
816
    ARRAY8Ptr	    authenticationName,
632
    ARRAY8Ptr	    status)
817
    ARRAY8Ptr	    status,
818
    int		    fd)
633
{
819
{
634
    XdmcpHeader	header;
820
    XdmcpHeader	header;
635
821
Lines 647-653 Link Here
647
    XdmcpWriteARRAY8 (&buffer, authenticationName);
833
    XdmcpWriteARRAY8 (&buffer, authenticationName);
648
    XdmcpWriteARRAY8 (&buffer, &Hostname);
834
    XdmcpWriteARRAY8 (&buffer, &Hostname);
649
    XdmcpWriteARRAY8 (&buffer, status);
835
    XdmcpWriteARRAY8 (&buffer, status);
650
    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
836
    XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen);
651
}
837
}
652
838
653
static void
839
static void
Lines 655-661 Link Here
655
    struct sockaddr *from,
841
    struct sockaddr *from,
656
    int		    fromlen,
842
    int		    fromlen,
657
    ARRAY8Ptr	    authenticationName,
843
    ARRAY8Ptr	    authenticationName,
658
    ARRAY8Ptr	    status)
844
    ARRAY8Ptr	    status,
845
    int		    fd)
659
{
846
{
660
    XdmcpHeader	header;
847
    XdmcpHeader	header;
661
848
Lines 671-677 Link Here
671
    XdmcpWriteHeader (&buffer, &header);
858
    XdmcpWriteHeader (&buffer, &header);
672
    XdmcpWriteARRAY8 (&buffer, &Hostname);
859
    XdmcpWriteARRAY8 (&buffer, &Hostname);
673
    XdmcpWriteARRAY8 (&buffer, status);
860
    XdmcpWriteARRAY8 (&buffer, status);
674
    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
861
    XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen);
675
}
862
}
676
863
677
static unsigned long	globalSessionID;
864
static unsigned long	globalSessionID;
Lines 696-702 Link Here
696
request_respond (
883
request_respond (
697
    struct sockaddr *from,
884
    struct sockaddr *from,
698
    int		    fromlen,
885
    int		    fromlen,
699
    int		    length)
886
    int		    length,
887
    int		    fd)
700
{
888
{
701
    CARD16	    displayNumber;
889
    CARD16	    displayNumber;
702
    ARRAY16	    connectionTypes;
890
    ARRAY16	    connectionTypes;
Lines 821-834 Link Here
821
				        &authenticationName,
1009
				        &authenticationName,
822
					&authenticationData,
1010
					&authenticationData,
823
					&authorizationName,
1011
					&authorizationName,
824
					&authorizationData);
1012
					&authorizationData, fd);
825
	}
1013
	}
826
	else
1014
	else
827
	{
1015
	{
828
decline:    ;
1016
decline:    ;
829
	    send_decline (from, fromlen, &authenticationName,
1017
	    send_decline (from, fromlen, &authenticationName,
830
				 &authenticationData,
1018
				 &authenticationData,
831
				 reason);
1019
				 reason, fd);
832
            if (pdpy)
1020
            if (pdpy)
833
		DisposeProtoDisplay (pdpy);
1021
		DisposeProtoDisplay (pdpy);
834
	}
1022
	}
Lines 850-856 Link Here
850
    ARRAY8Ptr	    authenticationName,
1038
    ARRAY8Ptr	    authenticationName,
851
    ARRAY8Ptr	    authenticationData,
1039
    ARRAY8Ptr	    authenticationData,
852
    ARRAY8Ptr	    authorizationName,
1040
    ARRAY8Ptr	    authorizationName,
853
    ARRAY8Ptr	    authorizationData)
1041
    ARRAY8Ptr	    authorizationData,
1042
    int		    fd)
854
{
1043
{
855
    XdmcpHeader	header;
1044
    XdmcpHeader	header;
856
1045
Lines 868-874 Link Here
868
    XdmcpWriteARRAY8 (&buffer, authenticationData);
1057
    XdmcpWriteARRAY8 (&buffer, authenticationData);
869
    XdmcpWriteARRAY8 (&buffer, authorizationName);
1058
    XdmcpWriteARRAY8 (&buffer, authorizationName);
870
    XdmcpWriteARRAY8 (&buffer, authorizationData);
1059
    XdmcpWriteARRAY8 (&buffer, authorizationData);
871
    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) to, tolen);
1060
    XdmcpFlush (fd, &buffer, (XdmcpNetaddr) to, tolen);
872
}
1061
}
873
   
1062
   
874
static void
1063
static void
Lines 877-883 Link Here
877
    int		    tolen,
1066
    int		    tolen,
878
    ARRAY8Ptr	    authenticationName,
1067
    ARRAY8Ptr	    authenticationName,
879
    ARRAY8Ptr	    authenticationData,
1068
    ARRAY8Ptr	    authenticationData,
880
    ARRAY8Ptr	    status)
1069
    ARRAY8Ptr	    status,
1070
    int	       	    fd)
881
{
1071
{
882
    XdmcpHeader	header;
1072
    XdmcpHeader	header;
883
1073
Lines 892-905 Link Here
892
    XdmcpWriteARRAY8 (&buffer, status);
1082
    XdmcpWriteARRAY8 (&buffer, status);
893
    XdmcpWriteARRAY8 (&buffer, authenticationName);
1083
    XdmcpWriteARRAY8 (&buffer, authenticationName);
894
    XdmcpWriteARRAY8 (&buffer, authenticationData);
1084
    XdmcpWriteARRAY8 (&buffer, authenticationData);
895
    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) to, tolen);
1085
    XdmcpFlush (fd, &buffer, (XdmcpNetaddr) to, tolen);
896
}
1086
}
897
1087
898
static void
1088
static void
899
manage (
1089
manage (
900
    struct sockaddr *from,
1090
    struct sockaddr *from,
901
    int		    fromlen,
1091
    int		    fromlen,
902
    int		    length)
1092
    int		    length,
1093
    int		    fd)
903
{
1094
{
904
    CARD32		sessionID;
1095
    CARD32		sessionID;
905
    CARD16		displayNumber;
1096
    CARD16		displayNumber;
Lines 949-955 Link Here
949
	    Debug ("Session ID %ld refused\n", (long) sessionID);
1140
	    Debug ("Session ID %ld refused\n", (long) sessionID);
950
	    if (pdpy)
1141
	    if (pdpy)
951
		Debug ("Existing Session ID %ld\n", (long) pdpy->sessionID);
1142
		Debug ("Existing Session ID %ld\n", (long) pdpy->sessionID);
952
	    send_refuse (from, fromlen, sessionID);
1143
	    send_refuse (from, fromlen, sessionID, fd);
953
	}
1144
	}
954
	else
1145
	else
955
	{
1146
	{
Lines 960-966 Link Here
960
	    Debug ("Computed display name: %s\n", name);
1151
	    Debug ("Computed display name: %s\n", name);
961
	    if (!name)
1152
	    if (!name)
962
	    {
1153
	    {
963
		send_failed (from, fromlen, "(no name)", sessionID, "out of memory");
1154
		send_failed (from, fromlen, "(no name)", sessionID, 
1155
		  "out of memory", fd);
964
		goto abort;
1156
		goto abort;
965
	    }
1157
	    }
966
	    d = FindDisplayByName (name);
1158
	    d = FindDisplayByName (name);
Lines 972-978 Link Here
972
	    class = malloc (displayClass.length + 1);
1164
	    class = malloc (displayClass.length + 1);
973
	    if (!class)
1165
	    if (!class)
974
	    {
1166
	    {
975
		send_failed (from, fromlen, name, sessionID, "out of memory");
1167
		send_failed (from, fromlen, name, sessionID, 
1168
		  "out of memory", fd);
976
		goto abort;
1169
		goto abort;
977
	    }
1170
	    }
978
	    if (displayClass.length)
1171
	    if (displayClass.length)
Lines 988-994 Link Here
988
	    from_save = (XdmcpNetaddr) malloc (fromlen);
1181
	    from_save = (XdmcpNetaddr) malloc (fromlen);
989
	    if (!from_save)
1182
	    if (!from_save)
990
	    {
1183
	    {
991
		send_failed (from, fromlen, name, sessionID, "out of memory");
1184
		send_failed (from, fromlen, name, sessionID,
1185
		  "out of memory", fd);
992
		goto abort;
1186
		goto abort;
993
	    }
1187
	    }
994
	    memmove( from_save, from, fromlen);
1188
	    memmove( from_save, from, fromlen);
Lines 996-1002 Link Here
996
	    if (!d)
1190
	    if (!d)
997
	    {
1191
	    {
998
		free ((char *) from_save);
1192
		free ((char *) from_save);
999
		send_failed (from, fromlen, name, sessionID, "out of memory");
1193
		send_failed (from, fromlen, name, sessionID, 
1194
		  "out of memory", fd);
1000
		goto abort;
1195
		goto abort;
1001
	    }
1196
	    }
1002
	    d->displayType.location = Foreign;
1197
	    d->displayType.location = Foreign;
Lines 1008-1013 Link Here
1008
	    d->displayNumber = pdpy->displayNumber;
1203
	    d->displayNumber = pdpy->displayNumber;
1009
	    ClientAddress (from, &clientAddress, &clientPort, &connectionType);
1204
	    ClientAddress (from, &clientAddress, &clientPort, &connectionType);
1010
	    d->useChooser = 0;
1205
	    d->useChooser = 0;
1206
	    d->xdmcpFd = fd;
1011
	    if (IsIndirectClient (&clientAddress, connectionType))
1207
	    if (IsIndirectClient (&clientAddress, connectionType))
1012
	    {
1208
	    {
1013
		Debug ("IsIndirectClient\n");
1209
		Debug ("IsIndirectClient\n");
Lines 1028-1034 Link Here
1028
		{
1224
		{
1029
		    free ((char *) from_save);
1225
		    free ((char *) from_save);
1030
		    free ((char *) d);
1226
		    free ((char *) d);
1031
		    send_failed (from, fromlen, name, sessionID, "out of memory");
1227
		    send_failed (from, fromlen, name, sessionID,
1228
		      "out of memory", fd);
1032
		    goto abort;
1229
		    goto abort;
1033
		}
1230
		}
1034
		d->authorizations[0] = pdpy->fileAuthorization;
1231
		d->authorizations[0] = pdpy->fileAuthorization;
Lines 1052-1058 Link Here
1052
    char	    *reason)
1249
    char	    *reason)
1053
{
1250
{
1054
    Debug ("Display start failed, sending Failed\n");
1251
    Debug ("Display start failed, sending Failed\n");
1055
    send_failed ((struct sockaddr *)(d->from), d->fromlen, d->name, d->sessionID, reason);
1252
    send_failed ((struct sockaddr *)(d->from), d->fromlen, d->name, 
1253
      d->sessionID, reason, d->xdmcpFd);
1056
}
1254
}
1057
1255
1058
static void
1256
static void
Lines 1061-1067 Link Here
1061
    int		    fromlen,
1259
    int		    fromlen,
1062
    char	    *name,
1260
    char	    *name,
1063
    CARD32	    sessionID,
1261
    CARD32	    sessionID,
1064
    char	    *reason)
1262
    char	    *reason,
1263
    int		    fd)
1065
{
1264
{
1066
    static char	buf[256];
1265
    static char	buf[256];
1067
    XdmcpHeader	header;
1266
    XdmcpHeader	header;
Lines 1078-1091 Link Here
1078
    XdmcpWriteHeader (&buffer, &header);
1277
    XdmcpWriteHeader (&buffer, &header);
1079
    XdmcpWriteCARD32 (&buffer, sessionID);
1278
    XdmcpWriteCARD32 (&buffer, sessionID);
1080
    XdmcpWriteARRAY8 (&buffer, &status);
1279
    XdmcpWriteARRAY8 (&buffer, &status);
1081
    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
1280
    XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen);
1082
}
1281
}
1083
1282
1084
static void
1283
static void
1085
send_refuse (
1284
send_refuse (
1086
    struct sockaddr *from,
1285
    struct sockaddr *from,
1087
    int		    fromlen,
1286
    int		    fromlen,
1088
    CARD32	    sessionID)
1287
    CARD32	    sessionID,
1288
    int		    fd)
1089
{
1289
{
1090
    XdmcpHeader	header;
1290
    XdmcpHeader	header;
1091
1291
Lines 1095-1108 Link Here
1095
    header.length = 4;
1295
    header.length = 4;
1096
    XdmcpWriteHeader (&buffer, &header);
1296
    XdmcpWriteHeader (&buffer, &header);
1097
    XdmcpWriteCARD32 (&buffer, sessionID);
1297
    XdmcpWriteCARD32 (&buffer, sessionID);
1098
    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
1298
    XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen);
1099
}
1299
}
1100
1300
1101
static void
1301
static void
1102
send_alive (
1302
send_alive (
1103
    struct sockaddr *from,
1303
    struct sockaddr *from,
1104
    int		    fromlen,
1304
    int		    fromlen,
1105
    int		    length)
1305
    int		    length,
1306
    int		    fd)
1106
{
1307
{
1107
    CARD32		sessionID;
1308
    CARD32		sessionID;
1108
    CARD16		displayNumber;
1309
    CARD16		displayNumber;
Lines 1136-1142 Link Here
1136
	    XdmcpWriteHeader (&buffer, &header);
1337
	    XdmcpWriteHeader (&buffer, &header);
1137
	    XdmcpWriteCARD8 (&buffer, sendRunning);
1338
	    XdmcpWriteCARD8 (&buffer, sendRunning);
1138
	    XdmcpWriteCARD32 (&buffer, sendSessionID);
1339
	    XdmcpWriteCARD32 (&buffer, sendSessionID);
1139
	    XdmcpFlush (xdmcpFd, &buffer, (XdmcpNetaddr) from, fromlen);
1340
	    XdmcpFlush (fd, &buffer, (XdmcpNetaddr) from, fromlen);
1140
	}
1341
	}
1141
    }
1342
    }
1142
}
1343
}
Lines 1151-1166 Link Here
1151
    switch (connectionType)
1352
    switch (connectionType)
1152
    {
1353
    {
1153
    case FamilyInternet:
1354
    case FamilyInternet:
1355
#ifdef IPv6
1356
    case FamilyInternetV6:
1357
#endif
1154
	{
1358
	{
1155
	    struct hostent	*hostent = NULL;
1359
	    struct hostent	*hostent = NULL;
1360
#ifdef IPv6
1361
	    char dotted[INET6_ADDRSTRLEN];
1362
#else
1156
	    char dotted[20];
1363
	    char dotted[20];
1364
#endif
1157
	    char *local_name = "";
1365
	    char *local_name = "";
1366
	    int af_type;
1367
1368
#ifdef IPv6
1369
	    if (connectionType == FamilyInternetV6)
1370
		af_type = AF_INET6;
1371
	    else
1372
#endif
1373
		af_type = AF_INET;
1158
1374
1159
	    hostent = gethostbyaddr ((char *)connectionAddress->data,
1375
	    hostent = gethostbyaddr ((char *)connectionAddress->data,
1160
				     connectionAddress->length, AF_INET);
1376
				      connectionAddress->length, af_type);
1161
1377
1162
	    if (hostent) {
1378
	    if (hostent) {
1163
		/* check for DNS spoofing */
1379
		/* check for DNS spoofing */
1380
#ifdef IPv6
1381
		struct addrinfo	*ai = NULL, *nai;
1382
		if (getaddrinfo(hostent->h_name, NULL, NULL, &ai) == 0) {
1383
		    while ((nai = ai->ai_next) != NULL) {
1384
			if ((af_type == nai->ai_family) &&
1385
			  (connectionAddress->length == nai->ai_addrlen) &&
1386
			  (memcmp(connectionAddress->data,nai->ai_addr,
1387
			    nai->ai_addrlen) != 0) ) {
1388
			    break;
1389
			}
1390
		    }
1391
		    if (nai == NULL) {
1392
			inet_ntop(af_type, connectionAddress->data, 
1393
			  dotted, sizeof(dotted));
1394
1395
			LogError("Possible DNS spoof attempt %s->%s.", dotted,
1396
			  hostent->h_name);
1397
			hostent = NULL;
1398
		    }
1399
		    freeaddrinfo(ai);
1400
		} else {
1401
		    hostent = NULL;
1402
		}
1403
#else
1164
		char *s = strdup(hostent->h_name); /* fscking non-reentrancy of getXXX() */
1404
		char *s = strdup(hostent->h_name); /* fscking non-reentrancy of getXXX() */
1165
		if ((hostent = gethostbyname(s))) {
1405
		if ((hostent = gethostbyname(s))) {
1166
			if (memcmp((char*)connectionAddress->data, hostent->h_addr,
1406
			if (memcmp((char*)connectionAddress->data, hostent->h_addr,
Lines 1172-1186 Link Here
1172
			}
1412
			}
1173
		}
1413
		}
1174
		free(s);
1414
		free(s);
1415
#endif
1175
	    }
1416
	    }
1176
1417
1177
	    if (!hostent) {
1418
	    if (!hostent) {
1178
		/* can't get name, so use emergency fallback */
1419
		/* can't get name, so use emergency fallback */
1420
#ifdef IPv6
1421
		inet_ntop(af_type, connectionAddress->data, 
1422
		  	  dotted, sizeof(dotted));
1423
#else
1179
		sprintf(dotted, "%d.%d.%d.%d",
1424
		sprintf(dotted, "%d.%d.%d.%d",
1180
			connectionAddress->data[0],
1425
			connectionAddress->data[0],
1181
			connectionAddress->data[1],
1426
			connectionAddress->data[1],
1182
			connectionAddress->data[2],
1427
			connectionAddress->data[2],
1183
			connectionAddress->data[3]);
1428
			connectionAddress->data[3]);
1429
#endif
1184
		local_name = dotted;
1430
		local_name = dotted;
1185
		LogError ("Cannot convert Internet address %s to host name\n",
1431
		LogError ("Cannot convert Internet address %s to host name\n",
1186
			  dotted);
1432
			  dotted);
Lines 1198-1204 Link Here
1198
	break;
1444
	break;
1199
    }
1445
    }
1200
    return name;
1446
    return name;
1201
    }
1447
}
1202
1448
1203
#if 0
1449
#if 0
1204
static int
1450
static int
(-)4.3.0/xc/programs/xfs/os/access.c (+3 lines)
Lines 76-85 Link Here
76
    MaxClients = num;
76
    MaxClients = num;
77
}
77
}
78
78
79
#ifdef NOTDEF
79
/*
80
/*
80
 * XXX
81
 * XXX
81
 *
82
 *
82
 * needs massive amounts of OS-dependent work (big surprise)
83
 * needs massive amounts of OS-dependent work (big surprise)
84
 * needs IPv6 support as well
83
 */
85
 */
84
int
86
int
85
GetHostAddress(HostAddress *addr)
87
GetHostAddress(HostAddress *addr)
Lines 102-107 Link Here
102
    }
104
    }
103
    return FSSuccess;
105
    return FSSuccess;
104
}
106
}
107
#endif
105
108
106
/* ARGSUSED */
109
/* ARGSUSED */
107
int
110
int
(-)4.3.0/xc/programs/xfs/os/connection.c (+1 lines)
Lines 69-74 Link Here
69
 */
69
 */
70
/* $XFree86: xc/programs/xfs/os/connection.c,v 3.25 2002/10/15 01:45:03 dawes Exp $ */
70
/* $XFree86: xc/programs/xfs/os/connection.c,v 3.25 2002/10/15 01:45:03 dawes Exp $ */
71
71
72
#include	<stdlib.h>
72
#include	<X11/Xtrans.h>
73
#include	<X11/Xtrans.h>
73
#include	<stdlib.h>
74
#include	<stdlib.h>
74
#include	"misc.h"
75
#include	"misc.h"
(-)4.3.0/xc/programs/xhost/xhost.c (-3 / +142 lines)
Lines 1-4 Link Here
1
/* $Xorg: xhost.c,v 1.4 2001/02/09 02:05:46 xorgcvs Exp $ */
1
/* $Xorg: xhost.c,v 1.4 2001/02/09 02:05:46 xorgcvs Exp $ */
2
/* Updated for IPv6 					  */
2
/*
3
/*
3
4
4
Copyright 1985, 1986, 1987, 1998  The Open Group
5
Copyright 1985, 1986, 1987, 1998  The Open Group
Lines 43-48 Link Here
43
#include <X11/Xproto.h>
44
#include <X11/Xproto.h>
44
#include <X11/Xfuncs.h>
45
#include <X11/Xfuncs.h>
45
#include <stdio.h>
46
#include <stdio.h>
47
#include <stdlib.h>
46
#include <signal.h>
48
#include <signal.h>
47
#ifdef X_NOT_POSIX
49
#ifdef X_NOT_POSIX
48
#include <setjmp.h>
50
#include <setjmp.h>
Lines 123-129 Link Here
123
125
124
#define NAMESERVER_TIMEOUT 5	/* time to wait for nameserver */
126
#define NAMESERVER_TIMEOUT 5	/* time to wait for nameserver */
125
127
126
int nameserver_timedout;
128
volatile int nameserver_timedout;
127
 
129
 
128
char *ProgramName;
130
char *ProgramName;
129
131
Lines 143-148 Link Here
143
#endif
145
#endif
144
#ifdef	AF_INET
146
#ifdef	AF_INET
145
        { AF_INET, FamilyInternet },
147
        { AF_INET, FamilyInternet },
148
#ifdef IPv6
149
        { AF_INET6, FamilyInternetV6 },
150
#endif
146
#endif
151
#endif
147
};
152
};
148
153
Lines 202-207 Link Here
202
		    case FamilyInternet:
207
		    case FamilyInternet:
203
			printf("INET:");
208
			printf("INET:");
204
			break;
209
			break;
210
		    case FamilyInternetV6:
211
			printf("INETV6:");
212
			break;
205
		    case FamilyDECnet:
213
		    case FamilyDECnet:
206
			printf("DNET:");
214
			printf("DNET:");
207
			break;
215
			break;
Lines 286-292 Link Here
286
static int 
294
static int 
287
change_host(Display *dpy, char *name, Bool add)
295
change_host(Display *dpy, char *name, Bool add)
288
{
296
{
289
    struct hostent *hp;
290
    XHostAddress ha;
297
    XHostAddress ha;
291
    char *lname;
298
    char *lname;
292
    int namelen, i, family = FamilyWild;
299
    int namelen, i, family = FamilyWild;
Lines 297-302 Link Here
297
#ifdef NEEDSOCKETS
304
#ifdef NEEDSOCKETS
298
#ifndef AMTCPCONN
305
#ifndef AMTCPCONN
299
    static struct in_addr addr;	/* so we can point at it */
306
    static struct in_addr addr;	/* so we can point at it */
307
#ifdef IPv6
308
    static struct in6_addr addr6; /* so we can point at it */
309
#else
310
    struct hostent *hp;
311
#endif
300
#else
312
#else
301
    static ipaddr_t addr;
313
    static ipaddr_t addr;
302
#endif
314
#endif
Lines 328-333 Link Here
328
	return 0;
340
	return 0;
329
#endif
341
#endif
330
    }
342
    }
343
    if (!strncmp("inetv6:", lname, 7)) {
344
#if (defined(TCPCONN) || defined(STREAMSCONN)) && defined(IPv6)
345
	family = FamilyInternetV6;
346
	name += 7;
347
#else
348
	fprintf (stderr, "%s: not compiled for IPv6\n", ProgramName);
349
	return 0;
350
#endif
351
    }
331
    if (!strncmp("dnet:", lname, 5)) {
352
    if (!strncmp("dnet:", lname, 5)) {
332
#ifdef DNETCONN
353
#ifdef DNETCONN
333
	family = FamilyDECnet;
354
	family = FamilyDECnet;
Lines 491-496 Link Here
491
	}
512
	}
492
	return 1;
513
	return 1;
493
    } 
514
    } 
515
#ifdef IPv6
516
    /*
517
     * Check to see if inet_pton() can grok it as an IPv6 address
518
     */
519
    else if (inet_pton(AF_INET6, name, &addr6.s6_addr) == 1) {
520
	ha.family = FamilyInternetV6;
521
	ha.length = sizeof(addr6.s6_addr);		
522
	ha.address = (char *) &addr6.s6_addr; 
523
	if (add) {
524
	    XAddHost (dpy, &ha);
525
	    printf ("%s %s\n", name, add_msg);
526
	} else {
527
	    XRemoveHost (dpy, &ha);
528
	    printf ("%s %s\n", name, remove_msg);
529
	}
530
	return 1;
531
    } else {
532
    /*
533
     * Is it in the namespace?  
534
     *
535
     * If no family was specified, use both Internet v4 & v6 addresses.
536
     * Otherwise, use only addresses matching specified family.
537
     */
538
	struct addrinfo *addresses;
539
	struct addrinfo *a;
540
541
	if (getaddrinfo(name, NULL, NULL, &addresses) != 0)
542
	    return 0;
543
544
	for (a = addresses; a != NULL; a = a->ai_next) {
545
	    if ( ((a->ai_family == AF_INET) && (family != FamilyInternetV6))
546
	      || ((a->ai_family == AF_INET6) && (family != FamilyInternet)) ) {
547
		char ad[INET6_ADDRSTRLEN];
548
		ha.family = XFamily(a->ai_family);
549
		if (a->ai_family == AF_INET6) {
550
		    ha.address = (char *)
551
		      &((struct sockaddr_in6 *) a->ai_addr)->sin6_addr;
552
		    ha.length = 
553
		      sizeof (((struct sockaddr_in6 *) a->ai_addr)->sin6_addr);
554
		} else {
555
		    ha.address = (char *)
556
		      &((struct sockaddr_in *) a->ai_addr)->sin_addr;
557
		    ha.length = 
558
		      sizeof (((struct sockaddr_in *) a->ai_addr)->sin_addr);
559
		}
560
		inet_ntop(a->ai_family, ha.address, ad, sizeof(ad));
561
	/* printf("Family: %d\nLength: %d\n", a->ai_family, ha.length); */
562
		/* printf("Address: %s\n", ad); */
563
564
		if (add) {
565
		    XAddHost (dpy, &ha);
566
		} else {
567
		    XRemoveHost (dpy, &ha);
568
		}
569
	    }
570
	}
571
	printf ("%s %s\n", name, add ? add_msg : remove_msg);
572
	freeaddrinfo(addresses);
573
	return 1;
574
    }
575
#else /* !IPv6 */
494
    /*
576
    /*
495
     * Is it in the namespace?
577
     * Is it in the namespace?
496
     */
578
     */
Lines 525-530 Link Here
525
	printf ("%s %s\n", name, add ? add_msg : remove_msg);
607
	printf ("%s %s\n", name, add ? add_msg : remove_msg);
526
	return 1;
608
	return 1;
527
    }
609
    }
610
#endif /* IPv6 */
528
#else /* NEEDSOCKETS */
611
#else /* NEEDSOCKETS */
529
    return 0;
612
    return 0;
530
#endif /* NEEDSOCKETS */
613
#endif /* NEEDSOCKETS */
Lines 544-550 Link Here
544
static char *
627
static char *
545
get_hostname(XHostAddress *ha)
628
get_hostname(XHostAddress *ha)
546
{
629
{
547
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
630
#if (defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)) && !defined(IPv6)
548
    static struct hostent *hp = NULL;
631
    static struct hostent *hp = NULL;
549
#endif
632
#endif
550
#ifdef DNETCONN
633
#ifdef DNETCONN
Lines 562-567 Link Here
562
#endif
645
#endif
563
646
564
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
647
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(AMTCPCONN)
648
#ifdef IPv6
649
    if ((ha->family == FamilyInternet) || (ha->family == FamilyInternetV6)) {
650
	struct sockaddr_storage saddr;
651
	static char inetname[NI_MAXHOST];
652
	int saddrlen;
653
654
	inetname[0] = '\0';
655
	if (ha->family == FamilyInternet) {
656
	    struct sockaddr_in *sin = (struct sockaddr_in *) &saddr;
657
#ifdef BSD44SOCKETS
658
	    sin->sin_len = sizeof(sin);
659
#endif
660
	    sin->sin_family = AF_INET;
661
	    sin->sin_port = 0;
662
	    memcpy(&sin->sin_addr, ha->address, sizeof(sin->sin_addr));
663
	    saddrlen = sizeof(struct sockaddr_in);
664
	} else {
665
	    struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) &saddr;
666
#ifdef SIN6_LEN
667
	    sin6->sin6_len = sizeof(sin6);
668
#endif
669
	    sin6->sin6_family = AF_INET6;
670
	    sin6->sin6_port = 0;
671
	    memcpy(&sin6->sin6_addr, ha->address, sizeof(sin6->sin6_addr));
672
	    saddrlen = sizeof(struct sockaddr_in6);
673
	}
674
675
	/* gethostbyaddr can take a LONG time if the host does not exist.
676
	   Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
677
	   that something is wrong and do not make the user wait.
678
	   gethostbyaddr will continue after a signal, so we have to
679
	   jump out of it. 
680
	   */
681
#ifndef X_NOT_POSIX
682
	memset(&sa, 0, sizeof sa);
683
	sa.sa_handler = nameserver_lost;
684
	sa.sa_flags = 0;	/* don't restart syscalls */
685
	sigaction(SIGALRM, &sa, NULL);
686
#else
687
	signal(SIGALRM, nameserver_lost);
688
#endif
689
	alarm(NAMESERVER_TIMEOUT);
690
#ifdef X_NOT_POSIX
691
	if (setjmp(env) == 0) 
692
#endif
693
	{ 
694
	    getnameinfo((struct sockaddr *) &saddr, saddrlen, inetname,
695
	      sizeof(inetname), NULL, 0, 0);
696
	}
697
	alarm(0);
698
	if (nameserver_timedout || inetname[0] == '\0')
699
	    inet_ntop(saddr.ss_family, ha->address, inetname, sizeof(inetname));
700
	return inetname;	      
701
    }
702
#else
565
    if (ha->family == FamilyInternet) {
703
    if (ha->family == FamilyInternet) {
566
#ifdef CRAY
704
#ifdef CRAY
567
	struct in_addr t_addr;
705
	struct in_addr t_addr;
Lines 600-605 Link Here
600
	else return (inet_ntoa(*((ipaddr_t *)(ha->address))));
738
	else return (inet_ntoa(*((ipaddr_t *)(ha->address))));
601
#endif
739
#endif
602
    }
740
    }
741
#endif /* IPv6 */
603
#endif
742
#endif
604
    if (ha->family == FamilyNetname) {
743
    if (ha->family == FamilyNetname) {
605
	static char netname[512];
744
	static char netname[512];
(-)4.3.0/xc/programs/xhost/xhost.man (-3 / +6 lines)
Lines 85-91 Link Here
85
.PP
85
.PP
86
.nf
86
.nf
87
.ta 1i
87
.ta 1i
88
inet	Internet host
88
inet	Internet host (IPv4)
89
inetv6	Internet host (IPv6)
89
dnet	DECnet host
90
dnet	DECnet host
90
nis	Secure RPC network name
91
nis	Secure RPC network name
91
krb	Kerberos V5 principal
92
krb	Kerberos V5 principal
Lines 102-108 Link Here
102
.PP
103
.PP
103
For backward compatibility with pre-R6 \fIxhost\fP,
104
For backward compatibility with pre-R6 \fIxhost\fP,
104
names that contain an at-sign (@) are assumed to be in the nis family.
105
names that contain an at-sign (@) are assumed to be in the nis family.
105
Otherwise the inet family is assumed.
106
Otherwise they are assumed to be Internet addresses. If compiled to support
107
IPv6, then all IPv4 and IPv6 addresses returned by getaddrinfo(3) are added to
108
the access list in the appropriate inet or inetv6 family.
106
.SH DIAGNOSTICS
109
.SH DIAGNOSTICS
107
For each name added to the access control list,
110
For each name added to the access control list,
108
a line of the form "\fIname\fP being added to access control list"
111
a line of the form "\fIname\fP being added to access control list"
Lines 113-119 Link Here
113
.SH FILES
116
.SH FILES
114
/etc/X*.hosts
117
/etc/X*.hosts
115
.SH "SEE ALSO"
118
.SH "SEE ALSO"
116
X(__miscmansuffix__), Xsecurity(__miscmansuffix__), Xserver(1), xdm(1)
119
X(__miscmansuffix__), Xsecurity(__miscmansuffix__), Xserver(1), xdm(1), getaddrinfo(3)
117
.SH ENVIRONMENT
120
.SH ENVIRONMENT
118
.TP 8
121
.TP 8
119
.B DISPLAY
122
.B DISPLAY
(-)4.3.0/xc/programs/xlogo/RenderLogo.c (-1 / +1 lines)
Lines 156-162 Link Here
156
#ifdef __GNUC__
156
#ifdef __GNUC__
157
	fprintf(stderr, "%s: intersection is off by: %f\n", __FUNCTION__, fabs(check - intersection->x));
157
	fprintf(stderr, "%s: intersection is off by: %f\n", __FUNCTION__, fabs(check - intersection->x));
158
#else
158
#else
159
	fprintf(stderr, "intersect: intersection is off by %f\n", fabs(check - instersection->x));
159
	fprintf(stderr, "intersect: intersection is off by %f\n", fabs(check - intersection->x));
160
#endif
160
#endif
161
    }
161
    }
162
}
162
}
(-)4.3.0/xc/programs/xrx/helper/Imakefile (-2 / +5 lines)
Lines 22-33 Link Here
22
22
23
   CONN_DEFINES = -DTCPCONN
23
   CONN_DEFINES = -DTCPCONN
24
  TRANS_DEFINES = -DTRANS_CLIENT
24
  TRANS_DEFINES = -DTRANS_CLIENT
25
# ifdef IPv6Flags
26
   IPv6_DEFINES = IPv6Flags
27
# endif
25
# if HasBSD44Sockets
28
# if HasBSD44Sockets
26
   SOCK_DEFINES = -DBSD44SOCKETS
29
   SOCK_DEFINES = -DBSD44SOCKETS
27
# endif
30
# endif
28
 DEPEND_DEFINES = $(TRANS_DEFINES) $(CONN_DEFINES) DependDefines
31
 DEPEND_DEFINES = $(TRANS_DEFINES) $(CONN_DEFINES) $(IPv6_DEFINES) DependDefines
29
32
30
  DEFINES = StrcasecmpDefines \
33
  DEFINES = StrcasecmpDefines $(IPv6_DEFINES) \
31
	$(CONN_DEFINES) $(SOCK_DEFINES) $(TRANS_DEFINES) $(POLL_DEFINES)
34
	$(CONN_DEFINES) $(SOCK_DEFINES) $(TRANS_DEFINES) $(POLL_DEFINES)
32
 INCLUDES = $(TRANS_INCLUDES) $(RX_INCLUDES)
35
 INCLUDES = $(TRANS_INCLUDES) $(RX_INCLUDES)
33
36
(-)4.3.0/xc/registry (+2 lines)
Lines 448-453 Link Here
448
0	Internet				[23]
448
0	Internet				[23]
449
1	DECnet					[23]
449
1	DECnet					[23]
450
2	Chaos					[23]
450
2	Chaos					[23]
451
6	InternetV6				[23]
452
33	Amoeba					[8]
451
252	LocalHost				[105]
453
252	LocalHost				[105]
452
253	Kerberos5Principal			[94]
454
253	Kerberos5Principal			[94]
453
254	Netname					[57]
455
254	Netname					[57]
(-)4.3.0/xc/programs/Xserver/Xserver.man (+9 lines)
Lines 273-278 Link Here
273
.B \-broadcast
273
.B \-broadcast
274
enable XDMCP and broadcasts BroadcastQuery packets to the network.  The
274
enable XDMCP and broadcasts BroadcastQuery packets to the network.  The
275
first responding display manager will be chosen for the session.
275
first responding display manager will be chosen for the session.
276
.B \-multicast [\fIaddress\fP [\fIhop count\fP]]
277
Enable XDMCP and multicast BroadcastQuery packets to the  network.   
278
The first responding display manager is chosen for the session.  If an 
279
address is specified, the multicast is sent to that address.  If no 
280
address is specified, the multicast is sent to the default XDMCP IPv6 
281
multicast group.  If a hop count is specified, it is used as the maximum 
282
hop count for the multicast.  If no hop count is specified, the multicast 
283
is set to a maximum of 1 hop, to prevent the multicast from being routed 
284
beyond the local network.
276
.TP 8
285
.TP 8
277
.B \-indirect \fIhostname\fP
286
.B \-indirect \fIhostname\fP
278
enables XDMCP and send IndirectQuery packets to the specified
287
enables XDMCP and send IndirectQuery packets to the specified

Return to bug 24445