Open italovalcy opened 3 weeks ago
Maybe it has to do with some recent changes I made on the xterm function, which now leverages Node.popen
instead of calling mnexec directly:
diff --git a/mnsec/api_server.py b/mnsec/api_server.py
index b9c377d..9afdb04 100644
--- a/mnsec/api_server.py
+++ b/mnsec/api_server.py
@@ -360,13 +360,22 @@ class APIServer:
# of this subprocess
host_pid = self.mnsec[host].pid
homeDir = self.mnsec.setupHostHomeDir(host)
- myenv = {"PS1": f"\\u@{host}:\\W\\$ ", "HOME": homeDir}
+ myenv = dict(os.environ)
+ myenv.update({"PS1": f"\\u@{host}:\\W\\$ ", "HOME": homeDir})
# workaround to avoid bash overridding PS1
myenv["SUDO_USER"] = "root"
myenv["SUDO_PS1"] = "# "
- subprocess.run(['mnexec', '-a', str(host_pid), "bash"], env=myenv, cwd=homeDir)
+ #subprocess.run(['mnexec', '-a', str(host_pid), "bash"], env=myenv, cwd=homeDir)
+ with self.mnsec[host].popen(
+ "bash", env=myenv, cwd=homeDir, stdout=None, stderr=None,
+ ) as process:
+ try:
+ stdout, stderr = process.communicate()
+ except:
+ process.kill()
# after finish make sure we cleanup
self.xterm_conns.pop(host, None)
else:
# this is the parent process fork.
# store child fd and pid
Hi,
If you leave a command running on mininet-sec console, let's say a ping from a host to another, and then try to open the Terminal on the WebUI, you will get the following error: