XFree86 / XDarwin and change of hostname

Tabitha McNerney tabithamc at gmail.com
Sat Feb 24 22:37:27 PST 2007

On 2/24/07, Paul Beard <paulbeard at gmail.com> wrote:
> On Feb 24, 2007, at 5:02 PM, Tabitha McNerney wrote:
> Xlib: connection to ":0.0" refused by server
> > Xlib: No protocol specified
> >
> I'm not an expert with regard to X so I wonder what to make of this. Also
> (even before I made the changes to the Computer Name), once I had X up and
> running, I could only run apps like OpenOffice from an xterm terminal shell
> but never from an OS X terminal shell. I suppose it must have something to
> do with how Xterm is configured ... are there some decent HowTos to read
> with regard to how to best set up one's bash profile on OS X in order to be
> able to run X apps from the normal terminal shell instead of requiring to
> run under Xterm, all in the context of MacPorts?
> try running xhost + in the xterm window (to allow any host to connect)
> then trying your command again. X doesn't permit connections by default.
> Once it works you can narrow it down to one or a group of hosts.

Paul, thanks very much.

Using xhost I had no success because I realized that I have an .Xauthority
file in place that was preventing changes when running xhost + in xterm (the
hidden Xauthority file specifically ~/.Xauthority must have been generated
soon after I had installed the XFree86 MacPort and run startx for the first

Tanks to your suggestions, I discovered the xauth command line tool.
xauthlet me change the .Xauthority file easily. For example, to remove
a display
name (where the display name includes the hostname), I used xauth in
interactive mode like this (note: for security purposes I have abbreviated
the hex value of the MIT-MAGIC-COOKIE-1 and made up a display name
representing the hostname that I didn't like due to a spelling error, and
also I did not list the entire output from an xauth "list" on the machine
I'm working on):

$ xauth
> Using authority file /Users/admin/.Xauthority
> xauth> list
> ComputerNameMisspelled.local/unix:0  MIT-MAGIC-COOKIE-1  xyzabc
> xauth> remove ComputerNameBad.local/unix:0

To add a new display name containing the corrected hostname, I found a web
page via Google that gave an example of how to do this for the local host
name all in one line of shell code:

$ dd if=/dev/urandom count=1|md5deep|sed -e 's/^/add :0 . /'|xauth -q
> 1+0 records in
> 1+0 records out
> 512 bytes transferred in 0.000103 secs (4971027 bytes/sec)

The first line above, I used the md5deep MacPort to create the hash from the
output of random, and then sed grabs the has and tacks it on to the input
that can be used for xauth (in quiet mode thus "-q") like this

add :0 . bbff4096504ef19a7b76bb83de4bdb2c

Apparently xauth then assume that the hostname that is part of the display
name is the current host name (it must read this when it is run) and since I
had changed my Computer Name (before running this code) from ComputerNameBad
(which under OS X changed the host name from ComputerNameBad.local) to
ComputerNameGood (host name of ComputerNameGood.local). I then end up with
something like this in .Xauthority:

$ xauth list
> ComputerNameGood.local/unix:0  MIT-MAGIC-COOKIE-1
> bbff4096504ef19a7b76bb83de4bdb2c

Then I fired up XDarwin with:

$ startx

and everything worked just fine.

All of the above commands were done in the OS X terminal shell, I didn't
need to run them in xterm.

This was a good lesson to learn and I hope its helpful to others on the list
here in the event they later need to change their ComputerNames. As much as
we'd like to believe that we live in a static world, the fact remains that
things change including names, since no one sys admin is perfect :-)



> Paul Beard
> contact info: www.paulbeard.org/paulbeard.vcf
> pictures: http://www.flickr.com/photos/pdb206/
> Are you trying to win an argument or solve a problem?
> _______________________________________________
> macports-users mailing list
> macports-users at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/macports-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-users/attachments/20070224/2970efb3/attachment.html

More information about the macports-users mailing list