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
This commit is contained in:
TotallyNotElite 2019-11-24 19:29:53 +01:00
parent 04f0e7a321
commit c824de1bb1

View File

@ -1099,7 +1099,11 @@ function createMeshCore(agent) {
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
} else {
if (fs.existsSync("/bin/bash")) {
if (fs.existsSync("/usr/bin/python") && fs.existsSync("/bin/bash")) {
this.httprequest.process = childProcess.execFile("/usr/bin/python", [ "python", "-c", "import pty; pty.spawn([\"/bin/bash\"])" ], { type: childProcess.SpawnTypes.TERM });
if (process.platform == 'linux') { this.httprequest.process.stdin.write("export TERM='xterm'\nalias ls='ls --color=auto'\nclear\n"); }
}
else if (fs.existsSync("/bin/bash")) {
this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
} else {