Xlib: connection to "sr1-ubur-20:34.0" refused by server

Alan Coopersmith Alan.Coopersmith at Sun.COM
Fri Oct 23 08:58:19 PDT 2009


Ethan Mallove wrote:
> Hello,
> 
> It seems I suddenly can not access my own DISPLAY. All X applications
> now error out with the following, e.g.,
> 
>  $ xterm
>  Xlib: connection to "sr1-ubur-20:34.0" refused by server
>  Xlib: No protocol specified
>  xterm Xt error: Can't open display: sr1-ubur-20:34.0
> 
> Is there an xauth command that can get X working for me again?

Check your $XAUTHORITY & $HOME environment variables - those control
where libX11 looks for the cookies for authentication.
($HOME/.xauthority is the default if $XAUTHORITY is not set)

If those are set correctly and the cookie for your display is gone,
you would have to know the original magic cookie for the display in
order to re-add it with xauth, there is no "crack the display
security and recover my cookie" option.

There's two copies made at session startup - one in your $XAUTHORITY
and one in a system directory that differs by display manager (gdm,
xdm, kdm, dtlogin, startx, etc.) that's passed to the X server started
(the -auth /path/to/file you can see in the arguments when running ps)
and is usually only readable by root.  Authentication works by comparing
the one your client reads from the authority file and sends to the server
with the one the server read from it's copy of the file at startup.

I suppose it might be possible to dig through the memory of currently
connected clients with a debugger to find the cookie they used, but
I've never tried that and don't know how easy it would be.

If this is a recurring problem, things you could do when starting a
new session to protect against it in the future:
 - keep a backup of your .xauthority so you can recover the cookie
   if it gets overwritten
 - run 'xhost +si:localuser:ethan' (or whatever username you use)
   so that local connections from that uid are always accepted,
   without needing a cookie.

-- 
	-Alan Coopersmith-           alan.coopersmith at sun.com
	 Sun Microsystems, Inc. - X Window System Engineering




More information about the xorg mailing list