Book: LPI Linux Certification in a Nutshell
Section: Chapter 18.  X (Topic 2.10)



18.3 Objective 2: Set Up xdm

The X Display Manager, or xdm, is a tool to manage X sessions on physical displays both locally and across the network. Part of its job is to handle user authentication through a graphical login screen, which replaces the familiar text-mode login.

18.3.1 Configuring xdm

xdm is distributed as part of XFree86 and is configured by a series of files located in /etc/X11/xdm. These files include:

Xaccess

This file controls inbound requests from remote hosts.

Xresources

This file is similar to .Xresources, discussed earlier. It holds configuration information for some xdm resources, including the graphical login screen. This file can be edited to modify the appearance of the xdm login screen.

Xservers

This file associates the X display names (:0, :1, ...) with either the local X server software or a foreign display such as an X terminal.

Xsession

This file contains the script xdm launches after a successful login. It usually looks for .xsession in the user's home directory and executes the commands found there. If such a file doesn't exist, Xsession starts a default window manager (or environment) and applications.

Xsetup_0

This file is a script started before the graphical login screen. It often includes commands to set colors, display graphics, or run other programs. This script is executed as root.

xdm-config

This file associates xdm configuration resources with the other files in this list. It usually isn't necessary to make changes in this file unless an expert administrator plans to customize xdm configuration.

18.3.1.1 Running xdm manually

xdm uses the X server to run on your local display. Therefore, you must have a working X configuration prior to using a display manager. Then, to start xdm, simply enter it as root:

# xdm

xdm launches the X server and display the graphical login, and you can log in as usual. xdm then starts your graphical environment. After you log out, xdm resets and again displays the login screen.

Most Linux distributions enable virtual consoles. You can switch among them using the key combinations Ctrl-Alt-F1, Ctrl-Alt-F2, and so on. Typically, the first six consoles are set up as text-mode screens, and X launches on console 7 (Ctrl-Alt-F7). This means that, as with startx, your original text-mode console remains unchanged after you manually start xdm. Therefore, you must log out of your text-mode console if you plan to leave the system unattended with xdm running manually.

If you want to stop xdm, you first must be sure that all of the X sessions under its management are logged out. Otherwise, they'll die when xdm exits and you could lose data. Then simply stop the xdm process using kill or killall from a text console:

# killall xdm

Of course, xdm isn't very useful for your local system if you must always start it manually. That's why most Linux distributions include a boot-time option to start xdm for you, eliminating the text-mode login completely.

18.3.1.2 Running xdm automatically

For Linux systems using the System-V-style initialization, a runlevel is usually reserved for login under xdm. This line at the bottom of /etc/inittab instructs init to start xdm for runlevel 5:

# Run xdm in runlevel 5
x:5:respawn:/usr/X11R6/bin/xdm -nodaemon

Using this configuration, when the system enters runlevel 5, xdm starts and presents the graphical login as before. See Section 5.2 for more information on runlevels.

It's also possible to automatically start xdm simply by adding it to the end of an initialization script, such as rc.local. This method offers less control over xdm but may be adequate for some situations and for Linux distributions that don't offer runlevels.

18.3.1.3 Basic xdm customization

You may wish to personalize the look of xdm for your system. The look of the graphical login screen can be altered by manipulating the resources in /etc/X11/xdm/Xresources.[6] For example, the following excerpt shows settings to control the greeting (Welcome to Linux on smp-pc), other prompts, and colors:

[6] Note that Xresources uses ! to initiate comments.

! Xresources file
xlogin*borderWidth: 10
xlogin*greeting: Welcome to Linux on CLIENTHOST
xlogin*namePrompt: Login:\040
xlogin*fail: Login incorrect - try again!
xlogin*failColor: red
xlogin*Foreground: Yellow
xlogin*Background: MidnightBlue

You can also include command-line options to the X server in /etc/X11/xdm/Xservers if you wish to override those found in XF86Config. For example, to change the default color depth, add the -bpp (bits per pixel) option for the local display:

# Xservers file
:0 local /usr/X11R6/bin/X -bpp 24

To include additional X programs or settings on the graphical login screen, put them in /etc/X11/xdm/Xsetup_0. In this example, the background color of the X display is set to a solid color (in hexadecimal form), and a clock is added at the lower righthand corner of the screen:

#!/bin/sh
# Xsetup 
/usr/X11R6/bin/xsetroot -solid "#356390"
/usr/X11R6/bin/xclock -digital -update 1 -geometry -5-5 &

Note that in this example, xsetroot exits immediately after it sets the color, allowing the Xsetup_0 script to continue. xclock, however, does not exit and must be put into the background using an & at the end of the command line. If such commands are not placed into the background, the Xsetup_0 script hangs, and the login display does not appear.

18.3.2 X Stations

X stations, also known as X terminals, sadly are a vanishing breed of low-cost display devices for X. They are usually diskless systems that implement an X server and drive a monitor. Such devices can be configured to access a remote host to find an xdm daemon or will broadcast to the entire network looking for a "willing host" to offer xdm services. The selected system will run an X session across the network with the X terminal as the target display. With this setup, a large number of relatively inexpensive X terminals can make use of a few high-powered host systems to run graphical clients.

18.3.2.1 xdm for X terminals

To use an X terminal with your host, xdm must first be running on the host machine. The host listens for inbound connections from the X terminals using XDMCP, the xdm Control Protocol (the default port for xdmcp is 177). When a request is received, xdm responds with the same graphical login screen that's used on the local system. The difference is that the X server is implemented in the X terminal hardware, not in the XFree86 software on the xdm host, and all of the graphics information is transmitted over the network.

You can configure access to your system's xdm daemon in the /etc/X11/xdm/Xaccess file. This file is a simple list of hosts that are to be restricted or enabled. To enable a host, simply enter its name. To restrict a host, enter its name with an exclamation point (!) before it. The * wildcard is also allowed to handle groups of devices.

The following example allows access to all X terminals on the local domain but prohibits access from xterm1 on an outside domain:

*.localdomain.com
!xterm1.outsidedomain.com

On the Exam

You should be aware of the configuration files for xdm, how they are used, and where they are located. In particular, remember that the Xresources file controls graphical login properties. Also remember that xdm can be started using a special runlevel and that xdm must be running for X terminals to connect via XDMCP.