From 9001ae5a674bc8c4b26fc50019a0994b5b7ee166 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Sun, 23 Apr 2023 01:29:49 -0400 Subject: [PATCH] tests: import munet version 0.12.16 Fixes bad fixed path use and rootcmd functionality to run things in the root namespace (all but pid at least). Signed-off-by: Christian Hopps --- tests/topotests/munet/base.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/topotests/munet/base.py b/tests/topotests/munet/base.py index 9238736c3e..38da7faa01 100644 --- a/tests/topotests/munet/base.py +++ b/tests/topotests/munet/base.py @@ -1976,9 +1976,9 @@ class LinuxNamespace(Commander, InterfaceMixin): if unet and unet.nsenter_fork: assert not unet.unshare_inline # Need child pid of p.pid - pgrep = roothost.get_exec_path("pgrep") + pgrep = unet.rootcmd.get_exec_path("pgrep") # a sing fork was done - child_pid = roothost.cmd_raises([pgrep, "-o", "-P", str(p.pid)]) + child_pid = unet.rootcmd.cmd_raises([pgrep, "-o", "-P", str(p.pid)]) self.pid = int(child_pid.strip()) self.logger.debug("%s: child of namespace process: %s", self, pid) @@ -2172,10 +2172,9 @@ class LinuxNamespace(Commander, InterfaceMixin): # this will fail if running inside the namespace with PID if pid: - o = self.cmd_status_nsonly("ls -l /proc/1/ns") + o = self.cmd_nostatus_nsonly("ls -l /proc/1/ns") else: - o = self.cmd_nostatus_nsonly(cmd=shlex.split("/usr/bin/ls -l /proc/self")) - o = self.cmd_nostatus_nsonly(cmd=shlex.split("ls -l /proc/self/ns")) + o = self.cmd_nostatus_nsonly("ls -l /proc/self/ns") self.logger.debug("namespaces:\n %s", o) @@ -2536,10 +2535,21 @@ class BaseMunet(LinuxNamespace): if not self.isolated: self.rootcmd = commander + elif not pid: + nsflags = ( + f"--mount={self.proc_path / '1/ns/mnt'}", + f"--net={self.proc_path / '1/ns/net'}", + f"--uts={self.proc_path / '1/ns/uts'}", + # f"--ipc={self.proc_path / '1/ns/ipc'}", + # f"--time={self.proc_path / '1/ns/time'}", + # f"--cgroup={self.proc_path / '1/ns/cgroup'}", + ) + self.rootcmd = SharedNamespace("root", pid=1, nsflags=nsflags) else: # XXX user nsflags = ( - f"--pid={self.proc_path / '1/ns/pid_for_children'}", + # XXX Backing up PID namespace just doesn't work. + # f"--pid={self.proc_path / '1/ns/pid_for_children'}", f"--mount={self.proc_path / '1/ns/mnt'}", f"--net={self.proc_path / '1/ns/net'}", f"--uts={self.proc_path / '1/ns/uts'}", -- 2.39.5