Re: [gtk-list] gtk or Xhost problem with linuxconf




You might want to make a simple script which copies around your
X auth keys with su.  Here is one that I use for my support job.
(It has a lot of bugs, but would be a start.)  Mine is a tcsh
only shop, so we didn't need to worry about not having csh
commands work after the su.  Obviously this would have to change
depending on what shell the su goes to.

--Karl

----------------------------------------------------------------
#!/bin/sh
#
#  Script to change user while keeping Xdisplay.
#
#  Feb  1 2000  created Karl E Nelson
#

if test $# -gt 2 || test $# -eq 2 && test "$1" != "-" ; then
  echo "usage: xsu [-] [username]"
  exit
fi
USER="root"
CD="cd "`pwd`";"
while test $# != "0" ; do
  if test $1 = "-" ; then CD="" ; else USER=$1; fi
  shift
done

XA=/usr/bin/X11/xauth

if test "X$DISPLAY" != "X" ; then
  XAUTH=`xauth list $DISPLAY`
  LOCAL_HOST=`hostname | awk -F . '{print $1}'`
  DISPLAY_HOST=`echo $DISPLAY | awk -F : '{print $1}'`
  echo "Transfering key for $DISPLAY"
  XCOMMAND="setenv DISPLAY $DISPLAY ; xauth add $XAUTH ; setenv TERM $TERM"
  if test "X$LOCAL_HOST" = "X$DISPLAY_HOST" ; then
    XAUTH_LOCAL=`xauth list unix:0`
    su - $USER -c "($XCOMMAND; $XA add $XAUTH_LOCAL; $CD tcsh)"
  else
    su - $USER -c "($XCOMMAND; $CD tcsh)"
  fi
else
  echo "No display to set"
  su - $USER -c "($CD tcsh)"
fi





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