2008-11-21 16:00:18 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Written by Simon Josefsson.
|
|
|
|
|
|
|
|
# Start sshd, invoke parameters, saving exit code, kill sshd, and
|
|
|
|
# return exit code.
|
|
|
|
|
|
|
|
srcdir=${srcdir:-$PWD}
|
|
|
|
SSHD=${SSHD:-/usr/sbin/sshd}
|
|
|
|
|
2008-11-27 17:00:07 +01:00
|
|
|
cmd="./ssh2${EXEEXT}"
|
|
|
|
srcdir=`cd $srcdir; pwd`
|
|
|
|
|
2008-11-21 16:00:18 +01:00
|
|
|
PRIVKEY=$srcdir/etc/user
|
|
|
|
export PRIVKEY
|
|
|
|
PUBKEY=$srcdir/etc/user.pub
|
|
|
|
export PUBKEY
|
|
|
|
|
|
|
|
chmod go-r $srcdir/etc/host*
|
|
|
|
$SSHD -f /dev/null -h $srcdir/etc/host \
|
2009-03-17 18:25:42 +01:00
|
|
|
-o 'Port 4711' \
|
|
|
|
-o 'Protocol 2' \
|
|
|
|
-o 'UsePrivilegeSeparation no' \
|
|
|
|
-o "AuthorizedKeysFile $srcdir/etc/user.pub" \
|
|
|
|
-D &
|
2008-11-21 16:00:18 +01:00
|
|
|
sshdpid=$!
|
|
|
|
|
|
|
|
trap "kill ${sshdpid}; echo signal killing sshd; exit 1;" EXIT
|
|
|
|
|
|
|
|
: "started sshd (${sshdpid})"
|
|
|
|
|
2008-12-17 17:22:37 +01:00
|
|
|
sleep 3
|
2008-11-21 16:00:18 +01:00
|
|
|
|
|
|
|
: Invoking $cmd...
|
|
|
|
eval $cmd
|
|
|
|
ec=$?
|
|
|
|
: Self-test exit code $ec
|
|
|
|
|
|
|
|
: "killing sshd (${sshdpid})"
|
|
|
|
kill "${sshdpid}" > /dev/null 2>&1
|
|
|
|
trap "" EXIT
|
|
|
|
exit $ec
|