public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
de35c3cebdd7555bd976bf7b13187d3096f7f2ef blob 4137 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
 
#!/bin/sh
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# PASST - Plug A Simple Socket Transport
#  for qemu/UNIX domain socket mode
#
# test/passt.mbuto - mbuto (https://mbuto.sh) profile for test images
#
# Copyright (c) 2022 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com>

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 socat dd strace ping tail killall sleep sysctl
       nproc tcp_rr tcp_crr udp_rr which tee seq bc sshd ssh-keygen cmp tcpdump
       env}"

# OpenSSH 9.8 introduced split binaries, with sshd being the daemon, and
# sshd-session the per-session program. We need the latter as well, and the path
# depends on the distribution. It doesn't exist on older versions.
for bin in /usr/lib/openssh/sshd-session /usr/lib/ssh/sshd-session \
	   /usr/libexec/openssh/sshd-session; do
	command -v "${bin}" >/dev/null && PROGS="${PROGS} ${bin}"
done

# OpenSSH 10 adds sshd-auth as well
for bin in /usr/lib/openssh/sshd-auth /usr/lib/ssh/sshd-auth \
	   /usr/libexec/openssh/sshd-auth; do
	command -v "${bin}" >/dev/null && PROGS="${PROGS} ${bin}"
done

KMODS="${KMODS:- virtio_net virtio_pci vmw_vsock_virtio_transport}"

LINKS="${LINKS:-
	 ash,dash,bash		/init
	 ash,dash,bash		/bin/sh
	 sshd			/usr/sbin/sshd
	 dhclient		/usr/sbin/dhclient
	 sysctl			/usr/sbin/sysctl}"

DIRS="${DIRS} /tmp /usr/sbin /usr/bin /usr/share /var/log /var/lib /etc/ssh /run/sshd /root/.ssh"

COPIES="${COPIES} small.bin,/root/small.bin medium.bin,/root/medium.bin big.bin,/root/big.bin rampstream,/bin/rampstream rampstream-check.sh,/bin/rampstream-check.sh"

FIXUP="${FIXUP}"'
	mv /sbin/* /usr/sbin || :
	rm -rf /sbin
	ln -s /usr/sbin /sbin
	cat > /sbin/dhclient-script << EOF
#!/bin/sh
LOG=/var/log/dhclient-script.log
echo \${reason} \${interface} >> \$LOG
env >> \$LOG
set >> \$LOG

[ -n "\${new_interface_mtu}" ]       && ip link set dev \${interface} mtu \${new_interface_mtu}

[ -n "\${new_ip_address}" ]          && ip addr add \${new_ip_address}/\${new_subnet_mask} dev \${interface}
[ -n "\${new_routers}" ]             && for r in \${new_routers}; do ip route add default via \${r} dev \${interface}; done
:> /etc/resolv.conf
[ -n "\${new_domain_name_servers}" ] && for d in \${new_domain_name_servers}; do echo "nameserver \${d}" >> /etc/resolv.conf; done
[ -n "\${new_domain_name}" ]         && echo "search \${new_domain_name}" >> /etc/resolf.conf
[ -n "\${new_domain_search}" ]       && (printf "search"; for d in \${new_domain_search}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
[ -n "\${new_ip6_address}" ]         && ip addr add \${new_ip6_address}/\${new_ip6_prefixlen} dev \${interface}
[ -n "\${new_dhcp6_name_servers}" ]  && for d in \${new_dhcp6_name_servers}; do echo "nameserver \${d}%\${interface}" >> /etc/resolv.conf; done
[ -n "\${new_dhcp6_domain_search}" ] && (printf "search"; for d in \${new_dhcp6_domain_search}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
[ -n "\${new_host_name}" ]           && echo "\${new_host_name}" > /tmp/new_host_name
[ -n "\${new_fqdn_fqdn}" ]           && echo "\${new_fqdn_fqdn}" > /tmp/new_fqdn_fqdn
exit 0
EOF
	chmod 755 /sbin/dhclient-script
	mv /bin/* /usr/bin || :
	rm -rf /bin
	ln -s /usr/bin /bin
	ln -s /run /var/run
	:> /etc/fstab

	# sshd via vsock
	cat > /etc/passwd << EOF
root:x:0:0:root:/root:/bin/sh
tcpdump:x:72:72:tcpdump:/:/sbin/nologin
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

	cat > /etc/ssh/sshd_config << EOF
Subsystem sftp internal-sftp
EOF
	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 2>/dev/null || :)"'
EOF
	chmod 600 /root/.ssh/authorized_keys
	chmod 700 /root
	socat VSOCK-LISTEN:22,fork EXEC:"/sbin/sshd -i -e" 2> /var/log/vsock-ssh.log &
	sh +m
'

OUTPUT="KERNEL=__KERNEL__
INITRD=__INITRD__
"
debug log:

solving de35c3ce ...
found de35c3ce in https://archives.passt.top/passt-dev/20260107014606.1513722-6-david@gibson.dropbear.id.au/ ||
	https://archives.passt.top/passt-dev/20260107001609.910615-6-david@gibson.dropbear.id.au/ ||
	https://archives.passt.top/passt-dev/20260105075337.1724962-6-david@gibson.dropbear.id.au/
found 598c2547 in https://passt.top/passt
preparing index
index prepared:
100755 598c254780c00c7a255cd375b49f0788409c6ee7	test/passt.mbuto

applying [1/3] https://archives.passt.top/passt-dev/20260107014606.1513722-6-david@gibson.dropbear.id.au/
diff --git a/test/passt.mbuto b/test/passt.mbuto
index 598c2547..de35c3ce 100755

Checking patch test/passt.mbuto...
Applied patch test/passt.mbuto cleanly.

skipping https://archives.passt.top/passt-dev/20260107001609.910615-6-david@gibson.dropbear.id.au/ for de35c3ce
skipping https://archives.passt.top/passt-dev/20260105075337.1724962-6-david@gibson.dropbear.id.au/ for de35c3ce
index at:
100755 de35c3cebdd7555bd976bf7b13187d3096f7f2ef	test/passt.mbuto

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).