Revert "[WIP] Add dynamic resizing of xterm tty"
Ylian Saint-Hilaire committed
Jan 24, 2020 at 15:10 UTC
0a966e54e29c2acfeaba0524689e61fa282a0ec8
2 files changed
+7
-20
agents/meshcore.js
+7
-19
@@ -39,7 +39,8 @@ var MESHRIGHT_LIMITEDINPUT = 4096;
39
40
function createMeshCore(agent) {
41
var obj = {};
42
- if (process.platform == 'win32' && require('user-sessions').isRoot()) {
42
+ if (process.platform == 'win32' && require('user-sessions').isRoot())
43
+ {
44
// Check the Agent Uninstall MetaData for correctness, as the installer may have written an incorrect value
45
try {
46
var writtenSize = 0, actualSize = Math.floor(require('fs').statSync(process.execPath).size / 1024);
@@ -1223,28 +1224,21 @@ function createMeshCore(agent) {
1224
var options = { uid: (this.httprequest.protocol == 8) ? require('user-sessions').consoleUid() : null, env: env };
1225
var setupcommands = ' alias ls=\'ls --color=auto\'\n';
1226
if (shell == sh) setupcommands += ' stty erase ^H\n';
1227
+ setupcommands += ' clear\n';
1228
1229
if (script && shell && process.platform == 'linux') {
1230
this.httprequest.process = childProcess.execFile(script, ['script', '--return', '--quiet', '-c', '"' + shell + '"', '/dev/null'], options); // Start as active user
1229
- // Is child process the shell? Needed for resizing.
1230
- this.httprequest.process.isChildShell = true;
1231
this.httprequest.process.stdin.write(setupcommands);
1232
} else if (python && shell) {
1233
this.httprequest.process = childProcess.execFile(python, ['python', '-c', 'import pty; pty.spawn(["' + shell + '"])'], options); // Start as active user
1234
- // Is child process the shell? Needed for resizing.
1235
- this.httprequest.process.isChildShell = true;
1234
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands); }
1235
} else if (bash) {
1236
options.type = childProcess.SpawnTypes.TERM;
1237
this.httprequest.process = childProcess.execFile(bash, ['bash', '-i'], options); // Start as active user
1240
- // Is child process the shell? Needed for resizing.
1241
- this.httprequest.process.isChildShell = false;
1238
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands); }
1239
} else if (sh) {
1240
options.type = childProcess.SpawnTypes.TERM;
1241
this.httprequest.process = childProcess.execFile(sh, ['sh'], options); // Start as active user
1246
- // Is child process the shell? Needed for resizing.
1247
- this.httprequest.process.isChildShell = false;
1242
if (process.platform == 'linux') { this.httprequest.process.stdin.write(setupcommands + "PS1='$ '\n"); }
1243
} else {
1244
MeshServerLog("Failed to start remote terminal session, no shell found");
@@ -1797,15 +1791,8 @@ function createMeshCore(agent) {
1791
// TODO
1792
} else {
1793
if (ws.httprequest.process == null) return;
1800
- // ILibDuktape_ChildProcess kill doesn't support sending signals
1801
- if (fs.existsSync("/bin/kill"))
1802
- {
1803
- if (ws.httprequest.process.isChildShell)
1804
- // We need to send signal to the child of the process, since the child is the shell
1805
- childProcess.execFile('/bin/bash', ['bash', "-c", "kill -SIGWINCH $(pgrep -P " + ws.httprequest.process.pid + ")"]);
1806
- else
1807
- childProcess.execFile('/bin/bash', ['bash', "-c", "kill -SIGWINCH " + ws.httprequest.process.pid]);
1808
- }
1794
+ //sendConsoleText('Linux-TermSize: ' + obj.cols + 'x' + obj.rows);
1795
+ // TODO
1796
}
1797
}
1798
break;
@@ -2239,7 +2226,8 @@ function createMeshCore(agent) {
2226
break;
2227
}
2228
case 'ps': {
2242
- processManager.getProcesses(function (plist) {
2229
+ processManager.getProcesses(function (plist)
2230
+ {
2231
var x = '';
2232
for (var i in plist) { x += i + ((plist[i].user) ? (', ' + plist[i].user) : '') + ', ' + plist[i].cmd + '\r\n'; }
2233
sendConsoleText(x, sessionid);
views/xterm.handlebars
-1
@@ -180,7 +180,6 @@
180
break;
181
case 3:
182
// Connected
183
- 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`);
183
term.focus();
184
break;
185
default: