How Remote X Servers and Clients Communicate

 < Day Day Up > 



Suppose you’re logged in to a command-line shell (bash or tcsh) on HOST2. You can tell HOST2 to use HOST1 for graphical application display by specifying it on the command line of the X application you’re running:

HOST2% xemacs –display HOST1:0.0 

You can force all X applications to use HOST1 for display by setting a DISPLAY environment variable within the shell. So in your HOST2 shell you’d type

HOST2% export DISPLAY=HOST1:0.0

for the Bourne shell (sh, bash), or

HOST2% setenv DISPLAY HOST1:0.0

for the C shell (csh, tcsh).

Now when you run xemacs, instead of trying to display itself on HOST2 (which may or may not be running an X server), it will attempt to display itself on HOST1. The flow of the X client/server model is illustrated here:

click to expand

What does the :0.0 mean after the HOST1 string in the DISPLAY variable? A single host can conceivably run multiple X servers. Each X server can control multiple screens. The format of the DISPLAY variable is as follows:

DISPLAY = <hostname>:<displaynumber>.<screennumber>

Where

  • <hostname>   Indicates the name or IP address of the host running the X server

  • <displaynumber>   Indicates which X server the X clients should use, with 0 being the first

  • <screennumber>   Indicates which screen on the X server should be used, with 0 being the first

Unless you’re using an interesting and atypical X server configuration, your DISPLAY will almost always be :0.0. In fact, you can leave off the trailing .0 because it assumes screen 0 by default.

X servers listen on TCP port 6000 by default. If a second X server (a display) was run on the same box, it would listen on TCP port 6001. The display number that the X server is using can always be mapped to the corresponding TCP port by adding 6000 to the display number.

You may see a bit of a security problem in this client/server model. Setting the environment variable lets us tell the client on HOST2 to display on HOST1. But what’s stopping you from sending the display of the application elsewhere? One of the most popular “hacks” in security training classes is setting your DISPLAY variable to your neighbor’s X server and watching with amusement as you run numerous instances of xeyes all over his Desktop while he’s trying to do work. A more frightening abuse would be to run a program such as xkey to capture your neighbor’s keystrokes from the X server. Obviously, X servers must have some kind of access control so that only authorized clients are able to display themselves.



 < Day Day Up > 



Anti-Hacker Tool Kit
Anti-Hacker Tool Kit, Third Edition
ISBN: 0072262877
EAN: 2147483647
Year: 2004
Pages: 189

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net