LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-10-2003, 11:36 PM   #1
Smerk
Member
 
Registered: Oct 2002
Location: Cairnsian, Oz
Distribution: Debian testing/unstable, knoppix/debian fudged router!
Posts: 169

Rep: Reputation: 30
can't open Xprograms when su


I am attempting to run graphical programs from the console as root.

the scenario is:
running kde as normal user, open up console su to root, enter command eg: ethereal and I get the following:

Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified


(ethereal:1613): Gtk-WARNING **: cannot open display:

how do I go about fixing this?

(when as normal user i start the program it works fine, apart from the fact that ethereal won't give me access to the interfaces..! thus the need to su!)
 
Old 10-10-2003, 11:53 PM   #2
Col Panic
Member
 
Registered: Oct 2003
Distribution: Red Hat 9
Posts: 93

Rep: Reputation: 15
sudo yourself if you need to do this alot.
if it's a once in a while thing try this:
xhost +localhost
su -
export $DISPLAY


if you see :0 or :00 you are good to go. If not:

export DISPLAY=:0

then you are su'd in X

when yer done type
xhost -
to get rid of everything.


edit:
i cainet speele reel gud.
 
Old 10-11-2003, 12:06 AM   #3
Smerk
Member
 
Registered: Oct 2002
Location: Cairnsian, Oz
Distribution: Debian testing/unstable, knoppix/debian fudged router!
Posts: 169

Original Poster
Rep: Reputation: 30
hmm.. didn't seem to work:
here is what I did:
ben@zeus:~$ xhost +localhost
localhost being added to access control list
ben@zeus:~$ su -
Password: XXXX
zeus:~# export $display
declare -x HOME="/root"
declare -x HZ="100"
declare -x LOGNAME="root"
declare -x MAIL="/var/mail/root"
declare -x OLDPWD
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"
declare -x PS1="\\h:\\w\\\$ "
declare -x PWD="/root"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x TERM="xterm"
declare -x USER="root"
zeus:~# export DISPLAY=:0
zeus:~# /usr/local/thunderbird/thunderbird
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified


(thunderbird-bin:1794): Gtk-WARNING **: cannot open display:
zeus:~#

what have I done wrong?! and will running thunderbird as su bring up the wrong profile (sorry to sort of change topic mid way..!)
 
Old 10-11-2003, 12:11 AM   #4
krussell
Member
 
Registered: Jul 2003
Location: dhaka
Distribution: Slackware 11 (fixed), MEPIS
Posts: 241

Rep: Reputation: 30
smerk, why don't you run apps in su mode by > Run>Options>Run as different user .....something like this.
 
Old 10-11-2003, 12:19 AM   #5
Smerk
Member
 
Registered: Oct 2002
Location: Cairnsian, Oz
Distribution: Debian testing/unstable, knoppix/debian fudged router!
Posts: 169

Original Poster
Rep: Reputation: 30
Sorry krussel, you have lost me there..!

to elaborate a little more.. the program being launched is from an event being captured by acpid which runs as root.
this then runs a script (as root) that tries to launch my email client, which fails because X11 won't open a gui from an su'd console.

I hope this isn't getting to confusing.

smerk.
 
Old 10-11-2003, 12:42 AM   #6
Col Panic
Member
 
Registered: Oct 2003
Distribution: Red Hat 9
Posts: 93

Rep: Reputation: 15
Xlib: connection to ":0.0" refused by server

Sounds like it did let you su in X, but it still won't open your GTK app. I know in redhat 9 there are a few things you just can't do unless logged in as root, not just su'd or su - 'd . Like edit Motd or visudoer. Work fine if I log in as root but no other way.

I'm sure you've tried, but su with the '-' paramater and see if it's the same error
sudo yourself
log in as root and try the same thing
I'm curious to see if anything different happens
 
Old 10-11-2003, 12:59 AM   #7
Smerk
Member
 
Registered: Oct 2002
Location: Cairnsian, Oz
Distribution: Debian testing/unstable, knoppix/debian fudged router!
Posts: 169

Original Poster
Rep: Reputation: 30
as user 'ben'
sudo -u 'user' /etc/acpi/email.sh works fine!

logged in as root:
zeus:/etc/acpi# sudo -u ben /usr/local/thunderbird/thunderbird
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified


(thunderbird-bin:2099): Gtk-WARNING **: cannot open display:

if logged in as root (i.e before starting x then can start programs no problems from console window.

I guess it may be a debian thing..
 
Old 10-11-2003, 09:38 PM   #8
Col Panic
Member
 
Registered: Oct 2003
Distribution: Red Hat 9
Posts: 93

Rep: Reputation: 15
I hate to think that's it's a distro specific problem. But the way I told you to be su in X allows me to do almost anything in Gnome on red hat that I could do as root. Wierd.

Hopefully someone else will pipe in with a suggestion.


E D I T
there's always chmod 7777 <fDirectory path>
but thats a bit lax in security......

Last edited by Col Panic; 10-11-2003 at 09:40 PM.
 
Old 11-01-2003, 11:03 PM   #9
tunacat
LQ Newbie
 
Registered: Nov 2003
Posts: 1

Rep: Reputation: 0
Try running
xhost +local:localhost
as your normal account. Then 'su -'. Make sure to export DISPLAY=:0

That should do the trick.
 
Old 11-20-2003, 08:48 PM   #10
xsis4me
LQ Newbie
 
Registered: Nov 2003
Distribution: Debian
Posts: 2

Rep: Reputation: 0
Thanx tunacat!
I was having the same problem with debian!
I ran what you suggested:

xhost +local:localhost

Then su'd
Then ran the program and it was fine.
i did not have to export though.
I may have done it before because I've been working on this trying for a while
some of the solutions i found here using search.
Should i when i'm finished run

xhost -

I read somewhere adding the localhost to xhost is a security risk?
Thanx for the help

xsis4me
 
Old 11-20-2003, 08:50 PM   #11
xsis4me
LQ Newbie
 
Registered: Nov 2003
Distribution: Debian
Posts: 2

Rep: Reputation: 0
Thanx tunacat!
I was having the same problem with debian!
I ran what you suggested:

xhost +local:localhost

Then su'd
Then ran the program and it was fine.
i did not have to export though.
I may have done it before because I've been working on this trying for a while
some of the solutions i found here using search.
Should i when i'm finished run

xhost -

I read somewhere adding the localhost to xhost is a security risk?
Thanx for the help

xsis4me
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Novell to Open SuSE Pro for open development HenchmenResourc Linux - News 0 08-02-2005 10:57 PM
open ports on linksys, i have ssh open but thats it PlatinumRik Linux - Security 1 07-07-2005 10:38 AM
Evolution - open word docs with open office (not KWord) bcarl314 Mandriva 1 06-11-2005 09:18 AM
installed open office from linuxpackages.net, don't know how to open it salviadud Slackware 7 04-15-2005 10:28 AM
im install amule there is more way to open him up its annoying to open him from shel SlackwareMan Linux - Software 1 07-31-2004 08:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration