the testsuite. Improved the home-directory-changing code and added an
error message when "localhost" is not the hostname specified. Use the
updated script in the testsuite instead of creating a pretend-ssh script
in a couple spots.
# we get a -l USER option, we try to use "sudo -u USER" to run the
# command.
# we get a -l USER option, we try to use "sudo -u USER" to run the
# command.
-
-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
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 ;;
-*) shift ;;
localhost) shift; break ;;
+ *) echo "lsh: unable to connect to host $1" 1>&2; exit 1 ;;
+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
+
-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"
-$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
RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
export RSYNC_CONNECT_PROG
-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"
if test x"$rsync_enable_ssh_tests" = xyes; then
if type ssh >/dev/null ; then
if test x"$rsync_enable_ssh_tests" = xyes; then
if type ssh >/dev/null ; then
-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
test_skipped "Skipping SSH tests because ssh conection to localhost not authorised"
fi