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

Re: X authentication and su (Re: changing framebuffer device owner during login)



On Thu, 21 Jun 2001, Vincent Zweije wrote:

> On Wed, Jun 20, 2001 at 02:59:56PM -0700, Francois Gouget wrote:
[...]
> ||     It would be sweet to have something that does all this automatically.
> ||  'su -X - foo' for instance, kind of like 'ssh -X -l foo hostname' but
> ||  without the encryption and forwarding overhead...
> 
> I think the Remote X Apps mini-HOWTO describes just the script you need.

   Thanks very much for the tip. I looked at
/usr/share/doc/HOWTO/en-txt/mini/Remote-X-Apps.txt.gz and found a script
from which I derived the one below (just in case it can be of some use).
   But I'm still having a problem. On my laptop xauth list gives me two
cookies:
$ xauth list "$DISPLAY"
oleron/unix:0  MIT-MAGIC-COOKIE-1   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
oleron/unix:0  XDM-AUTHORIZATION-1  yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

   xauth add is not happy when it gets both. It looks like I need to
transfer the XDM-AUTHORIZATION-1 authorization one. But I assume that if
I'm not using xdm things will be different. Should I systematically
transfer both? Does anyone have a good insight into this? Otherwise I'll
go a dig through this tomorrow.

   Is there any interest in getting such an 'xsu' script in the standard
Debian distribution? Maybe in xbase-clients? If so I could probably
polish the script below some more and even write a man page (otherwise
I'll keep it in my /usr/local/bin).


--- cut here ---
#!/bin/sh

su_opts=""
got_minus=0
while [ $# -gt 0 ]
do
  if [ "$1" = "-" ]
  then
    su_opts="$su_opts $1"
    got_minus=1;
    shift;
  elif [ "$1" = "-?" ]
  then
    echo "usage: `basename $0` [-] [username] command" >&2
    exit 2
  elif [ "$got_minus" = "1" ]
  then
    su_opts="$su_opts $1"
    shift;
    break;
  fi
done

if [ $# -eq 0 ]
then
  if [ "$got_minus" = "1" ]
  then
    set -- $SHELL --login
  else
    set -- $SHELL
  fi
fi

exec su $su_opts -c "xauth add `xauth list \"$DISPLAY\"`; \
                    exec env DISPLAY='$DISPLAY' "'"$SHELL"'" -c '$*'"
--- cut here ---


--
Francois Gouget         fgouget@free.fr        http://fgouget.free.fr/
 The greatest programming project of all took six days; on the seventh day the
  programmer rested. We've been trying to debug the *&^%$#@ thing ever since.
                      Resume: design before you implement.





Reply to: