DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 20th May 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default can't open display error

This is something I guess of very basic unix knowledge, but until now I have not found an answer (also because I can live with it and maybe did not look that hard for it).
The situation: I usually work as a user which is in the wheel group, if I use this user to login as a different user (even root), if I try to use an application that uses graphics I get this error:
Code:
# xpdf
Error: Can't open display:
This is xpdf, but it could be a movie etc.
Why is it?
How can I go around this?
I've read quite a few thread on the web, and if I got the point it has to do with some permission policy, but could not really understand the essence of the problem.

Could anyone explain in a comprehensible way or point me to a good tutorial?
Reply With Quote
  #2   (View Single Post)  
Old 20th May 2009
Oko's Avatar
Oko Oko is offline
Fsck Surgeon
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 733
Thanked 36 Times in 32 Posts
Default

Quote:
Originally Posted by gosha View Post
Code:
# xpdf
Error: Can't open display:
This is xpdf, but it could be a movie etc.
Why is it?
You are trying to open X client as root user on the X server which belongs to
regular user. That can be done but one needs to take care of certain permissions. I think at this point you would really benefit from reading man pages for X.Org because that was really elementary question.
Reply With Quote
  #3   (View Single Post)  
Old 20th May 2009
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 534
Thanked 14 Times in 13 Posts
Default

hi gosha, A common reason that can happen is that when you switch over to the new login, the DISPLAY environment variable is not set. Graphics app's need that variable to know what X display to connect to. So the fix would be simple, just set the variable with something like (for sh-type shells)

$ export DISPLAY=:0.0

or whatever the appropriate DISPLAY was before you switched users. Note: some ways of logging in will automatically set DISPLAY for you and the problem won't happen.
Reply With Quote
  #4   (View Single Post)  
Old 20th May 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

actually, before posting I did try the export DISPLAY thing, but then I get this:
Code:
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

Error: Can't open display: :0.0
Reply With Quote
  #5   (View Single Post)  
Old 20th May 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

ok, never mind, I got it working with this:
$ xhost +local:root
run as the user that started X.
But now a more general question: if root is allowed to do "anything", why does it need a special permission from a normal user to use its display?
Reply With Quote
  #6   (View Single Post)  
Old 20th May 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

You shouldn't be running X clients as root.. the fact that the X server disallows root when running as a user is a good thing.
Reply With Quote
  #7   (View Single Post)  
Old 21st May 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Actually depending on how you are running things, I believe root should be able to give him/her self access to the display without user intervention -- but it would not be polite
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #8   (View Single Post)  
Old 21st May 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

Booo at TerryP, that's like saying your boss should be allowed to come into your office and drink your coffee.

He can.. but he'll die trying.
Reply With Quote
  #9   (View Single Post)  
Old 21st May 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

I got the points, I sometimes forget about the risks of running apps as root.
Thanks
Reply With Quote
Old 21st May 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

I meant 'should' as in technically should be possible, not 'should' as in should be allowed to do so :-P
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Old 25th May 2009
sherekhan sherekhan is offline
New User
 
Join Date: May 2009
Location: Norway
Posts: 7
Thanked 0 Times in 0 Posts
Default

If you have Gnome you have the command gksudo to run graphical apps as root in the current users environment. kdesu is the same for KDE.
Reply With Quote
Old 26th May 2009
gosha gosha is offline
Spam Deminer
 
Join Date: Jun 2008
Location: China
Posts: 256
Thanked 0 Times in 0 Posts
Default

thanks for the suggestion, but I use neither gnome nor kde. I'll be fine with the xhost command and actually follow bsdfan666, that is, don't run apps as root
Reply With Quote
Old 28th May 2009
fbsduser fbsduser is offline
Shell Scout
 
Join Date: Aug 2008
Posts: 103
Thanked 4 Times in 4 Posts
Default

you can use xsu instead of gksudo/kdesu gosha.
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
dwm status bar won't display apm output asemisldkfj General software and network 6 16th August 2009 11:07 PM
How do I display Beastie next to the startup menu? troberts FreeBSD General 2 7th December 2008 02:16 PM
Odd font display TerryP Feedback and Suggestions 4 2nd November 2008 11:22 AM
Terminal display behavior 18Googol2 FreeBSD General 8 26th September 2008 02:05 PM
How do I display icons in Thunar? troberts FreeBSD Ports and Packages 2 18th September 2008 11:05 AM


All times are GMT. The time now is 06:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick