aboutgitcodebugslistschat
path: root/test/lib/term
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-09-12 20:56:20 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-09-13 05:32:00 +0200
commita8c32c85d5f3847a1f9ea0030beb0c338af53cd5 (patch)
tree6bc14542094830909d0c0c3f1ca127f71bef9af8 /test/lib/term
parent2f87265d8b25cbeeadfb662f2a46db00795747a3 (diff)
downloadpasst-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.gz
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.bz2
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.lz
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.xz
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.tar.zst
passt-a8c32c85d5f3847a1f9ea0030beb0c338af53cd5.zip
test: Add nsholder utility
In our test scripts we need to do some ugly parsing of /proc and/or pstree output in order to get the PIDs of processes running in namespaces so that we can connect to those namespaces with nsenter or pasta. This is actually a pretty tricky problem with standard tools. To determine the PID from the outside of the namespace we need to know how the process of interest is related to the unshare or pasta process (child? one of several children? grandchild?) as well as then parsing /proc or ps output. This is slightly awkward now, and will get worse with future changes I'd like to make to have processes are dispatched. The obvious solution would be to have the process of interest (which we control) report its own PID, but that doesn't work easily, because it is in a PID namepace and sees only its local PID not the global PID we need to address it from outside. To handle this, add a small custom tool, "nsholder". This takes a path and a mode parameter. In "hold" mode it will create a unix domain socket bound to the path and listening. In "pid" mode it will get the "hold"ing process's pid via the unix socket using SO_PEERCRED, which translates between PID namespaces. In "stop" mode it will send a message to the socket causing the "hold"ing process to clean up and exit. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'test/lib/term')
0 files changed, 0 insertions, 0 deletions