Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Can't connect to Xserver
Hello all,
I am trying to pop up a messagebox in KDE4 from a background process. In order to test this, I have opened a real console (CTRL-ALT-F1) and su-ed to root.
According to ps ax | grep X, X is running on display :0 and VT8: /usr/bin/X :0 vt8 -br -nolisten tcp -auth /var/run/xauth/A:0-9tDrka
Now my problem is that I can't connect to the X server from a console. This is the error message that I get when entering this command: export DISPLAY=:0 && kdialog --msgbox "Hello world"
returns: kdialog: cannot connect to xserver :0
Thinking that this might have to do something with allowed connections, I tried to set xhost: export DISPLAY=:0 && xhost +localhost
which returns xhost: unable to open display ":0"
For DISPLAY I tried :0, :1, :0.0, :0.1, :1.0, :1,1, but to no avail.
From a virtual console (pts/0) it is no problem to pop up message boxes.
I am running Debian Squeeze, KDE 4.4.5, kernel 2.6.32-5-amd64
Anyone who has some tips on how to accomplish this, or how to find out which DISPLAY to use?
xhost must be executed in a terminal window and after that you can try to access it from your console.
executing xhost in the console will not work (it is not allowed to modify access outside of the X windows)
Last edited by pan64; 03-26-2012 at 06:40 AM.
Reason: mistyped
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
pan64: Something is starting to dawn now.
Console is considered something different than Xterm. Xterm is able to connect to the Xserver, but Console cannot because it is an external connection. So from Xterm the xhost command has to be issued, and then Console should be able to connect?
Let me experiment with that later.
xhost is used to set access control. By default the owner of the xserver (the user who started that session) will be able to modify it. Xterm is started within the session, so there is no problem with it, but when you want to start something from the console....
So you need to switch off access control - that is xhost +, you can execute it in the Xterm window - and than you can make connections from outside.
in the real unix/linux life the X windows system is a client/server pair of applications, the Xserver itself is owned by root, and is usually named X or Xorg. It is only used to draw the content on the display. The client side is called session manager and this is owned by the user. All the applications within a session connect to the session manager, and the manager takes care about the access rights (to itself).
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Good, thanks for pointing me in the right direction.
What I did is this:
I am logged in into KDE as jlinkels
In Xterm I issued the command xhost +localhost
Then in Console (TTY1), logged in as jlinkels, the kdialog command succeeded.
However, as root it did not. Which is understandable according to the text in your post.
When I tried: root# su - jlinkels -c "export DISPLAY=:0 && kdialog \"Hello\""
this worked as well.
The script I am writing will be running with root credentials. So by using the su command and specifying this user, I can pop up a dialog for this user. Would that be the correct approach?
I don't know if you noticed but the -nolisten tcp option sounds like X won't be listening to anything you want to send it through network, even if it's from localhost.
you would need to read the man page of xhost..http://www.manpagez.com/man/1/xhost/.
xhost +localhost will allow to connect from console or from another x session on the localhost but only for the same user.
xhost +root will allow the user root to connect.
xhost + will completely switch off access control, so anyone can connect from anywhere.
I just tried adding xhost +localhost on my computer (runs with -nolisten tcp) and just got kicked out of trying to run one application from a VT (as I expected, as a matter of fact).
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Quote:
Originally Posted by eantoranz
I don't know if you noticed but the -nolisten tcp option sounds like X won't be listening to anything you want to send it through network, even if it's from localhost.
I did see the -nolisten. But:
- I know I am able to connect from other hosts over ssh, using ssh -x, which means there connection possible from the localhost. (I believe ssh -x acts like a tunnel)
- Turning off -nolisten in Debian is one of the best kept secrets in the X environment. Googling yields hundreds of solutions telling (a) to switch this off in /etc/X11/xinit/xserverrc, but this file and directory doesn't exist or (b) grep in /etc/ and subfolders for the string nolisten, which is not found.
Ref. the second paragraph, I would be extremely happy if someone can tell me how to switch off this option so I can experiment with it. It is not funny to see how numerous parrot posters on forums simply repeat (verbatim): "you have to turn off this option by editing xserverrc".
That might be an idea. I did browse thru the man page, but I might have missed a paragraph or two...
Quote:
Originally Posted by pan64
xhost +localhost will allow to connect from console or from another x session on the localhost but only for the same user.
xhost +root will allow the user root to connect.
Let me try that as well.
Quote:
Originally Posted by pan64
xhost + will completely switch off access control, so anyone can connect from anywhere.
Although this network is behind a NATted router and the local network is completely trusted, I don't think that is a good thing to do. Even if it is safe, it is a brute force approach. I think you gave this example as how not to set the permissions, right?
Although this network is behind a NATted router and the local network is completely trusted, I don't think that is a good thing to do. Even if it is safe, it is a brute force approach. I think you gave this example as how not to set the permissions, right?
You are right, xhost + is not suggested anyway. But if you want to test if it works you can give it a try. This is the simplest way to check the configuration. xhost - will switch on access control again.
... /etc/X11/xinit/xserverrc, but this file and directory doesn't exist or ...
Ok that got me because on one of my Debian machines i do have that file, but some others not. I know that because of this post. The package that generates it is xbase-clients.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Quote:
Originally Posted by ukiuki
Ok that got me because on one of my Debian machines i do have that file, but some others not. I know that because of this post. The package that generates it is xbase-clients.
Regards
Weird, I am running Squeeze as well. But on none of the machines I originally installed with Squeeze this directory or file is present. On upgraded machines this file is present, and on the sole Lenny machine which I haven't touched for 730 days the file is there as well.
Frankly I despise the Xorg/KDM/KDE policy to hide, move, rename or obsolete configuration files. If the config files are still present and being used they can be in 17 different locations, and on top of that Debian applies its own policy of using or ignoring files. Xorg/KDM/KDE is not the easiest by nature alone, and we could do without additional obfuscation.
jlinkels
OT1: Love to see that configuration in the post you are referring to. I used to sell those machines in 1998 with Win98 installed. Yikes!
OT2: Your statement about Facebook could not be more true! Someday I would expect Facebook to collect all information about my machine, web pages I have visited and whatnot, and then add me to a community: "Hi jlinkels: we thought you might like to know that all these people have visited amazon.com like you did, so we added you to that group. You will receive all mail from those group members, and we carefully have hidden the unsubscribe button"
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Original Poster
Rep:
Quote:
Originally Posted by pan64
xhost +root will allow the user root to connect.
No, it doesn't. xhost considers root as a hostname. As I understand if I want to use a name, it should be a nis name. I do have nis running, but root is a local account.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.