| 1 |
#! /bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
# Make sure sshd is on $PATH. |
| 5 |
export PATH="/usr/sbin:$PATH" |
| 6 |
|
| 7 |
CREATED_RUN_SSHD=false |
| 8 |
STARTED_HAVEGED=false |
| 9 |
ADDED_HOST=false |
| 10 |
|
| 11 |
cleanup () { |
| 12 |
sudo rm -f /usr/lib/openssh/regress/kbdintpw \ |
| 13 |
/usr/lib/openssh/regress/password |
| 14 |
|
| 15 |
if $ADDED_HOST; then |
| 16 |
sudo sed -i '/[[:space:]]UNKNOWN$/d' /etc/hosts |
| 17 |
fi |
| 18 |
|
| 19 |
if $STARTED_HAVEGED; then |
| 20 |
if [ -d /run/systemd/system ] && \ |
| 21 |
which systemctl >/dev/null 2>&1; then |
| 22 |
sudo systemctl disable haveged || true |
| 23 |
sudo systemctl stop haveged || true |
| 24 |
else |
| 25 |
sudo start-stop-daemon --stop --quiet --oknodo \ |
| 26 |
--retry=TERM/30/KILL/5 \ |
| 27 |
--pidfile "$AUTOPKGTEST_TMP/haveged.pid" \ |
| 28 |
--name haveged |
| 29 |
fi |
| 30 |
fi |
| 31 |
|
| 32 |
if $CREATED_RUN_SSHD; then |
| 33 |
sudo rm -rf /run/sshd |
| 34 |
fi |
| 35 |
} |
| 36 |
trap cleanup EXIT |
| 37 |
|
| 38 |
sudo chsh -s /bin/bash "$(id -un)" |
| 39 |
|
| 40 |
# Depending on how the environment is configured, our test dependency on |
| 41 |
# openssh-server may not actually started sshd and thus may not have caused |
| 42 |
# /run/sshd to be created. |
| 43 |
if [ ! -d /run/sshd ]; then |
| 44 |
sudo mkdir -m755 /run/sshd |
| 45 |
CREATED_RUN_SSHD=: |
| 46 |
fi |
| 47 |
|
| 48 |
# If we're running in a container, haveged may not have started |
| 49 |
# automatically. |
| 50 |
if [ -d /run/systemd/system ] && which systemctl >/dev/null 2>&1; then |
| 51 |
sudo systemctl enable haveged || true |
| 52 |
sudo systemctl start haveged || true |
| 53 |
STARTED_HAVEGED=: |
| 54 |
elif ! pidof haveged >/dev/null; then |
| 55 |
sudo start-stop-daemon --start --quiet \ |
| 56 |
--pidfile "$AUTOPKGTEST_TMP/haveged.pid" \ |
| 57 |
--exec /usr/sbin/haveged -- \ |
| 58 |
-p "$AUTOPKGTEST_TMP/haveged.pid" |
| 59 |
STARTED_HAVEGED=: |
| 60 |
fi |
| 61 |
|
| 62 |
# ssh ends up setting PAM_RHOST to "UNKNOWN" during a number of regression |
| 63 |
# tests, which causes DNS resolution delays, slowing down the test suite |
| 64 |
# substantially and causing the connection-timeout tests to fail. The only |
| 65 |
# way to work around this while running tests with "UsePAM yes" appears to |
| 66 |
# be to make "UNKNOWN" resolvable. |
| 67 |
if ! grep -q '[[:space:]]UNKNOWN$' /etc/hosts; then |
| 68 |
echo '127.0.0.2 UNKNOWN' | sudo tee -a /etc/hosts >/dev/null |
| 69 |
ADDED_HOST=: |
| 70 |
fi |
| 71 |
|
| 72 |
# This test runs in an isolated container, so we can safely set things up |
| 73 |
# for keyboard-interactive and password authentication tests to run. We |
| 74 |
# could hardcode a password, but let's generate a random one anyway. |
| 75 |
PASSWORD="$(pwgen -y 16 1)" |
| 76 |
echo "$PASSWORD" | sudo passwd -s "$(id -un)" |
| 77 |
echo "$PASSWORD" | sudo tee /usr/lib/openssh/regress/kbdintpw >/dev/null |
| 78 |
echo "$PASSWORD" | sudo tee /usr/lib/openssh/regress/password >/dev/null |
| 79 |
|
| 80 |
annotate-output +%H:%M:%S.%N \ |
| 81 |
/usr/lib/openssh/regress/run-tests "$AUTOPKGTEST_TMP" "$@" |