aboutgitcodebugslistschat
path: root/test/passt.mbuto
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-12 20:56:22 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-13 05:32:00 +0200
commit56e755ba1146dc6bd488bedc155db5be9c47ac12 (patch)
tree7123e2f9ae1d1ff9b125d897e2f0f93d880d9667 /test/passt.mbuto
parenta8a437abd6c03161c0d7430f969f6a32d046dc29 (diff)
downloadpasst-56e755ba1146dc6bd488bedc155db5be9c47ac12.tar
passt-56e755ba1146dc6bd488bedc155db5be9c47ac12.tar.gz
passt-56e755ba1146dc6bd488bedc155db5be9c47ac12.tar.bz2
passt-56e755ba1146dc6bd488bedc155db5be9c47ac12.tar.lz
passt-56e755ba1146dc6bd488bedc155db5be9c47ac12.tar.xz
passt-56e755ba1146dc6bd488bedc155db5be9c47ac12.tar.zst
passt-56e755ba1146dc6bd488bedc155db5be9c47ac12.zip
test: Use context system for guest commands
Extends the context system in the test scripts to allow executing commands within a guest. Do this without requiring an existing network in the guest by using socat to run ssh via a vsock connection. We do need some additional "sleep"s in the tests, because the new faster dispatch means that sometimes we attempt to connect before socat has managed to listen. For now, only use this for the plain "passt" tests. The "passt_in_ns" and other tests have additional complications we still need to deal with. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'test/passt.mbuto')
-rwxr-xr-xtest/passt.mbuto32
1 files changed, 29 insertions, 3 deletions
diff --git a/test/passt.mbuto b/test/passt.mbuto
index 8b41674..d29f456 100755
--- a/test/passt.mbuto
+++ b/test/passt.mbuto
@@ -13,15 +13,15 @@
PROGS="${PROGS:-ash,dash,bash ip mount ls insmod mkdir ln cat chmod lsmod
modprobe find grep mknod mv rm umount jq iperf3 dhclient hostname
sed tr chown sipcalc cut md5sum socat dd strace ping tail killall sleep
- sysctl nproc tcp_rr tcp_crr udp_rr which tee seq bc}"
+ sysctl nproc tcp_rr tcp_crr udp_rr which tee seq bc sshd ssh-keygen}"
-KMODS="${KMODS:- virtio_net virtio_pci}"
+KMODS="${KMODS:- virtio_net virtio_pci vmw_vsock_virtio_transport}"
LINKS="${LINKS:-
ash,dash,bash /init
ash,dash,bash /bin/sh}"
-DIRS="${DIRS} /tmp /sbin /var/log /var/run /var/lib"
+DIRS="${DIRS} /tmp /sbin /usr/share /var/log /var/lib /etc/ssh /run/sshd /root/.ssh"
FIXUP="${FIXUP}"'
cat > /sbin/dhclient-script << EOF
@@ -46,7 +46,33 @@ exit 0
EOF
chmod 755 /sbin/dhclient-script
ln -s /sbin /usr/sbin
+ ln -s /bin /usr/bin
+ ln -s /run /var/run
:> /etc/fstab
+
+ # sshd(dropbear) via vsock
+ cat > /etc/passwd << EOF
+root:x:0:0:root:/root:/bin/sh
+sshd:x:100:100:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
+EOF
+ cat > /etc/shadow << EOF
+root:::0:99999:7:::
+EOF
+ chmod 000 /etc/shadow
+
+ :> /etc/ssh/sshd_config
+ ssh-keygen -A
+ chmod 700 /root/.ssh
+ chmod 700 /run/sshd
+ # Alternative location for the priv separation dir
+ ln -s /run/sshd /usr/share/empty.sshd
+
+ cat > /root/.ssh/authorized_keys <<EOF
+'"$(cat guest-key.pub)"'
+EOF
+ chmod 600 /root/.ssh/authorized_keys
+ chmod 700 /root
+ socat VSOCK-LISTEN:22,fork EXEC:"sshd -i -e" 2> /var/log/vsock-ssh.log &
sh +m
'