[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: xhost +localhost doesn't work



On Sat, Oct 26, 2002 at 06:32:53AM -0500, Larry Alkoff wrote:
> Here is what I would expect to work:     (I think it _used_ to work)
>   As user:
>   xhost +localhost
>   su
>   synaptic                  Now get error Synaptic: could not open display
> 
> Here is what works:
>   As user:
>   xhost +                                         Opening up to the world
>   su
>   export DISPLAY=:0                   I didn't use to do this - did I?
>   synaptic
> 
> Am I doing something wrong or did I break something?

It's Not A Bug, It's A Feature(TM).  I'm not completely up on the whole
X auth thing, but I'm fairly sure this is how it's supposed to work.
Try setting the XAUTHORITY environment variable (after the su) to
/home/<user_running_X>/.Xauthority, and then run a program.  That
_should_ work.

<explanation type="half-arsed">
The X security system requires a `magic cookie' before
you're allowed to connect to a running server.  This cookie is stored in
~/.Xauthority when you start up X, and this location is exported in
XAUTHORITY environment variable.  When you try to start a program, the
xlibs look at this environment variable, then try to read in the file,
then use the cookie to authenticate to the X server.  If I run a program
as another (normal) user and try to connect to my X session, then they
either won't have the XAUTHORITY variable set, and thus be unable to
find my cookie, or else they won't have permission to read the file
(it's 600, by default).  root can read any file on the system tho, so
it's just a matter of setting the XAUTHORITY variable to the location of
your cookie file.  You shouldn't ever `xhost +', especially just for
running local programs as another user.  You'll probably need to export
DISPLAY as well, so the program knows which display to connect to.
</explanation>
 
> As a workaround I've installed sudo, added a group wheel and added myself to that group.
> Now I can simply type
> sudo synaptic
> and it works fine without the need to use xhost.

Why don't you like using sudo?  Seems to be a much easier solution, and
more secure to boot.

-rob

Attachment: pgpJyjDTvGfFE.pgp
Description: PGP signature


Reply to: