[PATCH 4/7] dix: Extend initial connection handshake for forwarding proxies
Alan Coopersmith
alan.coopersmith at oracle.com
Fri Jun 17 19:22:43 PDT 2011
Sounds like a protocol change that should be documented in the core protocol
spec. (Maybe even finally bump the protocol version from R6 to R7.)
Does seem like a neat solution to the problem though.
-alan-
On 06/17/11 11:36 AM, Adam Jackson wrote:
> Forwarding proxies like sshd will appear to be local, even though they
> aren't really. This leads to weird behaviour for extensions that truly
> require running under the same OS services as the client, like MIT-SHM
> and DRI2.
>
> Add two new legal values for the initial connection's byteOrder field,
> 'r' and 'R'. These act like 'l' and 'B' respectively, but have the side
> effect of forcing the client to be treated as non-local. Forwarding
> proxies should attempt to munge the first packet of the connection
> accordingly; older servers will reject connections thusly munged, so the
> proxy should fall back to passthrough if the munged connection attempt
> fails.
>
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
> dix/dispatch.c | 12 +++++++++---
> os/connection.c | 10 +++++-----
> 2 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/dix/dispatch.c b/dix/dispatch.c
> index 192c8c3..ac9d7f9 100644
> --- a/dix/dispatch.c
> +++ b/dix/dispatch.c
> @@ -3569,12 +3569,14 @@ ProcInitialConnection(ClientPtr client)
> REQUEST(xReq);
> xConnClientPrefix *prefix;
> int whichbyte = 1;
> + char order;
>
> prefix = (xConnClientPrefix *)((char *)stuff + sz_xReq);
> - if ((prefix->byteOrder != 'l') && (prefix->byteOrder != 'B'))
> + order = prefix->byteOrder;
> + if (order != 'l' && order != 'B' && order != 'r' && order != 'R')
> return client->noClientException = -1;
> - if (((*(char *) &whichbyte) && (prefix->byteOrder == 'B')) ||
> - (!(*(char *) &whichbyte) && (prefix->byteOrder == 'l')))
> + if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) ||
> + (!(*(char *) &whichbyte) && (order == 'l' || order == 'r')))
> {
> client->swapped = TRUE;
> SwapConnClientPrefix(prefix);
> @@ -3586,6 +3588,10 @@ ProcInitialConnection(ClientPtr client)
> {
> swaps(&stuff->length, whichbyte);
> }
> + if (order == 'r' || order == 'R')
> + {
> + client->local = FALSE;
> + }
> ResetCurrentRequest(client);
> return Success;
> }
> diff --git a/os/connection.c b/os/connection.c
> index fbc8e40..dd7b066 100644
> --- a/os/connection.c
> +++ b/os/connection.c
> @@ -881,7 +881,7 @@ ErrorConnMax(XtransConnInfo trans_conn)
> xConnSetupPrefix csp;
> char pad[3];
> struct iovec iov[3];
> - char byteOrder = 0;
> + char order = 0;
> int whichbyte = 1;
> struct timeval waittime;
> fd_set mask;
> @@ -894,16 +894,16 @@ ErrorConnMax(XtransConnInfo trans_conn)
> FD_SET(fd, &mask);
> (void)Select(fd + 1, &mask, NULL, NULL, &waittime);
> /* try to read the byte-order of the connection */
> - (void)_XSERVTransRead(trans_conn, &byteOrder, 1);
> - if ((byteOrder == 'l') || (byteOrder == 'B'))
> + (void)_XSERVTransRead(trans_conn, &order, 1);
> + if (order == 'l' || order == 'B' || order == 'r' || order == 'R')
> {
> csp.success = xFalse;
> csp.lengthReason = sizeof(NOROOM) - 1;
> csp.length = (sizeof(NOROOM) + 2) >> 2;
> csp.majorVersion = X_PROTOCOL;
> csp.minorVersion = X_PROTOCOL_REVISION;
> - if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
> - (!(*(char *) &whichbyte) && (byteOrder == 'l')))
> + if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) ||
> + (!(*(char *) &whichbyte) && (order == 'l' || order == 'r')))
> {
> swaps(&csp.majorVersion, whichbyte);
> swaps(&csp.minorVersion, whichbyte);
--
-Alan Coopersmith- alan.coopersmith at oracle.com
Oracle Solaris Platform Engineering: X Window System
More information about the xorg-devel
mailing list