displaysudo.sh script - sudo switch user and X11 display support
----------------------------------------------------------------
[terrence@baka terrence]$ cat bin/displaysudo.sh
#!/bin/sh
#
# displaysudo.sh
#
USAGE="usage: $0 [-] username"
if [ $# -eq 1 ]; then
DASH=''
SU_USER=$1
elif [ $# -eq 2 ]; then
if [ "$1" = "-" ]; then
DASH='-'
SU_USER=$2
else
echo "Incorrect syntax"
echo "$USAGE"
exit 1
fi
elif [ $# -ge 2 ]; then
echo "Wrong number of parameters"
echo "$USAGE"
exit 2
fi
if [ -x /usr/bin/X11/xauth ]; then
XAUTH_PATH=/usr/bin/X11/xauth
elif [ -x /usr/openwin/bin/xauth ]; then
XAUTH_PATH=/usr/openwin/bin/xauth
else
DISPLAY="NO"
fi
if [ "${DISPLAY-NO}" = "NO" ]; then
exec /usr/local/bin/sudo -u $SU_USER /usr/local/bin/sushi $DASH -c "(\
/usr/bin/env $SHELL)"
else
# DISPLAY2=`echo $DISPLAY | sed "s/localhost/${HOST}\/unix/"`
# echo "DISPLAY2 = $DISPLAY2"
DISPLAY2=`echo $DISPLAY | sed "s/localhost/unix/"`
exec /usr/local/bin/sudo -u $SU_USER /usr/local/bin/sushi $DASH -c "(\
$XAUTH_PATH add `$XAUTH_PATH list $DISPLAY2`; \
/usr/bin/env DISPLAY=$DISPLAY /usr/local/bin/bash; \
$XAUTH_PATH remove $DISPLAY2)"
fi
[terrence@baka terrence]$ bin/displaysudo.sh - siwc
terrence's password:
Sun Microsystems Inc. SunOS 5.8 Generic February 2000
[siwc@baka /siwc]$ cat .vimrc
syntax on
"set guifont=Monospace\ 10
set guifont=9x15
colorscheme evening
|