You are not logged in.

#1 2010-08-27 22:03:09

daedalusman
Member
From: CO, USA
Registered: 2006-12-05
Posts: 258

[SOLVED] sudo gui apps cannot connect to xserver from terminal app

I just started getting this error about a week ago.

sudo kwrite /etc/pacman.conf
Password: 
No protocol specified
kwrite: cannot connect to X server :0.0

Prior to that time this worked just as it would without the sudo command preempting, it would just run the gui application. I made no configuration changes but I have updated my system in that time period. Was there a change to sudo or somewhere in KDE that would cause this change in behavior? Or is there something I can do to get this working like it used to a few weeks ago?

Thanks for any help.

Last edited by daedalusman (2010-08-29 20:04:45)

Offline

#2 2010-08-28 01:04:52

keripix
Member
From: Indonesia
Registered: 2009-12-13
Posts: 22
Website

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

maybe you could use:

kdesu kwrite /etc/pacman.conf


'I skate to where the puck is going to be, not where it has been.'
--Wayne Gretzky--

Offline

#3 2010-08-28 01:32:17

*vitali*
Member
Registered: 2009-12-20
Posts: 83

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

run "xhost +".
I added this to kde autostart, you should now be able to launch all GUI program from root.

Offline

#4 2010-08-28 04:47:52

daedalusman
Member
From: CO, USA
Registered: 2006-12-05
Posts: 258

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

*vitali* wrote:

run "xhost +".
I added this to kde autostart, you should now be able to launch all GUI program from root.

I have never done this before and up until about a week ago I never had this problem. So why would I have to do this now?

Offline

#5 2010-08-28 08:21:42

Labello
Member
From: Germany
Registered: 2010-01-21
Posts: 315
Website

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

keripix wrote:

maybe you could use:

kdesu kwrite /etc/pacman.conf

this is the right way to go!


"They say just hold onto your hope but you know if you swallow your pride you will choke"
Alexisonfire - Midnight Regulations

Offline

#6 2010-08-28 09:08:06

mir
Member
Registered: 2010-08-25
Posts: 59

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

Last time I checked kdesu had nothing like /etc/sudoers, or does it have something similar?

Last edited by mir (2010-08-28 09:08:23)

Offline

#7 2010-08-28 09:17:18

tsv
Member
From: UK
Registered: 2008-12-03
Posts: 71
Website

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

Not 100%, but I think this is actually a feature, to prevent random users using your X display. If you use the xhost route, it could make it possible for other users to launch programs to your X session (perhaps over SSH), So yes kdesu / gksu are the recommended path. Don't actually use them myself though, so I'm afraid I can't speak as to features.

Offline

#8 2010-08-28 11:24:16

PirateJonno
Forum Fellow
From: New Zealand
Registered: 2009-04-13
Posts: 372

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

daedalusman wrote:

I have never done this before and up until about a week ago I never had this problem. So why would I have to do this now?

Sudo was updated recently, and no longer preserves some environment variables like HOME. See the /etc/sudoers file for details (it says how to fix this too). I'm not sure which is less secure - preserving HOME or running xhost + all the time...

Last edited by PirateJonno (2010-08-28 11:25:55)


"You can watch for your administrator to install the latest kernel with watch uname -r" - From the watch man page

Offline

#9 2010-08-28 16:09:44

*vitali*
Member
Registered: 2009-12-20
Posts: 83

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

How about a bashrc alias sort of like
alias sudo='A=`alias` sudo  '
alias kwrite="xhost +; kwrite; xhost -"
alias kate="xhost +; kate; xhost -"
except it won't take arguments anymore.....

Offline

#10 2010-08-28 16:55:58

flamelab
Member
From: Athens, Hellas (Greece)
Registered: 2007-12-26
Posts: 2,160

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

xhost + and sudo is not a good security options for launching gui apps. It would be much better to use kdesu .

Offline

#11 2010-08-29 17:05:42

mir
Member
Registered: 2010-08-25
Posts: 59

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

Don't do "xhost +" without understanding the implications.

I found out that adding

"DISPLAY XAUTHORITY"

to the "env_keep" defaults (in /etc/sudoers) works smile

See

man Xsecurity

Last edited by mir (2010-08-29 17:08:04)

Offline

#12 2010-08-29 17:53:41

RobertMe
Member
From: The Netherlands
Registered: 2010-07-04
Posts: 45

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

mir wrote:

Last time I checked kdesu had nothing like /etc/sudoers, or does it have something similar?

kdesu can use sudo instead of su to gain root access. See the sudo wiki page for instructions how to do this.

Offline

#13 2010-08-29 19:42:08

Vamp898
Member
From: ドイツではまだ住んでいる
Registered: 2009-01-03
Posts: 866
Website

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

A lot of people have this problem and its very easy to solve

The Solution is, read the pacman messages at upgrade

the last upgrade of sudo told you that there is a new /etc/sudoers and there is a lot of new content in it

If you read the Comments in the "new" sudoers file you´ll find out to enable X support in seconds

Its even that easy that you just have to uncomment the already prepared lines. Really, people often ignore the "New .pacnew file" messages when upgrading there system or just delete them... its not good at all...

also you should rename the title cause this happens in GNOME and every other DE/WM too

Last edited by Vamp898 (2010-08-29 19:42:40)

Offline

#14 2010-08-29 20:04:06

daedalusman
Member
From: CO, USA
Registered: 2006-12-05
Posts: 258

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

Thanks, Vamp898 and PirateJonno, I missed that message about the new sudoers file. Everything is back to how I like it.

Offline

#15 2010-08-29 21:11:50

mir
Member
Registered: 2010-08-25
Posts: 59

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

Hmm, I found HOME unnecessary and confusing. XAUTHORITY containts the full path to the cookie file. so there's no need to keep HOME.

Just my 2c ...

Offline

#16 2011-01-11 22:10:25

shervinkh
Member
From: Iran-Tehran
Registered: 2011-01-11
Posts: 11

Re: [SOLVED] sudo gui apps cannot connect to xserver from terminal app

Thank You So Much.I Solved It With /etc/sudoers.pacnew

Offline

Board footer

Powered by FluxBB