#!/usr/bin/bash # assign the environment to a a=`env |sed -n -e '/^!::=/d' -e 's,$,_EOL_,g' -e 's,'\'',_APOS_,g' -e 's/\([A-Za-z0-9_][A-Za-z0-9_]*\)=/'\'';\1='\''/' -e '/./p'` rm -f /tmp/env.$$ echo "#!`which bash`" > /tmp/env.$$ chmod 755 /tmp/env.$$ userarg="Administrator" options=":lc:fmps:" repeat=1; while [ $repeat -ne 0 ] ; do getopts $options arg if [ $? -ne 0 ] ; then arg="$1" OPTIND=2 fi case "x$arg" in xl | x- | x--login) loginarg=1 if [ -z "$shellarg" ] ; then shellarg=`which bash` fi ;; xc | x--command | x--command) commandarg="$OPTARG" ;; x--command=*) commandarg="${arg##--command=}" ;; xf | x--fast ) fastarg=1 if [ -z "$shellarg" ] ; then shellarg=`which tcsh` fi if [ -z "$shellarg" ] ; then shellarg=`which csh` fi ;; xm | xp | x--preserve-environment) echo $a|sed -e 's,^'\'';,,' -e 's,_EOL_$,'\'',' -e 's,_EOL_ '\'';,'\'';\ ,g' -e "s,_APOS_,'\\'',g" -e 's,_EOL_ ,\ ,g' >> /tmp/env.$$ env|sed -n -e 's,\([A-Za-z0-9_][A-Za-z0-9_]*\)=.*,export \1;,p' >> /tmp/env.$$ preservearg=1 ;; xs ) shellarg="$OPTARG" ;; x--shell) shellarg="$OPTARG" OPTIND=3 ;; x--shell=*) shellarg="${arg##--shell=}" ;; *) repeat=0 OPTIND=1 ;; esac while [ $OPTIND -gt 1 ] ; do shift OPTIND=`expr $OPTIND - 1` done done if [ -n "$1" ] ; then userarg="$1" shift fi if [ -z "$shellarg" ] ; then shellarg=`which bash` fi if [ -n "$commandarg" ] ; then echo "exec \"$shellarg\" $fastarg $loginarg -c \"$commandarg\"" >>/tmp/env.$$ elif [ -n "$*" ] ; then echo "exec \"$shellarg\" $fastarg $loginarg -c \"$@\"" >>/tmp/env.$$ else echo "exec \"$shellarg\" $fastarg $loginarg -i -s" >>/tmp/env.$$ fi trap "rm -f /tmp/env.$$" EXIT ssh -l "$userarg" localhost /tmp/env.$$ exit $? SU(1) User Commands SU(1) NAME su - run a shell with substitute user and group IDs SYNOPSIS su [OPTION]... [-] [USER [ARG]...] DESCRIPTION Change the effective user id and group id to that of USER. -, -l, --login make the shell a login shell -c, --commmand=COMMAND pass a single COMMAND to the shell with -c -f, --fast pass -f to the shell (for csh or tcsh) -m, --preserve-environment do not reset environment variables -p same as -m -s, --shell=SHELL run SHELL if /etc/shells allows it --help display this help and exit --version output version information and exit A mere - implies -l. If USER not given, assume root. AUTHOR Written by David MacKenzie. REPORTING BUGS Report bugs to . COPYRIGHT Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO The full documentation for su is maintained as a Texinfo manual. If the info and su programs are properly installed at your site, the com- mand info su should give you access to the complete manual. su (sh-utils) 2.0.15 August 2002 SU(1)