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.startxrcYou 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 }
fi2. 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}fi3. 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 OpenServerxhost(X1M) for UnixWare 7