You are not logged in.

#1 2003-09-17 05:10:44

kakabaratruskia
Member
From: Santiago, Chile
Registered: 2003-08-24
Posts: 596

Why can't I open an X based program as root?

Everytime I try to open some X based program from Konsole as root (logged as another user in KDE) it gives me this error:
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified


Gtk-WARNING **: cannot open display: :0.0


And where were all the sportsmen who always pulled you though?
They're all resting down in Cornwall
writing up their memoirs for a paper-back edition
of the Boy Scout Manual.

Offline

#2 2003-09-17 09:16:16

andy
Member
From: Germany
Registered: 2002-10-11
Posts: 374

Re: Why can't I open an X based program as root?

You have to merge the Xauthoruty cookies. Read the manpage to xauth (and look for the exmaple) or search google for "xauth merge root" and you'll find a lot of detailed descriptions. E.g. :
http://returntonature.com/pipermail/lin … 04529.html

Actually, I sometimes simpify it by simply copying the users's .Xauthority to /root/ :-) this works as long as root doesn't need to display anywhere else.

Offline

#3 2003-09-17 12:20:19

red_over_blue
Member
Registered: 2003-07-19
Posts: 152

Re: Why can't I open an X based program as root?

Another workaround is for the normal user to give permission for other users to use X on their display, then have root specify that he/she wants to use that display:

[john@limbo john]$ xhost +
access control disabled, clients can connect from any host
[john@limbo john]$ su -
Password: 
[root@limbo root]# export DISPLAY=localhost:0.0

and once you are done:

[john@limbo john]$ xhost - 
access control enabled, only authorized clients can connect
[john@limbo john]$ 

Don't forget to post your PKGBUILD in your thread when you announce a new package in incoming.
see HERE for details

Offline

#4 2003-09-17 15:44:25

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: Why can't I open an X based program as root?

Or even better, install sudo and set it up correctly.  Then you just need to type 'sudo program-to-run-as-root' and it'll display in X properly.


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#5 2003-09-17 17:54:56

kakabaratruskia
Member
From: Santiago, Chile
Registered: 2003-08-24
Posts: 596

Re: Why can't I open an X based program as root?

I didn't understand how to do the first thing. So I did what re_over_blue told me, but when I try to open a program it gives me this error.
Gtk-WARNING **: cannot open display: localhost

Then I can't do the command xhost -,and I can't open X program as my user anymore.


And where were all the sportsmen who always pulled you though?
They're all resting down in Cornwall
writing up their memoirs for a paper-back edition
of the Boy Scout Manual.

Offline

#6 2003-09-18 05:48:13

hApy
Member
From: Victoria, BC
Registered: 2003-04-13
Posts: 194
Website

Re: Why can't I open an X based program as root?

this may be a bit of a hack (not sure) but it works perfectly for me.

in my .bashrc (for users & root) I have the line:

xhost +localhost > /dev/null

Hapy.

Offline

#7 2003-09-18 12:17:27

red_over_blue
Member
Registered: 2003-07-19
Posts: 152

Re: Why can't I open an X based program as root?

kakabaratruskia,

Hi.  The only help I can offer is to make sure that you are entering the commands correctly and as the correct user.

[john@limbo john]$ xhost +
access control disabled, clients can connect from any host 

is run by the normal user.  This tells X that the normal user will allow others to use his/her display.

[root@limbo root]# export DISPLAY=localhost:0.0 

This is run as root.  Make sure to include the 0.0 at the end of localhost (that should work in most cases if you are running a single X session).  localhost is the machine that you want to use X on, and 0.0 specifies the X session.  If you aren't sure what to put _after_ localhost, try this as a _normal_ user:

[john@limbo john]$ echo $DISPLAY
:0.0

Hope this clarifies my previous post.


Don't forget to post your PKGBUILD in your thread when you announce a new package in incoming.
see HERE for details

Offline

Board footer

Powered by FluxBB