Improved event logs when running remote commands.

This commit is contained in:
Ylian Saint-Hilaire 2020-10-07 18:02:02 -07:00
parent 6f23c450b0
commit a435d57be5
5 changed files with 466 additions and 445 deletions

View File

@ -959,7 +959,6 @@ function createMeshCore(agent) {
}
case 'runcommands': {
if (mesh.cmdchild != null) { sendConsoleText("Run commands can't execute, already busy."); break; }
MeshServerLogEx(24, null, "Running commands", data);
sendConsoleText("Run commands (" + data.runAsUser + "): " + data.cmds);
// data.runAsUser: 0=Agent,1=UserOrAgent,2=UserOnly

View File

@ -3642,6 +3642,14 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Send the commands to the agent
try { agent.send(JSON.stringify({ action: 'runcommands', type: command.type, cmds: command.cmds, runAsUser: command.runAsUser })); } catch (ex) { }
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'runcommands', responseid: command.responseid, result: 'OK' })); } catch (ex) { } }
// Send out an event that these commands where run on this device
var targets = parent.CreateNodeDispatchTargets(node.meshid, node._id, ['server-users', user._id]);
var msgid = 24; // "Running commands"
if (command.type == 1) { msgid = 99; } // "Running commands as user"
if (command.type == 2) { msgid = 100; } // "Running commands as user if possible"
var event = { etype: 'node', userid: user._id, username: user.name, nodeid: node._id, action: 'runcommands', msg: 'Running commands', msgid: msgid, cmds: command.cmds, cmdType: command.type, runAsUser: command.runAsUser, domain: domain.id };
parent.parent.DispatchEvent(targets, obj, event);
} else {
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'runcommands', responseid: command.responseid, result: 'Invalid command type' })); } catch (ex) { } }
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -10777,7 +10777,9 @@
95: "Added security key",
96: "Verified phone number of user {0}",
97: "Removed phone number of user {0}",
98: "Help Requested, user: {0}, details: {1}"
98: "Help Requested, user: {0}, details: {1}",
99: "Running commands as user",
100: "Running commands as user if possible"
};
// Highlights the device being hovered