summaryrefslogtreecommitdiff
path: root/regress/test-exec.sh
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2015-08-19 14:23:51 +0100
committerColin Watson <cjwatson@debian.org>2015-08-19 16:48:11 +0100
commit0f0841b2d28b7463267d4d91577e72e3340a1d3a (patch)
treeba55fcd2b6e2cc22b30f5afb561dbb3da4c8b6c7 /regress/test-exec.sh
parentf2a5f5dae656759efb0b76c3d94890b65c197a02 (diff)
parent8698446b972003b63dfe5dcbdb86acfe986afb85 (diff)
New upstream release (6.8p1).
Diffstat (limited to 'regress/test-exec.sh')
-rw-r--r--regress/test-exec.sh88
1 files changed, 79 insertions, 9 deletions
diff --git a/regress/test-exec.sh b/regress/test-exec.sh
index a1bab832f..0f766620d 100644
--- a/regress/test-exec.sh
+++ b/regress/test-exec.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: test-exec.sh,v 1.48 2014/07/06 07:42:03 djm Exp $ 1# $OpenBSD: test-exec.sh,v 1.51 2015/03/03 22:35:19 markus Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4#SUDO=sudo 4#SUDO=sudo
@@ -130,6 +130,11 @@ if [ "x$TEST_SSH_CONCH" != "x" ]; then
130 esac 130 esac
131fi 131fi
132 132
133SSH_PROTOCOLS=`$SSH -Q protocol-version`
134if [ "x$TEST_SSH_PROTOCOLS" != "x" ]; then
135 SSH_PROTOCOLS="${TEST_SSH_PROTOCOLS}"
136fi
137
133# Path to sshd must be absolute for rexec 138# Path to sshd must be absolute for rexec
134case "$SSHD" in 139case "$SSHD" in
135/*) ;; 140/*) ;;
@@ -141,6 +146,55 @@ case "$SSHAGENT" in
141*) SSHAGENT=`which $SSHAGENT` ;; 146*) SSHAGENT=`which $SSHAGENT` ;;
142esac 147esac
143 148
149# Record the actual binaries used.
150SSH_BIN=${SSH}
151SSHD_BIN=${SSHD}
152SSHAGENT_BIN=${SSHAGENT}
153SSHADD_BIN=${SSHADD}
154SSHKEYGEN_BIN=${SSHKEYGEN}
155SSHKEYSCAN_BIN=${SSHKEYSCAN}
156SFTP_BIN=${SFTP}
157SFTPSERVER_BIN=${SFTPSERVER}
158SCP_BIN=${SCP}
159
160if [ "x$USE_VALGRIND" != "x" ]; then
161 mkdir -p $OBJ/valgrind-out
162 VG_TEST=`basename $SCRIPT .sh`
163
164 # Some tests are difficult to fix.
165 case "$VG_TEST" in
166 connect-privsep|reexec)
167 VG_SKIP=1 ;;
168 esac
169
170 if [ x"$VG_SKIP" = "x" ]; then
171 VG_IGNORE="/bin/*,/sbin/*,/usr/*,/var/*"
172 VG_LOG="$OBJ/valgrind-out/${VG_TEST}."
173 VG_OPTS="--track-origins=yes --leak-check=full"
174 VG_OPTS="$VG_OPTS --trace-children=yes"
175 VG_OPTS="$VG_OPTS --trace-children-skip=${VG_IGNORE}"
176 VG_PATH="valgrind"
177 if [ "x$VALGRIND_PATH" != "x" ]; then
178 VG_PATH="$VALGRIND_PATH"
179 fi
180 VG="$VG_PATH $VG_OPTS"
181 SSH="$VG --log-file=${VG_LOG}ssh.%p $SSH"
182 SSHD="$VG --log-file=${VG_LOG}sshd.%p $SSHD"
183 SSHAGENT="$VG --log-file=${VG_LOG}ssh-agent.%p $SSHAGENT"
184 SSHADD="$VG --log-file=${VG_LOG}ssh-add.%p $SSHADD"
185 SSHKEYGEN="$VG --log-file=${VG_LOG}ssh-keygen.%p $SSHKEYGEN"
186 SSHKEYSCAN="$VG --log-file=${VG_LOG}ssh-keyscan.%p $SSHKEYSCAN"
187 SFTP="$VG --log-file=${VG_LOG}sftp.%p ${SFTP}"
188 SCP="$VG --log-file=${VG_LOG}scp.%p $SCP"
189 cat > $OBJ/valgrind-sftp-server.sh << EOF
190#!/bin/sh
191exec $VG --log-file=${VG_LOG}sftp-server.%p $SFTPSERVER "\$@"
192EOF
193 chmod a+rx $OBJ/valgrind-sftp-server.sh
194 SFTPSERVER="$OBJ/valgrind-sftp-server.sh"
195 fi
196fi
197
144# Logfiles. 198# Logfiles.
145# SSH_LOGFILE should be the debug output of ssh(1) only 199# SSH_LOGFILE should be the debug output of ssh(1) only
146# SSHD_LOGFILE should be the debug output of sshd(8) only 200# SSHD_LOGFILE should be the debug output of sshd(8) only
@@ -175,7 +229,7 @@ SSH="$SSHLOGWRAP"
175# [kbytes] to ensure the file is at least that large. 229# [kbytes] to ensure the file is at least that large.
176DATANAME=data 230DATANAME=data
177DATA=$OBJ/${DATANAME} 231DATA=$OBJ/${DATANAME}
178cat ${SSHAGENT} >${DATA} 232cat ${SSHAGENT_BIN} >${DATA}
179chmod u+w ${DATA} 233chmod u+w ${DATA}
180COPY=$OBJ/copy 234COPY=$OBJ/copy
181rm -f ${COPY} 235rm -f ${COPY}
@@ -183,7 +237,7 @@ rm -f ${COPY}
183increase_datafile_size() 237increase_datafile_size()
184{ 238{
185 while [ `du -k ${DATA} | cut -f1` -lt $1 ]; do 239 while [ `du -k ${DATA} | cut -f1` -lt $1 ]; do
186 cat ${SSHAGENT} >>${DATA} 240 cat ${SSHAGENT_BIN} >>${DATA}
187 done 241 done
188} 242}
189 243
@@ -325,16 +379,27 @@ fatal ()
325 exit $RESULT 379 exit $RESULT
326} 380}
327 381
382ssh_version ()
383{
384 echo ${SSH_PROTOCOLS} | grep "$1" >/dev/null
385}
386
328RESULT=0 387RESULT=0
329PIDFILE=$OBJ/pidfile 388PIDFILE=$OBJ/pidfile
330 389
331trap fatal 3 2 390trap fatal 3 2
332 391
392if ssh_version 1; then
393 PROTO="2,1"
394else
395 PROTO="2"
396fi
397
333# create server config 398# create server config
334cat << EOF > $OBJ/sshd_config 399cat << EOF > $OBJ/sshd_config
335 StrictModes no 400 StrictModes no
336 Port $PORT 401 Port $PORT
337 Protocol 2,1 402 Protocol $PROTO
338 AddressFamily inet 403 AddressFamily inet
339 ListenAddress 127.0.0.1 404 ListenAddress 127.0.0.1
340 #ListenAddress ::1 405 #ListenAddress ::1
@@ -360,7 +425,7 @@ echo 'StrictModes no' >> $OBJ/sshd_proxy
360# create client config 425# create client config
361cat << EOF > $OBJ/ssh_config 426cat << EOF > $OBJ/ssh_config
362Host * 427Host *
363 Protocol 2,1 428 Protocol $PROTO
364 Hostname 127.0.0.1 429 Hostname 127.0.0.1
365 HostKeyAlias localhost-with-alias 430 HostKeyAlias localhost-with-alias
366 Port $PORT 431 Port $PORT
@@ -385,10 +450,15 @@ fi
385 450
386rm -f $OBJ/known_hosts $OBJ/authorized_keys_$USER 451rm -f $OBJ/known_hosts $OBJ/authorized_keys_$USER
387 452
453if ssh_version 1; then
454 SSH_KEYTYPES="rsa rsa1"
455else
456 SSH_KEYTYPES="rsa ed25519"
457fi
388trace "generate keys" 458trace "generate keys"
389for t in rsa rsa1; do 459for t in ${SSH_KEYTYPES}; do
390 # generate user key 460 # generate user key
391 if [ ! -f $OBJ/$t ] || [ ${SSHKEYGEN} -nt $OBJ/$t ]; then 461 if [ ! -f $OBJ/$t ] || [ ${SSHKEYGEN_BIN} -nt $OBJ/$t ]; then
392 rm -f $OBJ/$t 462 rm -f $OBJ/$t
393 ${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t ||\ 463 ${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t ||\
394 fail "ssh-keygen for $t failed" 464 fail "ssh-keygen for $t failed"
@@ -451,7 +521,7 @@ if test "$REGRESS_INTEROP_PUTTY" = "yes" ; then
451 echo "Hostname=127.0.0.1" >> ${OBJ}/.putty/sessions/localhost_proxy 521 echo "Hostname=127.0.0.1" >> ${OBJ}/.putty/sessions/localhost_proxy
452 echo "PortNumber=$PORT" >> ${OBJ}/.putty/sessions/localhost_proxy 522 echo "PortNumber=$PORT" >> ${OBJ}/.putty/sessions/localhost_proxy
453 echo "ProxyMethod=5" >> ${OBJ}/.putty/sessions/localhost_proxy 523 echo "ProxyMethod=5" >> ${OBJ}/.putty/sessions/localhost_proxy
454 echo "ProxyTelnetCommand=sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy 524 echo "ProxyTelnetCommand=sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy" >> ${OBJ}/.putty/sessions/localhost_proxy
455 525
456 REGRESS_INTEROP_PUTTY=yes 526 REGRESS_INTEROP_PUTTY=yes
457fi 527fi
@@ -459,7 +529,7 @@ fi
459# create a proxy version of the client config 529# create a proxy version of the client config
460( 530(
461 cat $OBJ/ssh_config 531 cat $OBJ/ssh_config
462 echo proxycommand ${SUDO} sh ${SRC}/sshd-log-wrapper.sh ${SSHD} ${TEST_SSHD_LOGFILE} -i -f $OBJ/sshd_proxy 532 echo proxycommand ${SUDO} sh ${SRC}/sshd-log-wrapper.sh ${TEST_SSHD_LOGFILE} ${SSHD} -i -f $OBJ/sshd_proxy
463) > $OBJ/ssh_proxy 533) > $OBJ/ssh_proxy
464 534
465# check proxy config 535# check proxy config