From 6e97142b84551e1d5d3fc60f10ac7dea02a42e3f Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 29 Feb 2024 11:37:29 +0100 Subject: [PATCH] test: shell & cleanup cleanup --- test/units/testsuite-46.sh | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/test/units/testsuite-46.sh b/test/units/testsuite-46.sh index d097ccdac8c..6102a430a90 100755 --- a/test/units/testsuite-46.sh +++ b/test/units/testsuite-46.sh @@ -446,14 +446,15 @@ for opt in json multiplexer output synthesize with-dropin with-nss with-varlink; done # FIXME: sshd seems to crash inside asan currently, skip the actual ssh test hence -if command -v ssh &> /dev/null && command -v sshd &> /dev/null && ! [[ -v ASAN_OPTIONS ]]; then - +if command -v ssh &>/dev/null && command -v sshd &>/dev/null && ! [[ -v ASAN_OPTIONS ]]; then at_exit() { - systemctl stop mysshserver.socket - rm -f /tmp/homed.id_rsa /run/systemd/system/mysshserver.socket /run/systemd/system/mysshserver@.service + set +e + + systemctl is-active -q mysshserver.socket && systemctl stop mysshserver.socket + rm -f /tmp/homed.id_rsa /run/systemd/system/mysshserver{@.service,.socket} systemctl daemon-reload - homectl remove homedsshtest ||: - mv /etc/pam.d/sshd.save46 /etc/pam.d/sshd + homectl remove homedsshtest + mv /etc/pam.d/sshd.bak /etc/pam.d/sshd } trap at_exit EXIT @@ -469,6 +470,7 @@ if command -v ssh &> /dev/null && command -v sshd &> /dev/null && ! [[ -v ASAN_O --ssh-authorized-keys=@/tmp/homed.id_rsa.pub \ --stop-delay=0 \ homedsshtest + homectl inspect homedsshtest mkdir -p /etc/ssh test -f /etc/ssh/ssh_host_rsa_key || ssh-keygen -t rsa -C '' -N '' -f /etc/ssh/ssh_host_rsa_key @@ -476,9 +478,8 @@ if command -v ssh &> /dev/null && command -v sshd &> /dev/null && ! [[ -v ASAN_O # ssh wants this dir around, but distros cannot agree on a common name for it, let's just create all that are aware of distros use mkdir -p /usr/share/empty.sshd /var/empty /var/empty/sshd - mv /etc/pam.d/sshd /etc/pam.d/sshd.save46 - - cat > /etc/pam.d/sshd </etc/pam.d/sshd <> /etc/ssh/sshd_config </etc/ssh/sshd_config < /run/systemd/system/mysshserver.socket </run/systemd/system/mysshserver.socket < /run/systemd/system/mysshserver@.service </run/systemd/system/mysshserver@.service < /tmp/homedsshtest.out + ssh -t -t -4 -p 4711 -i /tmp/homed.id_rsa \ + -o "SetEnv PASSWORD=hunter4711" -o "StrictHostKeyChecking no" \ + homedsshtest@localhost echo zzz | tail -n 1 | tr -d '\r' > /tmp/homedsshtest.out cat /tmp/homedsshtest.out test "$(cat /tmp/homedsshtest.out)" = "zzz" rm /tmp/homedsshtest.out - ssh -t -t -4 -p 4711 -i /tmp/homed.id_rsa -o "SetEnv PASSWORD=hunter4711" -o "StrictHostKeyChecking no" homedsshtest@localhost env + ssh -t -t -4 -p 4711 -i /tmp/homed.id_rsa \ + -o "SetEnv PASSWORD=hunter4711" -o "StrictHostKeyChecking no" \ + homedsshtest@localhost env wait_for_state homedsshtest inactive - homectl remove homedsshtest fi systemd-analyze log-level info -- 2.47.3