CLX display naming (was Re: Picking Nits on new build)
Daniel Barlow <[email protected]> Tue, 01 Jul 2003 13:36:44 +0100
| Newsgroups | gmane.lisp.cmucl.devel,gmane.lisp.clx.devel |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [ Apologies to cmucl-imp readers for the extensive quoting. You may want to reply to portable-clx-devel only ] On cmucl-imp, Eric Marsden <[email protected]> writes: >>>>>> "hr" == Hannu Rummukainen <[email protected]> writes: > > hr> Note that the C language X library special cases unix in display > hr> names, so that unix:0.0 makes a local connection. A google > > indeed, Paul Foley made the same comment. I haven't been able to find > anywhere in the X documentation that describes this, but in the Xlib > source code there is a comment above the function > xc/lib/X11/ConnDis.c:_X11TransConnectDisplay that says > > /* > * Attempts to connect to server, given display name. Returns file descriptor > * (network socket) or -1 if connection fails. Display names may be of the > * following format: > * > * [protocol/] [hostname] : [:] displaynumber [.screennumber] > * > * The second colon indicates a DECnet style name. No hostname is interpretted > * as the most efficient local connection to a server on the same machine. > * This is usually: > * > * o shared memory > * o local stream > * o UNIX domain socket > * o TCP to local host > * > * This function will eventually call the X Transport Interface functions > * which expects the hostname in the format: > * > * [protocol/] [hostname] : [:] displaynumber > * > */ > > > Together with the special casing of the "unix" hostname (which > requests a Uhix transport) this leads to the following interpretations > of the DISPLAY environment variable: > > :0 most efficient local transport (unix) > localhost:0 TCP > unix:0 Unix to local host ("magic" hostname) > dnet/localhost:0 DECnet to localhost > tcp/unix:0 unix (because of special-casing of It strikes me that a function that does proper display name parsing would be a useful addition to "standard" CLX. I'm going to suggest - ------ open-display-name &optional (display-name (getenv "DISPLAY")) Parse the supplied display-name, which is expected to be in the format [protocol/] [hostname] : [:] displaynumber [.screennumber] to extract the protocol, host and display number. The parsing matches that done in the Xlib C language bindings - there are two special cases: - If the hostname is ``unix'' or the empty string, any supplied protocol is ignored and a connection is made using the :local transport. - If a double colon separates hostname from displaynumber, the protocol is assumed to be decnet. OPEN-DISPLAY-NAME always attempts to do display authorization. The hostname is resolved to an address, then authorization data for the (protocol, host-address, displaynumber) triple is looked up in the file given by AUTHORITY_PATHNAME (typically $HOME/.Xauthority). If the protocol is :local, or if the hostname resolves to the local host, authority data for the local machine's actual hostname (as returned by gethostname(3)) is used instead. - ---- Comments? The description of xauth defaulting is frightening, but in that respect it does actually reflect the scariness of the xauth defaulting. - -dan - -- http://www.cliki.net/ - Link farm for free CL-on-Unix resources -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/AYBiHDK5ZnWQiRMRAmKhAJ9+9QDCp4Zzr4QBkEjYQdBZ/SF8jgCguwoS YCD2Q00YYb/6zXYA2ynHsIc= =fKu3 -----END PGP SIGNATURE-----