tags:

views:

791

answers:

3

Greetings!

I am implementing a backup solution, and I need to access the X11 display for getting a password from the user and displaying status information. I have tried setting $DISPLAY in the script to :0.0 (hardcoded), but xhost and misc complain that they cannot open the display. What should I do?

PS: The script is here: http://dpaste.com/109435/

+4  A: 

You need the X Authentication information. I do not believe that xhost can "break in" to an X session and allow access without it (you'd need to have the user do it for you) and if you have it, then there is no need to use xhost at all.

Try

export DISPLAY=:0.0
export XAUTHORITY=/home/user/.Xauthority

and then running your commands.

Zan Lynx
+1  A: 

As stated above, the user has to allow you to access their display. They need to perform the xhost + command. It's not really a good idea to just open your display up to anyone!

You'd be better off getting them to run

xhost +jeeger

or whatever your user is running as.

HTH

cheers,

Rob

Rob Wells
+1  A: 

Thanks, you brought me on the right path. Now I execute xhost +local: in my .xinitrc, and that allows me to access the X11 display (when I export DISPLAY).

jeeger
I disagree with this, as it destroys security. As I stated in my comment, use the X authorization cookies instead of xhost.
Zan Lynx
@Zan, you mean magic cookies
Rob Wells