Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
sudo a gui application [solved]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
elvisd
n00b
n00b


Joined: 30 Jan 2006
Posts: 17

PostPosted: Tue Feb 14, 2006 7:45 am    Post subject: sudo a gui application [solved] Reply with quote

Hi all,

i'm trying to launch some GUI application that needs su privileges (i.ex. gdmsetup). I open my shell and type
Code:
sudo gdmsetup

The application won't start, i have this error:
Code:
(gdmsetup:7865): Gtk-WARNING **: cannot open display:


In ubuntu that worked fine for every GUi and non-GUi application. Now not. Should i configure something more to have this run?
I have installed gksu and this runs... but I'd like to know why not sudo...

Thank you all
Best regards

elvisd
________
linux_n00b


Last edited by elvisd on Tue Feb 14, 2006 9:57 am; edited 1 time in total
Back to top
View user's profile Send private message
brims
Guru
Guru


Joined: 19 Apr 2004
Posts: 492
Location: Arizona

PostPosted: Tue Feb 14, 2006 7:49 am    Post subject: Reply with quote

I don't know if this is the "official" way or if there's a better way but...
Code:
export DISPLAY=:0.0

_________________
Adopt an Unanswered Post
Report violations, duplicates, misplaced, etc
Back to top
View user's profile Send private message
elvisd
n00b
n00b


Joined: 30 Jan 2006
Posts: 17

PostPosted: Tue Feb 14, 2006 7:53 am    Post subject: Reply with quote

Thax for reply.

I have tried exporting the DISPLAY but gives me the same error.
Back to top
View user's profile Send private message
yota
n00b
n00b


Joined: 17 Jul 2005
Posts: 17
Location: Padova (Italy)

PostPosted: Tue Feb 14, 2006 7:59 am    Post subject: Reply with quote

The user root is not authorized to connect to the x server (that is owned by the user you open the graphic session with).
You can give the permission to root with:

Code:

xhost +local:root


or to erveryone:

Code:

xhost +
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Tue Feb 14, 2006 8:21 am    Post subject: Reply with quote

DO NOT use xhost. It's a colossal security hole.

You probably need to add pam_xauth.so to /etc/pam.d/sudo:
Code:

session    optional             pam_xauth.so

_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
piercey
Apprentice
Apprentice


Joined: 28 Jan 2005
Posts: 182

PostPosted: Tue Feb 14, 2006 9:31 am    Post subject: Reply with quote

or, you could just:

Code:

$  su -
# gdmsetup

_________________
[ 2008.0 X86 E8400 @ 4.0Ghz ]
Back to top
View user's profile Send private message
skellr
l33t
l33t


Joined: 18 Jun 2005
Posts: 975
Location: The Village, Portmeirion

PostPosted: Tue Feb 14, 2006 9:35 am    Post subject: Reply with quote

I've always used su -c to run GUI apps, untill today.
There are some good examples to put in your sudoers file near the bottom of this page that helps. namely env_keep=DISPLAY
http://www.gentoo.org/doc/en/sudo-guide.xml

Totaly missed noticing env_keep mentioned in the sudoers man page. :?
Back to top
View user's profile Send private message
elvisd
n00b
n00b


Joined: 30 Jan 2006
Posts: 17

PostPosted: Tue Feb 14, 2006 9:57 am    Post subject: Reply with quote

Thank you. this last reply solved my issue. :D
I have added a line like this in my /etc/sudoers file:

Code:

Defaults:elvisd env_keep=DISPLAY


Thank you!

Best regards

elvisd
___________
linux_n00b
Back to top
View user's profile Send private message
lyallp
Veteran
Veteran


Joined: 15 Jul 2004
Posts: 1557
Location: Adelaide/Australia

PostPosted: Wed Aug 01, 2007 11:44 am    Post subject: Reply with quote

I have successfully kept my DISPLAY by updating /etc/suders such that members of the wheel group keep environment variable DISPLAY only.

ecatmur wrote:
DO NOT use xhost. It's a colossal security hole.


Well, given I use xhost +local:root - ie, only root can open windows on my display, I am unsure how this can be a security hole. I fully understand if I just used xhost +

ecatmur wrote:

You probably need to add pam_xauth.so to /etc/pam.d/sudo:
Code:

session    optional             pam_xauth.so


What does this achieve? Does it make sudo use an X window to prompt for the password?
If so, it's not doing it for me.
Does this line have to be in any place in particular in the /etc/pam.d/sudo file?
I also noticed that the /etc/pam.d/sudo file is auto generated by pamd_mimic_system - so where should I be updating settings so that my mods will stay put?
_________________
...Lyall
Back to top
View user's profile Send private message
tarpman
Veteran
Veteran


Joined: 04 Nov 2004
Posts: 1083
Location: Victoria, BC, Canada

PostPosted: Wed Aug 01, 2007 3:08 pm    Post subject: Reply with quote

try gksu or kdesu
_________________
Saving the world, one kilobyte at a time.
Back to top
View user's profile Send private message
xnij2
n00b
n00b


Joined: 27 Jun 2006
Posts: 20
Location: Solna, Sweden

PostPosted: Mon Aug 06, 2007 7:55 am    Post subject: Reply with quote

The sudo env_keep trick worked great! So thanks for that Rainskellr. I've also been doing sudo -c to run gui stuff.

What about the XAUTHORITY environment variable? Should that also be exported? Seems to work without it here tho...

Code:
Defaults env_keep="DISPLAY XAUTHORITY"

(from http://gentoo-wiki.com/Sudo_config)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum