Commit 276cc455 authored by Wayne Davison's avatar Wayne Davison

Added a --no-cd option to support/lsh so that the script can be used by

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.
parent 311676ed
......@@ -6,18 +6,30 @@
# 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 "${@}"
......@@ -24,20 +24,7 @@
. "$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
......@@ -54,7 +41,7 @@ case `id -u` in
;;
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
......
......@@ -10,20 +10,7 @@
. "$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
......@@ -31,7 +18,7 @@ if test x"$rsync_enable_ssh_tests" = xyes; 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment