mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-27 23:55:54 -05:00
fix runcommands missing data (#5477)
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
6c15bcbe05
commit
2173921f07
@ -1496,33 +1496,33 @@ function handleServerCommand(data) {
|
|||||||
if (options.uid == null) break;
|
if (options.uid == null) break;
|
||||||
if (((require('user-sessions').minUid != null) && (options.uid < require('user-sessions').minUid()))) break; // This command can only run as user.
|
if (((require('user-sessions').minUid != null) && (options.uid < require('user-sessions').minUid()))) break; // This command can only run as user.
|
||||||
}
|
}
|
||||||
|
var replydata = "";
|
||||||
if (process.platform == 'win32') {
|
if (process.platform == 'win32') {
|
||||||
if (data.type == 1) {
|
if (data.type == 1) {
|
||||||
// Windows command shell
|
// Windows command shell
|
||||||
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd'], options);
|
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\system32\\cmd.exe', ['cmd'], options);
|
||||||
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
||||||
mesh.cmdchild.stdout.on('data', function (c) { sendConsoleText(c.toString()); });
|
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); });
|
||||||
mesh.cmdchild.stderr.on('data', function (c) { sendConsoleText(c.toString()); });
|
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); });
|
||||||
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
||||||
mesh.cmdchild.on('exit', function () { sendConsoleText("Run commands completed."); delete mesh.cmdchild; });
|
mesh.cmdchild.on('exit', function () { sendConsoleText(replydata); sendConsoleText("Run commands completed."); delete mesh.cmdchild; });
|
||||||
} else if (data.type == 2) {
|
} else if (data.type == 2) {
|
||||||
// Windows Powershell
|
// Windows Powershell
|
||||||
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], options);
|
mesh.cmdchild = require('child_process').execFile(process.env['windir'] + '\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', ['powershell', '-noprofile', '-nologo', '-command', '-'], options);
|
||||||
mesh.cmdchild.descriptorMetadata = 'UserCommandsPowerShell';
|
mesh.cmdchild.descriptorMetadata = 'UserCommandsPowerShell';
|
||||||
mesh.cmdchild.stdout.on('data', function (c) { sendConsoleText(c.toString()); });
|
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); });
|
||||||
mesh.cmdchild.stderr.on('data', function (c) { sendConsoleText(c.toString()); });
|
mesh.cmdchild.stderr.on('data', function (c) { replydata += c.toString(); });
|
||||||
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
mesh.cmdchild.stdin.write(data.cmds + '\r\nexit\r\n');
|
||||||
mesh.cmdchild.on('exit', function () { sendConsoleText("Run commands completed."); delete mesh.cmdchild; });
|
mesh.cmdchild.on('exit', function () { sendConsoleText(replydata); sendConsoleText("Run commands completed."); delete mesh.cmdchild; });
|
||||||
}
|
}
|
||||||
} else if (data.type == 3) {
|
} else if (data.type == 3) {
|
||||||
// Linux shell
|
// Linux shell
|
||||||
mesh.cmdchild = require('child_process').execFile('/bin/sh', ['sh'], options);
|
mesh.cmdchild = require('child_process').execFile('/bin/sh', ['sh'], options);
|
||||||
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
mesh.cmdchild.descriptorMetadata = 'UserCommandsShell';
|
||||||
mesh.cmdchild.stdout.on('data', function (c) { sendConsoleText(c.toString()); });
|
mesh.cmdchild.stdout.on('data', function (c) { replydata += c.toString(); });
|
||||||
mesh.cmdchild.stderr.on('data', function (c) { sendConsoleText(c.toString()); });
|
mesh.cmdchild.stderr.on('data', function (c) { replydata + c.toString(); });
|
||||||
mesh.cmdchild.stdin.write(data.cmds.split('\r').join('') + '\nexit\n');
|
mesh.cmdchild.stdin.write(data.cmds.split('\r').join('') + '\nexit\n');
|
||||||
mesh.cmdchild.on('exit', function () { sendConsoleText("Run commands completed."); delete mesh.cmdchild; });
|
mesh.cmdchild.on('exit', function () { sendConsoleText(replydata); sendConsoleText("Run commands completed."); delete mesh.cmdchild; });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user