[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

The best recommendation for allowing "su" in X



Hi, I am the author of "Debian Reference" and am soliciting learned
opinion.

   What recommendation should I give to the reader for "su" in X?

Here is the back ground.  FAQ is:

  "I want to run X from a user account. It is a good thing. But how can
   I get a program which requires root privilege to run from this X
   session?"  

Answer is simple and I know this:)

  "export XAUTHORITY=$HOME/.Xauthority"

It is still a question where to put this command to avoid typing this.

1) .profile or .bash_profile : If gnome-session is used, they do the
    job. Maybe reasonable recommendation these days.  But in non-gnome
    environment, they do not work. (Because bash is not login shell)
2) .xinitrc : only works for startx. (I use this)
3) .bashrc : ugly. (.bashrc is not for ENVIRONMENT VARIABLES)
4) .xsession : Creating custom .xsession kills Debian's nice
  configuration scheme. (Way to complicated)
5) Add /etc/X11/Xsession.d/10xfree86-common_su (see below) :
  I ended up creating this file.  This is a bit too much intrusive
  action for novice users and may not be good to put in HOWTO-type
  document.
  
If this 5) is the good way, xfree86-common should install it.

Below is a discussion I had with my French translator.

>----- Forwarded message from Osamu Aoki <debian@aokiconsulting.com> -----
>From: Osamu Aoki <debian@aokiconsulting.com>
>Subject: [Qref-dev] How to allow "su" easily in X (.xinitrc .profile ...)
>To: qref-developers@lists.sourceforge.net
>Date: Sun, 7 Jul 2002 09:54:48 -0700
>User-Agent: Mutt/1.3.28i
>
>Hi Guillaume.
>On Sun, Jul 07, 2002 at 03:09:09PM +0200, Guillaume Erbs wrote:
>> Though I'm wondering if these commands must be added to $HOME/.xinitrc. 
>--- this is script for $HOME/.xinitrc ---
>#!/bin/sh
># This makes X work when I su to root.
>if [ -z "$XAUTHORITY" ]; then
>        XAUTHORITY=$HOME/.Xauthority
>        export XAUTHORITY
>fi
># invoke global X session script
>. /etc/X11/Xsession
>------------------------
>> This will work if you are running the startx script, but I'm not sure
>> it will if you are using xdm or any other session manager, which
>> reads the $HOME/.xsession file if I'm not mistaken. Are you using
>> this with xdm?
>> 
>> Anyways (and this is what I'm currently doing), one can also set the
>> $XAUTHORITY variable in his $HOME/.profile or any shell startup
>> script, and I think this is simpler this way ; the variable is kept
>> when su'ing to root.
>$HOME/.profile works in your environment because you may be using
>gnome.  Xsession script invokes x-session-manager -> gnome-session.  
>
>If one starts X without gnome-session but directly into xterm or
>x-window-manager -> sawfish to avoid panels etc., "su" does not work
>unless one explicitly exports XAUTHORITY from ones shell.  
>
>This happens because $HOME/.profile and/or $HOME/.bash_profile will not
>be read when bash is invoked in normal/classic X environment.  System
>is already logged in and login script will be skipped.
>
>If you create a file /etc/X11/Xsession.d/10xfree86-common_su :
>---
># This makes X work when I su to root.
>if [ -z "$XAUTHORITY" ]; then
>        XAUTHORITY=$HOME/.Xauthority
>        export XAUTHORITY
>fi
>----
>This always works unless Xsession is overridden by $HOME/.xsession or
>so.  (If they do, they should know. :)
>
>Let me think what is best recommendation.
>----- End forwarded message -----

-- 
~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~ +++++
 Osamu Aoki @ Cupertino CA USA
 See "Debian reference": http://www.debian.org/doc/manuals/debian-reference/
 "Debian reference" Project at: http://qref.sf.net

 I welcome your constructive criticisms and corrections.


-- 
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: