public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] test/lib/setup: Unshare PID namespace in pasta_setup()
@ 2022-03-02  9:28 Stefano Brivio
  0 siblings, 0 replies; only message in thread
From: Stefano Brivio @ 2022-03-02  9:28 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]

...otherwise, we'll leave processes (dhclient) around.

Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
 test/lib/setup | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/test/lib/setup b/test/lib/setup
index b076eff..f04949e 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -69,12 +69,16 @@ setup_pasta() {
 
 	layout_pasta
 
-	pane_run NS "unshare -rUn /bin/sh "
+	pane_run NS 'echo $$'
 	pane_wait NS
+	__tty_pid="$(pane_parse NS)"
 
-	pane_run NS 'echo $$'
+	pane_run NS "unshare -rUnpf /bin/sh"
 	pane_wait NS
-	__pasta_pid="$(pane_parse NS)"
+
+	pane_run PASST "pstree -p ${__tty_pid} | sed -n 's/.*(\([0-9].*\))$/\1/p'"
+	pane_wait PASST
+	__target_pid="$(pane_parse PASST)"
 
 	# Ports:
 	#
@@ -87,7 +91,7 @@ setup_pasta() {
 	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 
-	pane_run PASST "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 ${__pasta_pid}"
+	pane_run PASST "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 ${__target_pid}"
 	sleep 1
 }
 
-- 
@@ -69,12 +69,16 @@ setup_pasta() {
 
 	layout_pasta
 
-	pane_run NS "unshare -rUn /bin/sh "
+	pane_run NS 'echo $$'
 	pane_wait NS
+	__tty_pid="$(pane_parse NS)"
 
-	pane_run NS 'echo $$'
+	pane_run NS "unshare -rUnpf /bin/sh"
 	pane_wait NS
-	__pasta_pid="$(pane_parse NS)"
+
+	pane_run PASST "pstree -p ${__tty_pid} | sed -n 's/.*(\([0-9].*\))$/\1/p'"
+	pane_wait PASST
+	__target_pid="$(pane_parse PASST)"
 
 	# Ports:
 	#
@@ -87,7 +91,7 @@ setup_pasta() {
 	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 
-	pane_run PASST "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 ${__pasta_pid}"
+	pane_run PASST "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 ${__target_pid}"
 	sleep 1
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-02  9:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02  9:28 [PATCH] test/lib/setup: Unshare PID namespace in pasta_setup() Stefano Brivio

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).