LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   su then open program in X fails (https://www.linuxquestions.org/questions/slackware-14/su-then-open-program-in-x-fails-369091/)

uopjohnson 10-02-2005 01:41 PM

su then open program in X fails
 
I used to be able to do this no prob... now I can't and I have no idea what changed. I'm on a fresh 10.2 install. What I would like to be able to do is su to another user and then open a program as that user. For instance firefox. However when I do this I get.

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


(firefox-bin:5392): Gtk-WARNING **: cannot open display:

any suggestions?

anomie 10-02-2005 01:48 PM

Try
Code:

sux - user_name
That should let you inherit X.

uopjohnson 10-02-2005 01:54 PM

I don't seem to have sux. I tried xhost +localhost which I saw was supposed to let me open things as another user and that didn't work either.

uselpa 10-02-2005 01:57 PM

Try sudo instead of su.

uopjohnson 10-02-2005 02:01 PM

Code:

sudo -u user firefox
gives the same error. I see that this is some sort of X server security feature, but it is damnably inconvenient.

almahdi 10-02-2005 02:15 PM

It should work this way, first in the terminal write
Code:

xhost +localhost
then
Code:

su - user
and then run any application you'd like to run like xcalc
Code:

xcalc
Let us know what goes with you.

uopjohnson 10-02-2005 02:38 PM

Code:

xhost +localhost
gives: localhost being added to access control list

Code:

su - user
gives: /dev/pts/0: Operation not permitted

Code:

xcalc
gives: Error: Can't open display:

uopjohnson 10-02-2005 02:54 PM

Ok so I did
Code:

xhost +
which disables access control and now It works. Is this a major security hole? I'm not sure how the x server would handle connections but
Code:

nmap localhost
doesn't show an open x port.

egag 10-02-2005 03:40 PM

xhost + will allow anyone to connect to your x server.
it's a securety risc.

<there was some nonsense here before editing...>

if i use " su " --->gui programs work ok without doing any settings.
if i use " su - " --->things don't work ( which is logic )


egag

imitheos 10-02-2005 04:15 PM

Re: su then open program in X fails
 
Quote:

Originally posted by uopjohnson
I used to be able to do this no prob... now I can't and I have no idea what changed. I'm on a fresh 10.2 install. What I would like to be able to do is su to another user and then open a program as that user. For instance firefox. However when I do this I get.

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


(firefox-bin:5392): Gtk-WARNING **: cannot open display:

any suggestions?

I guess that either you start your xserver with "-auth" or you use "KDM/XDM/GDM/etc".

You can use "xhost" but it is insecure.
The proper way is to use xauth authentication.

you run "xauth list" as the user that is running the xserver (the first user)
you will get some authentication keys
copy the one that is starting as "hostname/unix:0"
then su to the user you want to start the program as (the second user)
(dont run "su -" just plain "su")

then run "xauth add KEY_LINE" where KEY_LINE is the key you copied from the other user.
KEY_LINE is the whole line (it is something like this "hostname/unix:0 MIT-MAGIC-COOKIE-1 big_key")
you copy all this thing.

then every X application should work for the other user.
if you run "su -" then you get a login shell and it has the enviroment the user would have if he logged in.
then all the procedure is the same except for an addition. you should set the DISPLAY enviroment variable
(for example in a bash shell "export DISPLAY=":.0" )

uopjohnson 10-03-2005 08:29 PM

Ok... so that allows me to open things, but it does not open them as the sued to user. It opens them as the original user.

jayptr 10-05-2005 11:28 AM

I am having the same problem with using su to run a program from the command line for another user. The su command was working eariler on when I was configuring my system after installing Slackware 10.2. I noticed recently that it was not working anymore. I think it might be caused by the [slackware-security] X.Org pixmap overflow (SSA:2005-269-02) patch that was released by Pat. I haven't been able to test my theory yet, but will later today hopefully, if I have time, and I will post the results.

KMcD 10-05-2005 11:49 AM

kde has a solution to this. If you use kde go to the "run command" option in the start (k) menu and enter
Code:

kdesu firefox
to open firefox as root.

jayptr 10-05-2005 02:40 PM

For me and probably others, not everyone uses KDE. I personally use Window Maker on my Slack Box. So a real solution to the problem should be found rather than putting a band aide on it.

imitheos 10-05-2005 03:51 PM

Quote:

Originally posted by jayptr
For me and probably others, not everyone uses KDE. I personally use Window Maker on my Slack Box. So a real solution to the problem should be found rather than putting a band aide on it.
jayptr didn't the method with xauth i described work for you ?

i use slackware-current, so i have the updated X packages and i also use Windowmaker but it works ok for me.

Also, kdesu works in windowmaker too as every other KDE program. you don't have to use kde to use Kwrite for instance.
And if you don't like it there are many other "graphical su" programs


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