sudo doesnt open X programs

Hi.

I am using OpenSuse 11.1 and i cant find a way to make sudo open X
programs like gedit

Code:

diego@linux-8mmd:~> sudo gedit
No protocol specified

(gedit:5500): Gtk-WARNING **: cannot open display: :0.0

diego@linux-8mmd:~> sudo xhost +localhost
xhost: unable to open display “”


gnomesu works, but it asks for password.


epsilon_da

epsilon_da’s Profile: http://forums.opensuse.org/member.php?userid=19373
View this thread: http://forums.opensuse.org/showthread.php?t=405624

Hi
Use xdg-su, for example;


xdg-su -c "gedit /etc/hosts"


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel 2.6.27.7-9-default
up 3 days 9:58, 3 users, load average: 0.30, 0.21, 0.24
GPU GeForce 6600 TE/6200 TE - Driver Version: 180.22

thanks, better than gnomesu, but still asking for password, and is more
complicated to type in the console.


epsilon_da

epsilon_da’s Profile: http://forums.opensuse.org/member.php?userid=19373
View this thread: http://forums.opensuse.org/showthread.php?t=405624

epsilon_da;1931307 Wrote:
> Hi.
>
> I am using OpenSuse 11.1 and i cant find a way to make sudo open X
> programs like gedit
>
> >
Code:

> > diego@linux-8mmd:~> sudo gedit
> No protocol specified
>
> (gedit:5500): Gtk-WARNING **: cannot open display: :0.0
>
> diego@linux-8mmd:~> sudo xhost +localhost
> xhost: unable to open display “”
>

> >
>
> gnomesu works, but it asks for password.
You force the same error twice. sudo lets a process run as root and is
not allowed to open a window on the display you diego have.
Then you use sudo again running xhost as root. But root can not help
you here, it has no display. diego must run xhost. So leave out the
sudo:

Code:

diego@linux-8mmd:~> xhost +

Now you, diego, allow everybody (including root) to open a window on
your display.


Henk van Velden

hcvv’s Profile: http://forums.opensuse.org/member.php?userid=180
View this thread: http://forums.opensuse.org/showthread.php?t=405624

Thank you.

Very good explanation.

I just did “xhost +” as user “diego” and now sudo is able to run X
programs.

Now just to ask… is there a way to only allow sudo in the xhost’s
list?


epsilon_da

epsilon_da’s Profile: http://forums.opensuse.org/member.php?userid=19373
View this thread: http://forums.opensuse.org/showthread.php?t=405624

It is not the command -sudo, -but the user -root -you have to allow. And
indeed, a plain -xhost + -does allow “anybody” to open windows before
your very nose :frowning: . Now do not be to afraid of this, Those from other
systems are normaly blocked from doing so by your firewall. And those
from inside your system … well, when this is a pc there will not be
very many.

But yes you can restrict. Your -+localhost -is restricting it to those
comming from localhost (127.0.0.1), that is “inside”.

You could read the -man xhost- page (as I did). It talks about
usernames, but I can not find out how :frowning: . But as said, -localhost -may
be enough security.

BTW I think (but not quite sure, please test) that once a + entry is
added to the list, it stayes there over the following log-ins (somewhere
in a -.X*- or -.x*- file in your home directory). Just a

Code:

xhost

will tel you what the situation is. Eventualy first do a

Code:

xhost -

before a more restricting

Code:

xhost +localhost


Henk van Velden

hcvv’s Profile: http://forums.opensuse.org/member.php?userid=180
View this thread: http://forums.opensuse.org/showthread.php?t=405624