2013-05-17 07:19:10 +08:00
|
|
|
# $OpenBSD: test-exec.sh,v 1.39 2013/04/06 06:00:22 dtucker Exp $
|
2002-05-01 11:17:33 +08:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
#SUDO=sudo
|
|
|
|
|
2005-02-08 17:17:17 +08:00
|
|
|
# Unbreak GNU head(1)
|
|
|
|
_POSIX2_VERSION=199209
|
|
|
|
export _POSIX2_VERSION
|
|
|
|
|
2005-03-09 07:02:55 +08:00
|
|
|
case `uname -s 2>/dev/null` in
|
|
|
|
OSF1*)
|
|
|
|
BIN_SH=xpg4
|
|
|
|
export BIN_SH
|
|
|
|
;;
|
2012-07-02 23:11:28 +08:00
|
|
|
CYGWIN_NT-5.0)
|
2012-07-02 23:06:49 +08:00
|
|
|
os=cygwin
|
|
|
|
TEST_SSH_IPV6=no
|
|
|
|
;;
|
|
|
|
CYGWIN*)
|
|
|
|
os=cygwin
|
|
|
|
;;
|
2005-03-09 07:02:55 +08:00
|
|
|
esac
|
|
|
|
|
2004-06-23 07:28:20 +08:00
|
|
|
if [ ! -z "$TEST_SSH_PORT" ]; then
|
|
|
|
PORT="$TEST_SSH_PORT"
|
|
|
|
else
|
|
|
|
PORT=4242
|
|
|
|
fi
|
|
|
|
|
2003-09-04 13:35:48 +08:00
|
|
|
if [ -x /usr/ucb/whoami ]; then
|
|
|
|
USER=`/usr/ucb/whoami`
|
2003-09-12 13:32:17 +08:00
|
|
|
elif whoami >/dev/null 2>&1; then
|
2003-09-04 13:35:48 +08:00
|
|
|
USER=`whoami`
|
2006-02-01 08:21:01 +08:00
|
|
|
elif logname >/dev/null 2>&1; then
|
|
|
|
USER=`logname`
|
2003-09-04 13:35:48 +08:00
|
|
|
else
|
|
|
|
USER=`id -un`
|
|
|
|
fi
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
OBJ=$1
|
|
|
|
if [ "x$OBJ" = "x" ]; then
|
|
|
|
echo '$OBJ not defined'
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
if [ ! -d $OBJ ]; then
|
|
|
|
echo "not a directory: $OBJ"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
SCRIPT=$2
|
|
|
|
if [ "x$SCRIPT" = "x" ]; then
|
|
|
|
echo '$SCRIPT not defined'
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
if [ ! -f $SCRIPT ]; then
|
|
|
|
echo "not a file: $SCRIPT"
|
|
|
|
exit 2
|
|
|
|
fi
|
2004-02-12 23:17:10 +08:00
|
|
|
if $TEST_SHELL -n $SCRIPT; then
|
2002-05-01 11:17:33 +08:00
|
|
|
true
|
|
|
|
else
|
|
|
|
echo "syntax error in $SCRIPT"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
unset SSH_AUTH_SOCK
|
|
|
|
|
2005-03-07 15:33:02 +08:00
|
|
|
SRC=`dirname ${SCRIPT}`
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
# defaults
|
|
|
|
SSH=ssh
|
|
|
|
SSHD=sshd
|
|
|
|
SSHAGENT=ssh-agent
|
|
|
|
SSHADD=ssh-add
|
|
|
|
SSHKEYGEN=ssh-keygen
|
|
|
|
SSHKEYSCAN=ssh-keyscan
|
|
|
|
SFTP=sftp
|
|
|
|
SFTPSERVER=/usr/libexec/openssh/sftp-server
|
2004-06-16 18:15:59 +08:00
|
|
|
SCP=scp
|
2002-05-01 11:17:33 +08:00
|
|
|
|
2008-03-12 21:17:00 +08:00
|
|
|
# Interop testing
|
2008-06-30 06:12:37 +08:00
|
|
|
PLINK=plink
|
|
|
|
PUTTYGEN=puttygen
|
|
|
|
CONCH=conch
|
2008-03-12 21:17:00 +08:00
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
if [ "x$TEST_SSH_SSH" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SSH="${TEST_SSH_SSH}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_SSHD" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SSHD="${TEST_SSH_SSHD}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_SSHAGENT" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SSHAGENT="${TEST_SSH_SSHAGENT}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_SSHADD" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SSHADD="${TEST_SSH_SSHADD}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_SSHKEYGEN" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SSHKEYGEN="${TEST_SSH_SSHKEYGEN}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_SSHKEYSCAN" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SSHKEYSCAN="${TEST_SSH_SSHKEYSCAN}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_SFTP" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SFTP="${TEST_SSH_SFTP}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_SFTPSERVER" != "x" ]; then
|
2004-02-29 17:31:08 +08:00
|
|
|
SFTPSERVER="${TEST_SSH_SFTPSERVER}"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
2004-06-16 18:15:59 +08:00
|
|
|
if [ "x$TEST_SSH_SCP" != "x" ]; then
|
|
|
|
SCP="${TEST_SSH_SCP}"
|
|
|
|
fi
|
2008-03-12 21:17:00 +08:00
|
|
|
if [ "x$TEST_SSH_PLINK" != "x" ]; then
|
2008-03-13 09:41:31 +08:00
|
|
|
# Find real binary, if it exists
|
|
|
|
case "${TEST_SSH_PLINK}" in
|
|
|
|
/*) PLINK="${TEST_SSH_PLINK}" ;;
|
2008-03-15 06:25:54 +08:00
|
|
|
*) PLINK=`which ${TEST_SSH_PLINK} 2>/dev/null` ;;
|
2008-03-13 09:41:31 +08:00
|
|
|
esac
|
2008-03-12 21:17:00 +08:00
|
|
|
fi
|
|
|
|
if [ "x$TEST_SSH_PUTTYGEN" != "x" ]; then
|
2008-03-13 09:41:31 +08:00
|
|
|
# Find real binary, if it exists
|
|
|
|
case "${TEST_SSH_PUTTYGEN}" in
|
|
|
|
/*) PUTTYGEN="${TEST_SSH_PUTTYGEN}" ;;
|
2008-03-15 06:25:54 +08:00
|
|
|
*) PUTTYGEN=`which ${TEST_SSH_PUTTYGEN} 2>/dev/null` ;;
|
2008-03-13 09:41:31 +08:00
|
|
|
esac
|
2008-03-12 21:17:00 +08:00
|
|
|
fi
|
2008-06-30 06:07:56 +08:00
|
|
|
if [ "x$TEST_SSH_CONCH" != "x" ]; then
|
2008-06-30 06:12:37 +08:00
|
|
|
# Find real binary, if it exists
|
|
|
|
case "${TEST_SSH_CONCH}" in
|
|
|
|
/*) CONCH="${TEST_SSH_CONCH}" ;;
|
|
|
|
*) CONCH=`which ${TEST_SSH_CONCH} 2>/dev/null` ;;
|
|
|
|
esac
|
2008-06-30 06:07:56 +08:00
|
|
|
fi
|
2002-05-01 11:17:33 +08:00
|
|
|
|
2004-06-25 11:45:18 +08:00
|
|
|
# Path to sshd must be absolute for rexec
|
2005-08-23 21:32:05 +08:00
|
|
|
case "$SSHD" in
|
|
|
|
/*) ;;
|
|
|
|
*) SSHD=`which sshd` ;;
|
|
|
|
esac
|
2004-06-25 11:45:18 +08:00
|
|
|
|
2013-05-17 07:19:10 +08:00
|
|
|
# Logfiles.
|
|
|
|
# SSH_LOGFILE should be the debug output of ssh(1) only
|
|
|
|
# SSHD_LOGFILE should be the debug output of sshd(8) only
|
|
|
|
# REGRESS_LOGFILE is the output of the test itself stdout and stderr
|
2005-03-07 15:33:02 +08:00
|
|
|
if [ "x$TEST_SSH_LOGFILE" = "x" ]; then
|
2013-05-17 07:19:10 +08:00
|
|
|
TEST_SSH_LOGFILE=$OBJ/ssh.log
|
2005-03-07 15:33:02 +08:00
|
|
|
fi
|
2013-05-17 07:19:10 +08:00
|
|
|
if [ "x$TEST_SSHD_LOGFILE" = "x" ]; then
|
|
|
|
TEST_SSHD_LOGFILE=$OBJ/sshd.log
|
|
|
|
fi
|
|
|
|
if [ "x$TEST_REGRESS_LOGFILE" = "x" ]; then
|
|
|
|
TEST_REGRESS_LOGFILE=$OBJ/regress.log
|
|
|
|
fi
|
|
|
|
|
|
|
|
# truncate logfiles
|
|
|
|
>$TEST_SSH_LOGFILE
|
|
|
|
>$TEST_SSHD_LOGFILE
|
|
|
|
>$TEST_REGRESS_LOGFILE
|
2005-03-07 15:33:02 +08:00
|
|
|
|
2013-03-12 08:19:40 +08:00
|
|
|
# Some data for test copies
|
|
|
|
DATA=$OBJ/testdata
|
|
|
|
cat $SSHD${EXEEXT} $SSHD${EXEEXT} $SSHD${EXEEXT} $SSHD${EXEEXT} >$DATA
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
# these should be used in tests
|
2004-06-16 18:15:59 +08:00
|
|
|
export SSH SSHD SSHAGENT SSHADD SSHKEYGEN SSHKEYSCAN SFTP SFTPSERVER SCP
|
|
|
|
#echo $SSH $SSHD $SSHAGENT $SSHADD $SSHKEYGEN $SSHKEYSCAN $SFTP $SFTPSERVER $SCP
|
2002-05-01 11:17:33 +08:00
|
|
|
|
|
|
|
# helper
|
2003-09-04 13:16:56 +08:00
|
|
|
echon()
|
|
|
|
{
|
|
|
|
if [ "x`echo -n`" = "x" ]; then
|
|
|
|
echo -n "$@"
|
|
|
|
elif [ "x`echo '\c'`" = "x" ]; then
|
|
|
|
echo "$@\c"
|
|
|
|
else
|
|
|
|
fatal "Don't know how to echo without newline."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2003-09-12 13:32:17 +08:00
|
|
|
have_prog()
|
|
|
|
{
|
|
|
|
saved_IFS="$IFS"
|
|
|
|
IFS=":"
|
|
|
|
for i in $PATH
|
|
|
|
do
|
|
|
|
if [ -x $i/$1 ]; then
|
|
|
|
IFS="$saved_IFS"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
IFS="$saved_IFS"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
cleanup ()
|
|
|
|
{
|
|
|
|
if [ -f $PIDFILE ]; then
|
2010-08-13 00:43:13 +08:00
|
|
|
pid=`$SUDO cat $PIDFILE`
|
2002-05-01 11:17:33 +08:00
|
|
|
if [ "X$pid" = "X" ]; then
|
|
|
|
echo no sshd running
|
|
|
|
else
|
|
|
|
if [ $pid -lt 2 ]; then
|
2010-02-24 14:29:34 +08:00
|
|
|
echo bad pid for ssh: $pid
|
2002-05-01 11:17:33 +08:00
|
|
|
else
|
|
|
|
$SUDO kill $pid
|
2010-02-24 14:29:34 +08:00
|
|
|
trace "wait for sshd to exit"
|
|
|
|
i=0;
|
|
|
|
while [ -f $PIDFILE -a $i -lt 5 ]; do
|
|
|
|
i=`expr $i + 1`
|
|
|
|
sleep $i
|
|
|
|
done
|
|
|
|
test -f $PIDFILE && \
|
|
|
|
fatal "sshd didn't exit port $PORT pid $pid"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
trace ()
|
|
|
|
{
|
2013-05-17 07:19:10 +08:00
|
|
|
echo "trace: $@" >>$TEST_REGRESS_LOGFILE
|
2002-05-01 11:17:33 +08:00
|
|
|
if [ "X$TEST_SSH_TRACE" = "Xyes" ]; then
|
2007-10-26 13:35:54 +08:00
|
|
|
echo "$@"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
verbose ()
|
|
|
|
{
|
2013-05-17 07:19:10 +08:00
|
|
|
echo "verbose: $@" >>$TEST_REGRESS_LOGFILE
|
2002-05-01 11:17:33 +08:00
|
|
|
if [ "X$TEST_SSH_QUIET" != "Xyes" ]; then
|
2007-10-26 13:35:54 +08:00
|
|
|
echo "$@"
|
2002-05-01 11:17:33 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2011-09-04 17:04:16 +08:00
|
|
|
warn ()
|
|
|
|
{
|
|
|
|
echo "WARNING: $@" >>$TEST_SSH_LOGFILE
|
|
|
|
echo "WARNING: $@"
|
|
|
|
}
|
2002-05-01 11:17:33 +08:00
|
|
|
|
|
|
|
fail ()
|
|
|
|
{
|
2013-05-17 07:19:10 +08:00
|
|
|
echo "FAIL: $@" >>$TEST_REGRESS_LOGFILE
|
2002-05-01 11:17:33 +08:00
|
|
|
RESULT=1
|
2007-10-26 13:35:54 +08:00
|
|
|
echo "$@"
|
2002-05-01 11:17:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fatal ()
|
|
|
|
{
|
2013-05-17 07:19:10 +08:00
|
|
|
echo "FATAL: $@" >>$TEST_REGRESS_LOGFILE
|
2003-09-04 13:16:56 +08:00
|
|
|
echon "FATAL: "
|
2002-05-01 11:17:33 +08:00
|
|
|
fail "$@"
|
|
|
|
cleanup
|
|
|
|
exit $RESULT
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:17:09 +08:00
|
|
|
# Check whether preprocessor symbols are defined in config.h.
|
|
|
|
config_defined ()
|
|
|
|
{
|
|
|
|
str=$1
|
|
|
|
while test "x$2" != "x" ; do
|
|
|
|
str="$str|$2"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
egrep "^#define.*($str)" ${BUILDDIR}/config.h >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
RESULT=0
|
|
|
|
PIDFILE=$OBJ/pidfile
|
|
|
|
|
|
|
|
trap fatal 3 2
|
|
|
|
|
|
|
|
# create server config
|
|
|
|
cat << EOF > $OBJ/sshd_config
|
2004-06-16 18:36:16 +08:00
|
|
|
StrictModes no
|
2002-05-01 11:17:33 +08:00
|
|
|
Port $PORT
|
2009-10-12 06:37:22 +08:00
|
|
|
Protocol 2,1
|
2006-01-31 18:59:01 +08:00
|
|
|
AddressFamily inet
|
2002-05-01 11:17:33 +08:00
|
|
|
ListenAddress 127.0.0.1
|
|
|
|
#ListenAddress ::1
|
|
|
|
PidFile $PIDFILE
|
|
|
|
AuthorizedKeysFile $OBJ/authorized_keys_%u
|
2005-03-14 20:02:46 +08:00
|
|
|
LogLevel VERBOSE
|
2004-06-16 18:08:56 +08:00
|
|
|
AcceptEnv _XXX_TEST_*
|
|
|
|
AcceptEnv _XXX_TEST
|
2004-06-16 18:22:22 +08:00
|
|
|
Subsystem sftp $SFTPSERVER
|
2002-05-01 11:17:33 +08:00
|
|
|
EOF
|
|
|
|
|
2004-06-23 07:25:02 +08:00
|
|
|
if [ ! -z "$TEST_SSH_SSHD_CONFOPTS" ]; then
|
|
|
|
trace "adding sshd_config option $TEST_SSH_SSHD_CONFOPTS"
|
|
|
|
echo "$TEST_SSH_SSHD_CONFOPTS" >> $OBJ/sshd_config
|
|
|
|
fi
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
# server config for proxy connects
|
|
|
|
cp $OBJ/sshd_config $OBJ/sshd_proxy
|
|
|
|
|
|
|
|
# allow group-writable directories in proxy-mode
|
|
|
|
echo 'StrictModes no' >> $OBJ/sshd_proxy
|
|
|
|
|
|
|
|
# create client config
|
|
|
|
cat << EOF > $OBJ/ssh_config
|
|
|
|
Host *
|
2009-10-12 06:37:22 +08:00
|
|
|
Protocol 2,1
|
2002-05-01 11:17:33 +08:00
|
|
|
Hostname 127.0.0.1
|
|
|
|
HostKeyAlias localhost-with-alias
|
|
|
|
Port $PORT
|
|
|
|
User $USER
|
|
|
|
GlobalKnownHostsFile $OBJ/known_hosts
|
|
|
|
UserKnownHostsFile $OBJ/known_hosts
|
|
|
|
RSAAuthentication yes
|
|
|
|
PubkeyAuthentication yes
|
|
|
|
ChallengeResponseAuthentication no
|
|
|
|
HostbasedAuthentication no
|
|
|
|
PasswordAuthentication no
|
|
|
|
BatchMode yes
|
|
|
|
StrictHostKeyChecking yes
|
|
|
|
EOF
|
|
|
|
|
2004-06-23 07:25:02 +08:00
|
|
|
if [ ! -z "$TEST_SSH_SSH_CONFOPTS" ]; then
|
|
|
|
trace "adding ssh_config option $TEST_SSH_SSHD_CONFOPTS"
|
|
|
|
echo "$TEST_SSH_SSH_CONFOPTS" >> $OBJ/ssh_config
|
|
|
|
fi
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
rm -f $OBJ/known_hosts $OBJ/authorized_keys_$USER
|
|
|
|
|
|
|
|
trace "generate keys"
|
|
|
|
for t in rsa rsa1; do
|
|
|
|
# generate user key
|
2013-05-17 07:10:20 +08:00
|
|
|
if [ ! -f $OBJ/$t ] || [ ${SSHKEYGEN} -nt $OBJ/$t ]; then
|
|
|
|
rm -f $OBJ/$t
|
|
|
|
${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t ||\
|
|
|
|
fail "ssh-keygen for $t failed"
|
|
|
|
fi
|
2002-05-01 11:17:33 +08:00
|
|
|
|
|
|
|
# known hosts file for client
|
|
|
|
(
|
2003-09-04 13:16:56 +08:00
|
|
|
echon 'localhost-with-alias,127.0.0.1,::1 '
|
2002-05-01 11:17:33 +08:00
|
|
|
cat $OBJ/$t.pub
|
|
|
|
) >> $OBJ/known_hosts
|
|
|
|
|
|
|
|
# setup authorized keys
|
|
|
|
cat $OBJ/$t.pub >> $OBJ/authorized_keys_$USER
|
|
|
|
echo IdentityFile $OBJ/$t >> $OBJ/ssh_config
|
|
|
|
|
|
|
|
# use key as host key, too
|
|
|
|
$SUDO cp $OBJ/$t $OBJ/host.$t
|
|
|
|
echo HostKey $OBJ/host.$t >> $OBJ/sshd_config
|
|
|
|
|
|
|
|
# don't use SUDO for proxy connect
|
|
|
|
echo HostKey $OBJ/$t >> $OBJ/sshd_proxy
|
|
|
|
done
|
|
|
|
chmod 644 $OBJ/authorized_keys_$USER
|
|
|
|
|
2008-06-30 06:07:56 +08:00
|
|
|
# Activate Twisted Conch tests if the binary is present
|
|
|
|
REGRESS_INTEROP_CONCH=no
|
|
|
|
if test -x "$CONCH" ; then
|
|
|
|
REGRESS_INTEROP_CONCH=yes
|
|
|
|
fi
|
|
|
|
|
2008-06-10 21:15:54 +08:00
|
|
|
# If PuTTY is present and we are running a PuTTY test, prepare keys and
|
|
|
|
# configuration
|
2008-03-12 21:17:00 +08:00
|
|
|
REGRESS_INTEROP_PUTTY=no
|
2008-06-10 23:39:38 +08:00
|
|
|
if test -x "$PUTTYGEN" -a -x "$PLINK" ; then
|
2008-06-10 23:38:52 +08:00
|
|
|
REGRESS_INTEROP_PUTTY=yes
|
|
|
|
fi
|
|
|
|
case "$SCRIPT" in
|
|
|
|
*putty*) ;;
|
|
|
|
*) REGRESS_INTEROP_PUTTY=no ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if test "$REGRESS_INTEROP_PUTTY" = "yes" ; then
|
2008-03-12 21:17:00 +08:00
|
|
|
mkdir -p ${OBJ}/.putty
|
|
|
|
|
|
|
|
# Add a PuTTY key to authorized_keys
|
|
|
|
rm -f ${OBJ}/putty.rsa2
|
|
|
|
puttygen -t rsa -o ${OBJ}/putty.rsa2 < /dev/null > /dev/null
|
|
|
|
puttygen -O public-openssh ${OBJ}/putty.rsa2 \
|
|
|
|
>> $OBJ/authorized_keys_$USER
|
|
|
|
|
|
|
|
# Convert rsa2 host key to PuTTY format
|
|
|
|
${SRC}/ssh2putty.sh 127.0.0.1 $PORT $OBJ/rsa > \
|
|
|
|
${OBJ}/.putty/sshhostkeys
|
|
|
|
${SRC}/ssh2putty.sh 127.0.0.1 22 $OBJ/rsa >> \
|
|
|
|
${OBJ}/.putty/sshhostkeys
|
|
|
|
|
|
|
|
# Setup proxied session
|
|
|
|
mkdir -p ${OBJ}/.putty/sessions
|
|
|
|
rm -f ${OBJ}/.putty/sessions/localhost_proxy
|
|
|
|
echo "Hostname=127.0.0.1" >> ${OBJ}/.putty/sessions/localhost_proxy
|
|
|
|
echo "PortNumber=$PORT" >> ${OBJ}/.putty/sessions/localhost_proxy
|
|
|
|
echo "ProxyMethod=5" >> ${OBJ}/.putty/sessions/localhost_proxy
|
2013-05-17 07:19:10 +08:00
|
|
|
echo "ProxyTelnetCommand=sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy
|
2008-03-12 21:17:00 +08:00
|
|
|
|
|
|
|
REGRESS_INTEROP_PUTTY=yes
|
|
|
|
fi
|
|
|
|
|
2002-05-01 11:17:33 +08:00
|
|
|
# create a proxy version of the client config
|
|
|
|
(
|
|
|
|
cat $OBJ/ssh_config
|
2013-05-17 07:19:10 +08:00
|
|
|
echo proxycommand ${SUDO} sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy
|
2002-05-01 11:17:33 +08:00
|
|
|
) > $OBJ/ssh_proxy
|
|
|
|
|
|
|
|
# check proxy config
|
|
|
|
${SSHD} -t -f $OBJ/sshd_proxy || fatal "sshd_proxy broken"
|
|
|
|
|
|
|
|
start_sshd ()
|
|
|
|
{
|
|
|
|
# start sshd
|
2008-03-12 21:17:00 +08:00
|
|
|
$SUDO ${SSHD} -f $OBJ/sshd_config "$@" -t || fatal "sshd_config broken"
|
2013-05-17 07:19:10 +08:00
|
|
|
$SUDO ${SSHD} -f $OBJ/sshd_config -e "$@" >>$TEST_SSHD_LOGFILE 2>&1
|
2002-05-01 11:17:33 +08:00
|
|
|
|
|
|
|
trace "wait for sshd"
|
|
|
|
i=0;
|
2003-09-04 13:35:48 +08:00
|
|
|
while [ ! -f $PIDFILE -a $i -lt 10 ]; do
|
2002-05-01 11:17:33 +08:00
|
|
|
i=`expr $i + 1`
|
|
|
|
sleep $i
|
|
|
|
done
|
|
|
|
|
|
|
|
test -f $PIDFILE || fatal "no sshd running on port $PORT"
|
|
|
|
}
|
|
|
|
|
|
|
|
# source test body
|
|
|
|
. $SCRIPT
|
|
|
|
|
|
|
|
# kill sshd
|
|
|
|
cleanup
|
|
|
|
if [ $RESULT -eq 0 ]; then
|
|
|
|
verbose ok $tid
|
|
|
|
else
|
|
|
|
echo failed $tid
|
|
|
|
fi
|
|
|
|
exit $RESULT
|