SlackwareThis Forum is for the discussion of Slackware Linux.
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.
I never start X as root. I'm always running as just a regular user. I would like to start up gvim as root in this regular users X session. Is this possible? When I su to root from in an xterm shell and try to start gvim I get the expected result: Cannot open up Display. Of course because root has no display session running. I was thinking root can do anything and there should be a way to barge in on someone elses X session?
Hmm, I wonder if /root had an Xauthority file I could have used that instead of the one in /home/slack? Don't think so. It is probably used to give authority to the session like it says in its name
First, before you su to root, make sure that you execute "xhost +hostname" in the shell as your non-privileged user.
Then, once you've become root, you can "export DISPLAY=hostname:0.0" and then whatever you run, anything that tries to create a new X window, will appear correctly.
EDIT: Obviously, once you've got it ironed out, you should probably put these in your shell init scripts, so you don't have to type them all the time.
I've seen that before and was thinking that could be one way.
I gotten it to work just by exporting the DISPLAY and XAUTHORITY without the "xhost +hostname". Is exporting the XAUTHORITY kinda of like using the brute force method. What is the difference between the two ways?
Originally posted by cavalier I've never heard of this option before. When you say you exported XAUTHORITY, what command line did you use?
Yeah it's cool right. I've seen of "xhost +hostname" before I just never really had a need to use it until now and wasn't sure of it use.
First I start up an xterm and the user slack of course.
Second "su - root"
Third
export DISPLAY=":0,0"
export XAUTHORITY="/home/slack/.Xauthority
Fourth gvim.
Try it. It works.
The one way the user slack has to give me permission, which of course is me so no problem. The otherway I just take it by brute force. Hell I'm root and can do anything
Interesting! I really never have seen that done before. It's very crafty, and as you said, as root, you can pretty much do whatever you want.
I guess the difference, honestly, is that with 'xhost +hostname' your user, slack, can give rights to people other than root to display things on his or her X session.
Also, if you put those commands in your .bashrc for root, for example, you'd always, as root, be trying to use the Xauthority file from the user slack, even if you logged in a root and ran X manually. Might be okay on your local desktop system, but if it were a server, there might well be times that you logged in as root, say from the console.
Further investigation shows the the .Xauthority is the key file. It contains a mit-magic-cookie used to present itselft to the server. If a user present this right mit-magic-cookie then they can start X programs.
You don't even have to export XAUTHORITY, you could just copy the file into your own home directory and then start X programs up.
It seems that xhost tells the X server not to request the mit-magic-cookie to however you tell it to allow. Also there is xauth and xauth -merge which will just outright give the mit-magic-cookie to the specific user.
Funny how I was just took an educated guess that Xauthority was the key to everything and exported it into my root shell and it worked.
Also I couldn't use "xhost +localhost" becuase I have -nolisten tcp option. I hade to use "xhost local:", which gives permission over unix sockets only.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.