mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-23 06:34:54 +03:00
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:
parent
04f0e7a321
commit
c824de1bb1
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user