Technical article 110509

Executing xhost automatically at X server start up.

OpenServer 6.0.0OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6OpenServer 5.0.7UnixWare 7.0.0UnixWare 7.0.1UnixWare 7.1.0UnixWare 7.1.1UnixWare 7.1.2UnixWare 7.1.3UnixWare 7.1.4Open UNIX 8

Written · Last revised

Problem

I need xhost + to be invoked automatically when my X server starts up. I don't want to have to enter it manually from command line. How can I do this?

NOTE:     An example of the error you would see without running the xhost
          command, and then trying to launch a remote X client to your
          display, might be:

Error: Can't open display: <machine domain name>:0 Xlib: connection to "machine domain name:0.0" refused by server Xlib: Client is not authorized to connect to Server

Solution

The xhost command can be issued automatically when the graphical user interface (GUI) is started. The steps below outline how to accomplish this for both SCO OpenServer and UnixWare 7 running CDE Desktop.

On SCO OpenServer:
1.  As root, vi the file:
/usr/lib/X11/sys.startxrc

You will see something similar to this:

#
#       @(#) sys.startxrc 1.3 89/04/04
#
#
# Clients started by default by startx
# The last client should NOT be started in the background.
#
if [ -f /usr/bin/X11/scosession ]
then
        exec scosession 2> /dev/null
else {
        exec scoterm 2> /dev/null &
        exec pmwm    2> /dev/null
     }
fi
2.  Add the xhost command above the first uncommented line:
#
#       @(#) sys.startxrc 1.3 89/04/04
#
#
# Clients started by default by startx
# The last client should NOT be started in the background.
#

/usr/bin/X11/xhost + if [ -f /usr/bin/X11/scosession ] then exec scosession 2> /dev/null

else {
        exec scoterm 2> /dev/null &
        exec pmwm    2> /dev/null
}
fi
3. Save your changes.
Issuing xhost + will disable access control, which means ANY
remote host can send an X client to your X display.  Issuing
xhost +<hostname> disables access control only for the specified
hostname.
4.  If you are running X Windows when you make changes, be sure
to exit your X session, then start it again.  This is done either
by logging in via scologin if you have scologin enabled, or by
typing 'startx' from the system console.
UnixWare 7 using CDE Desktop:

As with OpenServer, there exists a file where the xhost entry can be placed for UnixWare 7 using CDE Desktop. The file is .dtprofile. This file must exist in the user's home directory for changes to take effect.

1. As root place a copy of .dtprofile in the user's home directory. Make sure the user has read/write/execute permissions.

2. vi this file and place the xhost entry at the very end of the
file on its own line.  Again, your results will vary depending on
how you use the xhost command.

3. Exit your X session and log back in.

4. To check that your changes have taken effect, type 'xhost'
at the command line.  The resulting output to the screen will
indicate whether access control is enabled or disabled.
NOTES:    The sys.startxrc file is intended for making changes to the X
          server on a system-wide basis. To effect changes on a specific
          user account, copy /usr/lib/X11/sys.startxrc to the specified
          user's home directory under the name .startxrc. Make sure the
          user has read/write permissions. Any changes made in the .startxrc
          file will affect that user only.

See also

xhost(X) for SCO OpenServer
xhost(X1M) for UnixWare 7

From the Xinuos technical article database, record 110509. Reproduced with permission. The original is at www.sco.com/ta/110509, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.