1#!/bin/sh 2 3# Written by Simon Josefsson. 4 5# Start sshd, invoke parameters, saving exit code, kill sshd, and 6# return exit code. 7 8srcdir="@SSHD_TEST_CONFIG_DIR@" 9SSHD="@SSHD_EXECUTABLE@" 10 11cmd="\"$1\"" 12 13PRIVKEY=$srcdir/etc/user 14export PRIVKEY 15PUBKEY=$srcdir/etc/user.pub 16export PUBKEY 17 18if test -n "$DEBUG"; then 19 libssh2_sshd_params="-d -d" 20fi 21 22chmod go-rwx "$srcdir"/etc/host* 23"$SSHD" -f /dev/null -h "$srcdir/etc/host" \ 24 -o 'Port 4711' \ 25 -o 'Protocol 2' \ 26 -o "AuthorizedKeysFile \"$srcdir/etc/user.pub\"" \ 27 -o 'UsePrivilegeSeparation no' \ 28 -o 'StrictModes no' \ 29 -D \ 30 $libssh2_sshd_params & 31sshdpid=$! 32 33trap "kill ${sshdpid}; echo signal killing sshd; exit 1;" EXIT 34 35: "started sshd (${sshdpid})" 36 37sleep 3 38 39if ! kill -0 ${sshdpid} 40then 41 echo "SSHD exited before test started" 42 exit 1 43fi 44 45: Invoking $cmd... 46eval "$cmd" 47ec=$? 48: Self-test exit code $ec 49 50: "killing sshd (${sshdpid})" 51kill "${sshdpid}" > /dev/null 2>&1 52trap "" EXIT 53exit $ec 54