hostname change breaks X - how to connect 127.0.0.1 ?

Adam Jackson ajax at nwnk.net
Tue Aug 31 11:42:16 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 31 August 2004 15:02, Mike A. Harris wrote:
> Tero Karvinen tero _dot_ karvinen atta iki _dot_ fi wrote:
> > When hostname is changed, X can no longer open windows. I think
> > this could be fixed by making X connect to 127.0.0.1, but I don't
> > know how to do this.
> >
> > To repeat the problem:
> > $ xterm
> > (xterm opens normally)
> > # hostame xbreaker
> > $ xterm
> >  Xlib: connection to ":0.0" refused by server
> >  Xlib: No protocol specified
> >  xterm Xt error: Can't open display: :0.0
> > (xterm does not open)
> >
> > XFree86 has the same problem. I have seen this on Redhat 8, Redhat 9,
> > Fedora Core 1 and Fedora Core 2 on different computers and networks.
> > Searching google, groups2, gmane and asking in #xorg, #freedeesktop and
> > #xwin did not help. I have found bubble gum solutions, such as restarting
> > X and setting hostname to localhost, but they interrupt work and cause
> > other problems.
> >
> > How can I make X work normally when hostname keeps changing?
>
> To my knowledge, there's no way to do that currently.  You'd have to
> hack up something in the X server authentication code to handle hostname
> changes, but I don't think anyone's ever done that.  We've got a feature
> request for this in Red Hat bugzilla, but it's more of a general problem
> than a distribution specific one.
>
> I'm interested in hearing what other people might propose as solutions
> to this problem though also.

I propose not changing the hostname.  Give the machine a name, bind it to 
127.0.0.1 or ::1 in /etc/hosts, and never ever call hostname(1) even if you 
switch networks.  The machine's idea of its own canonical name should not 
change just because your dhcp server wants to call you 
dyn-3-1-33-7.erewhon.dom.

Alternatively you could hack the auth code to call gethostname(3) on every 
client connection, but I'd consider that to be suboptimal.

- - ajax
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBNMaIW4otUKDs0NMRAhypAJwMkOU6HigoUmVUx+3S+HMw9URTlACfQKxp
VX2uC0MXc14X1CYJ/Sz28MQ=
=+1D+
-----END PGP SIGNATURE-----



More information about the xorg mailing list