Re: cannot run X apps when 'su'

2002-06-18 Thread Nuno Silva



Derrick 'dman' Hudson wrote:

| Hello,
| you shouldn just copy over .Xauth files.. It will ruin root X access ;)

What do you mean, ruin root X access?  What X access does root have
in the first place?  You certainly don't 'startx' as root in the first
place, do you?


Well, you can startx as rootbut that's not the Right Way(C).

You can also have other info in ~root/.Xauthority about other X sessions 
- can be a complete X session with startx

- cookies from other sessions -- another user is su'ing to root, too
- the local machine can have several DISPLAY's :0 :1 :2...
- lots of possibilities! ;)



| The Right Way(C) is:
| # xauth merge ~user/.Xauthority

Ahh, I knew 'xauth' was the Right tool, but I couldn't (quickly)
figure out how to use it :-).  'cp' I already know :-).


That merge means really *merge*, not *overwrite* as cp does ;)

Anyway, I was talking about The Right Way(C). cp works must of the 
cases, too :-)




| ...and don't forget to set DISPLAY:
| export DISPLAY=:0

As always, unless 1) ssh takes care of it or 2) environment
inheritance is your friend (that is, it's already set properly).



Yes, it's true... But there are ways of loosing the DISPLAY var too. 
After a su - for instance.


Regards,
Nuno Silva




--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: cannot run X apps when 'su'

2002-06-18 Thread Martin Rowe
Hi all

Don't know if it's been mentioned on this thread yet, but Francois Gouget 
wrote a script, sux[1], to transfer $DISPLAY and X cookies so X apps work 
fine when assuming another user's identity. Details were posted here[2] 
about a year ago and I've appreciated it ever since. Just use it as a 
drop in replacement for su.

Regards, Martin  
[1] http://makeashorterlink.com/?U27C32511
[2] http://fgouget.free.fr/sux/
-- 
[EMAIL PROTECTED]  [EMAIL PROTECTED]  http://www.dbg400.net/\
DBG/400 - DataBase Generation utilities - AS/400 / iSeries Open\ /
Source free test environment tools and others (file/spool/misc) X
Debian GNU/Linux | ASCII Ribbon Campaign against HTML mail  news  / \


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: cannot run X apps when 'su'

2002-06-17 Thread Karsten M. Self
on Sun, Jun 16, 2002, Oleg ([EMAIL PROTECTED]) wrote:
 On Sunday 16 June 2002 10:55 pm, ttv wrote:
  Hi, when I su as root, I can't run X apps ...
 
 
  Camranh:/home/thanh# Xlib: connection to :0.0 refused by server
  Xlib: Client is not authorized to connect to Server
  emacs: Cannot connect to X server :0.0.
  Check the DISPLAY environment variable or use `-d'.
  Also use the `xhost' program to verify that it is set to permit
  connections from your machine.
 
 
  any ideas how to fix it ?
 
 xauth -f /home/${LOGNAME}/.Xauthority extract - $DISPLAY | xauth merge -

seal
Karsten M. Self Good Linuxkeeping Seal of Approval
/seal

-- 
Karsten M. Self kmself@ix.netcom.comhttp://kmself.home.netcom.com/
 What Part of Gestalt don't you understand?
   KQED FM:  The bright spot on the dial:  http://www.kqed.org/fm/


pgpYU5bxScGnJ.pgp
Description: PGP signature


Re: cannot run X apps when 'su'

2002-06-17 Thread uzoma nwosu

This is from a local LUG list:


The safe way of doing this is to use xauth.  xauth will allow you to 
set a magic cookie on your root account such that your X server will 
recognize it as being eligible to access your X server.  

First, as the non-root user who is running X type in an xterm:

xauth list $DISPLAY

which will output the xauth cookies associated with your current
display.  It should look something like:

debian/unix:0  MIT-MAGIC-COOKIE-1  f4739672dece010d7e1faf01dca9

( note, the magic cookie has been changed to protect the innocent ).  

Then in the xterm where you have used su to become root type:

xauth add $DISPLAY . f4739672dece010d7e1faf01dca9

( please note the big long number matches the one above ).  

Now your root user can access your X server and display X apps.  Since
the root user is caching the magic cookie in the .Xauthority file in 
roots homedir you will be able to display on this X server instance as
root as long as it keeps running.  


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: cannot run X apps when 'su'

2002-06-16 Thread Derrick 'dman' Hudson
On Sun, Jun 16, 2002 at 10:55:15PM -0400, ttv wrote:
| Hi, when I su as root, I can't run X apps ...

Solution 1 :
Don't su -.  If you don't put the '-' on there, su will inherit
the current process' environment and maintain xauth

Solution 2 :
# cp ~user/.Xauthority ~/

Copy your normal user's .Xauthority file to root's home directory.
That gives it the magic cookie showing the X server it has
permission to connect.

-D

-- 

Reckless words pierce like a sword,
but the tongue of the wise brings healing.
Proverbs 12:18
 
http://dman.ddts.net/~dman/



pgprpWxhIuOJg.pgp
Description: PGP signature


Re: cannot run X apps when 'su'

2002-06-16 Thread John Hasler
ttv writes:
 Hi, when I su as root, I can't run X apps ...

X apps are not secure enough to be run by root.

 any ideas how to fix it ? 

'emacs -nw' will run emacs in an xterm.
-- 
John Hasler
[EMAIL PROTECTED]
Dancing Horse Hill
Elmwood, Wisconsin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: cannot run X apps when 'su'

2002-06-16 Thread Oleg
On Sunday 16 June 2002 10:55 pm, ttv wrote:
 Hi, when I su as root, I can't run X apps ...


 Camranh:/home/thanh# Xlib: connection to :0.0 refused by server
 Xlib: Client is not authorized to connect to Server
 emacs: Cannot connect to X server :0.0.
 Check the DISPLAY environment variable or use `-d'.
 Also use the `xhost' program to verify that it is set to permit
 connections from your machine.


 any ideas how to fix it ?

xauth -f /home/${LOGNAME}/.Xauthority extract - $DISPLAY | xauth merge -

HTH
Oleg


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: cannot run X apps when 'su'

2002-06-16 Thread Nuno Silva



Derrick 'dman' Hudson wrote:

On Sun, Jun 16, 2002 at 10:55:15PM -0400, ttv wrote:
| Hi, when I su as root, I can't run X apps ...

Solution 1 :
Don't su -.  If you don't put the '-' on there, su will inherit
the current process' environment and maintain xauth

Solution 2 :
# cp ~user/.Xauthority ~/

Copy your normal user's .Xauthority file to root's home directory.
That gives it the magic cookie showing the X server it has
permission to connect.

-D



Hello,
you shouldn just copy over .Xauth files.. It will ruin root X access ;)

The Right Way(C) is:
# xauth merge ~user/.Xauthority

...and don't forget to set DISPLAY:
export DISPLAY=:0

Regards,
Nuno Silva



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: cannot run X apps when 'su'

2002-06-16 Thread Derrick 'dman' Hudson
On Mon, Jun 17, 2002 at 04:22:55AM +0100, Nuno Silva wrote:
| Derrick 'dman' Hudson wrote:
| On Sun, Jun 16, 2002 at 10:55:15PM -0400, ttv wrote:
| | Hi, when I su as root, I can't run X apps ...

| Solution 2 :
| # cp ~user/.Xauthority ~/
| 
| Copy your normal user's .Xauthority file to root's home directory.
| That gives it the magic cookie showing the X server it has
| permission to connect.

| Hello,
| you shouldn just copy over .Xauth files.. It will ruin root X access ;)

What do you mean, ruin root X access?  What X access does root have
in the first place?  You certainly don't 'startx' as root in the first
place, do you?

| The Right Way(C) is:
| # xauth merge ~user/.Xauthority

Ahh, I knew 'xauth' was the Right tool, but I couldn't (quickly)
figure out how to use it :-).  'cp' I already know :-).

| ...and don't forget to set DISPLAY:
| export DISPLAY=:0

As always, unless 1) ssh takes care of it or 2) environment
inheritance is your friend (that is, it's already set properly).

-D

-- 

Be sure of this:  The wicked will not go unpunished,
but those who are righteous will go free.
Proverbs 11:21
 
http://dman.ddts.net/~dman/



pgp1AYgqZqEPC.pgp
Description: PGP signature