Skip to content

Commit

Permalink
mucmd: start process the same way as base process is started
Browse files Browse the repository at this point in the history
       Fixes issue seen with rootless containers
  • Loading branch information
louberger committed Dec 17, 2023
1 parent d7e675b commit 4b1fcab
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions munet/mucmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,14 @@ def main(*args):
ecmd = "/usr/bin/nsenter"
eargs = [ecmd]

output = subprocess.check_output(["/usr/bin/nsenter", "--help"], encoding="utf-8")
if " -a," in output:
eargs.append("-a")
else:
# -U doesn't work
for flag in ["-u", "-i", "-m", "-n", "-C", "-T"]:
if f" {flag}," in output:
eargs.append(flag)
#start mucmd same way base process is started
eargs.append(f"--mount=/proc/{pid}/ns/mnt")
eargs.append(f"--net=/proc/{pid}/ns/net")
eargs.append(f"--pid=/proc/{pid}/ns/pid_for_children")
eargs.append(f"--uts=/proc/{pid}/ns/uts")
eargs.append(f"--wd={rundir}")
eargs.extend(["-t", pid])
eargs += args.shellcmd
# print("Using ", eargs)
#print("Using ", eargs)
return os.execvpe(ecmd, eargs, {**env, **envcfg})


Expand Down

0 comments on commit 4b1fcab

Please sign in to comment.