Use PTY if python is available

Problem: starting bash with -i will only make the current shell interactive, but not further sub shells (if you switch user for example). Fix: Use a PTY

TotallyNotElite committed Nov 24, 2019 at 19:29 UTC c824de1bb1a7f2463074fdeaafc50766bda2ee01
1 file changed +5 -1
agents/meshcore.js
+5 -1
@@ -1099,7 +1099,11 @@ function createMeshCore(agent) {
1099 this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
1100 this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
1101 } else {
1102 - if (fs.existsSync("/bin/bash")) {
1102 + if (fs.existsSync("/usr/bin/python") && fs.existsSync("/bin/bash")) {
1103 + this.httprequest.process = childProcess.execFile("/usr/bin/python", [ "python", "-c", "import pty; pty.spawn([\"/bin/bash\"])" ], { type: childProcess.SpawnTypes.TERM });
1104 + if (process.platform == 'linux') { this.httprequest.process.stdin.write("export TERM='xterm'\nalias ls='ls --color=auto'\nclear\n"); }
1105 + }
1106 + else if (fs.existsSync("/bin/bash")) {
1107 this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
1108 if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
1109 } else {