# we get a -l USER option, we try to use "sudo -u USER" to run the
# command.
+user=''
prefix=''
-
-cd # Default path is home dir, just like ssh.
+do_cd=y # Default path is user's home dir, just like ssh.
while : ; do
case "$1" in
- -l) shift ; prefix="sudo -u $1"; shift ;;
- -l*) prefix=`echo $1 | sed 's/-l/sudo -u /'`; shift ;;
+ -l) user="$2"; shift; shift ;;
+ -l*) user=`echo $1 | sed 's/^-l//'`; shift ;;
+ --no-cd) do_cd=n; shift ;;
-*) shift ;;
localhost) shift; break ;;
- *) exit 1 ;;
+ *) echo "lsh: unable to connect to host $1" 1>&2; exit 1 ;;
esac
done
+if [ "$user" ]; then
+ prefix="sudo -H -u $user"
+ if [ $do_cd = y ]; then
+ home=`perl -e "print((getpwnam("$user"))[7])"`
+ # Yeah, this may fail, but attempts to get sudo to cd are harder.
+ cd $home
+ fi
+elif [ $do_cd = y ]; then
+ cd
+fi
+
eval $prefix "${@}"
. "$suitedir/rsync.fns"
-SSH="$scratchdir/pretend-ssh"
-
-cat >"$SSH" <<'EOT'
-while : ; do
- case "$1" in
- -*) shift ;;
- localhost) shift; break ;;
- *) exit 1 ;;
- esac
-done
-
-eval "${@}"
-EOT
-chmod +x "$SSH"
+SSH="src/support/lsh --no-cd"
build_rsyncd_conf
;;
esac
-$RSYNC -ve $SSH --rsync-path="$RSYNC$confopt" localhost::
+$RSYNC -ve "$SSH" --rsync-path="$RSYNC$confopt" localhost::
RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
export RSYNC_CONNECT_PROG
. "$suitedir/rsync.fns"
-SSH="$scratchdir/pretend-ssh"
-
-cat >"$SSH" <<'EOT'
-while : ; do
- case "$1" in
- -*) shift ;;
- localhost) shift; break ;;
- *) exit 1 ;;
- esac
-done
-
-eval "${@}"
-EOT
-chmod +x "$SSH"
+SSH=support/lsh
if test x"$rsync_enable_ssh_tests" = xyes; then
if type ssh >/dev/null ; then
fi
fi
-if ! [ "`"$SSH" -o'BatchMode yes' localhost echo yes`" = "yes" ]; then
+if ! [ "`$SSH -o'BatchMode yes' localhost echo yes`" = "yes" ]; then
test_skipped "Skipping SSH tests because ssh conection to localhost not authorised"
fi