mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-27 15:45:53 -05:00
Merge pull request #869 from Ylianst/revert-868-master
Revert "[WIP] Add dynamic resizing of xterm tty"
This commit is contained in:
commit
785cbd8f3a
@ -39,7 +39,8 @@ var MESHRIGHT_LIMITEDINPUT = 4096;
|
|||||||
|
|
||||||
function createMeshCore(agent) {
|
function createMeshCore(agent) {
|
||||||
var obj = {};
|
var obj = {};
|
||||||
if (process.platform == 'win32' && require('user-sessions').isRoot()) {
|
if (process.platform == 'win32' && require('user-sessions').isRoot())
|
||||||
|
{
|
||||||
// Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
|
// Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
|
||||||
try {
|
try {
|
||||||
var writtenSize = 0, actualSize = Math.floor(require('fs').statSync(process.execPath).size / 1024);
|
var writtenSize = 0, actualSize = Math.floor(require('fs').statSync(process.execPath).size / 1024);
|
||||||
@ -1223,28 +1224,21 @@ function createMeshCore(agent) {
|
|||||||
var options = { uid: (this.httprequest.protocol == 8) ? require('user-sessions').consoleUid() : null, env: env };
|
var options = { uid: (this.httprequest.protocol == 8) ? require('user-sessions').consoleUid() : null, env: env };
|
||||||
var setupcommands = ' alias ls=\'ls --color=auto\'\n';
|
var setupcommands = ' alias ls=\'ls --color=auto\'\n';
|
||||||
if (shell == sh) setupcommands += ' stty erase ^H\n';
|
if (shell == sh) setupcommands += ' stty erase ^H\n';
|
||||||
|
setupcommands += ' clear\n';
|
||||||
|
|
||||||
if (script && shell && process.platform == 'linux') {
|
if (script && shell && process.platform == 'linux') {
|
||||||
this.httprequest.process = childProcess.execFile(script, ['script', '--return', '--quiet', '-c', '"' + shell + '"', '/dev/null'], options); // Start as active user
|
this.httprequest.process = childProcess.execFile(script, ['script', '--return', '--quiet', '-c', '"' + shell + '"', '/dev/null'], options); // Start as active user
|
||||||
// Is child process the shell? Needed for resizing.
|
|
||||||
this.httprequest.process.isChildShell = true;
|
|
||||||
this.httprequest.process.stdin.write(setupcommands);
|
this.httprequest.process.stdin.write(setupcommands);
|
||||||
} else if (python && shell) {
|
} else if (python && shell) {
|
||||||
this.httprequest.process = childProcess.execFile(python, ['python', '-c', 'import pty; pty.spawn(["' + shell + '"])'], options); // Start as active user
|
this.httprequest.process = childProcess.execFile(python, ['python', '-c', 'import pty; pty.spawn(["' + shell + '"])'], options); // Start as active user
|
||||||
// Is child process the shell? Needed for resizing.
|
|
||||||
this.httprequest.process.isChildShell = true;
|
|
||||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands); }
|
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands); }
|
||||||
} else if (bash) {
|
} else if (bash) {
|
||||||
options.type = childProcess.SpawnTypes.TERM;
|
options.type = childProcess.SpawnTypes.TERM;
|
||||||
this.httprequest.process = childProcess.execFile(bash, ['bash', '-i'], options); // Start as active user
|
this.httprequest.process = childProcess.execFile(bash, ['bash', '-i'], options); // Start as active user
|
||||||
// Is child process the shell? Needed for resizing.
|
|
||||||
this.httprequest.process.isChildShell = false;
|
|
||||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands); }
|
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands); }
|
||||||
} else if (sh) {
|
} else if (sh) {
|
||||||
options.type = childProcess.SpawnTypes.TERM;
|
options.type = childProcess.SpawnTypes.TERM;
|
||||||
this.httprequest.process = childProcess.execFile(sh, ['sh'], options); // Start as active user
|
this.httprequest.process = childProcess.execFile(sh, ['sh'], options); // Start as active user
|
||||||
// Is child process the shell? Needed for resizing.
|
|
||||||
this.httprequest.process.isChildShell = false;
|
|
||||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands + "PS1='$ '\n"); }
|
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands + "PS1='$ '\n"); }
|
||||||
} else {
|
} else {
|
||||||
MeshServerLog("Failed to start remote terminal session, no shell found");
|
MeshServerLog("Failed to start remote terminal session, no shell found");
|
||||||
@ -1797,15 +1791,8 @@ function createMeshCore(agent) {
|
|||||||
// TODO
|
// TODO
|
||||||
} else {
|
} else {
|
||||||
if (ws.httprequest.process == null) return;
|
if (ws.httprequest.process == null) return;
|
||||||
// ILibDuktape_ChildProcess kill doesn't support sending signals
|
//sendConsoleText('Linux-TermSize: ' + obj.cols + 'x' + obj.rows);
|
||||||
if (fs.existsSync("/bin/kill"))
|
// TODO
|
||||||
{
|
|
||||||
if (ws.httprequest.process.isChildShell)
|
|
||||||
// We need to send signal to the child of the process, since the child is the shell
|
|
||||||
childProcess.execFile('/bin/bash', ['bash', "-c", "kill -SIGWINCH $(pgrep -P " + ws.httprequest.process.pid + ")"]);
|
|
||||||
else
|
|
||||||
childProcess.execFile('/bin/bash', ['bash', "-c", "kill -SIGWINCH " + ws.httprequest.process.pid]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2239,7 +2226,8 @@ function createMeshCore(agent) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'ps': {
|
case 'ps': {
|
||||||
processManager.getProcesses(function (plist) {
|
processManager.getProcesses(function (plist)
|
||||||
|
{
|
||||||
var x = '';
|
var x = '';
|
||||||
for (var i in plist) { x += i + ((plist[i].user) ? (', ' + plist[i].user) : '') + ', ' + plist[i].cmd + '\r\n'; }
|
for (var i in plist) { x += i + ((plist[i].user) ? (', ' + plist[i].user) : '') + ', ' + plist[i].cmd + '\r\n'; }
|
||||||
sendConsoleText(x, sessionid);
|
sendConsoleText(x, sessionid);
|
||||||
|
@ -180,7 +180,6 @@
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// Connected
|
// Connected
|
||||||
tunnel.sendText(`mcresize() { old=$(stty -g);stty raw -echo min 0 time 5;printf '\\0337\\033[r\\033[999;999H\\033[6n\\0338' > /dev/tty;IFS='[;R' read -r _ rows cols _ < /dev/tty;stty "$old";stty cols "$cols" rows "$rows"; };trap mcresize SIGWINCH;clear\n`);
|
|
||||||
term.focus();
|
term.focus();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user