1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Added server setting for agent core dump.

This commit is contained in:
Ylian Saint-Hilaire 2020-07-06 16:01:44 -07:00
parent 984ce8b201
commit 35e2e0cd20
5 changed files with 3506 additions and 47 deletions

View file

@ -958,6 +958,14 @@ function createMeshCore(agent) {
try { require(data.plugin).consoleaction(data, data.rights, data.sessionid, this); } catch (e) { throw e; }
break;
}
case 'coredump':
if (data.value === true) {
// TODO: This replace() below is not ideal, would be better to remove the .exe at the end instead of replace.
process.coreDumpLocation = (process.platform == 'win32') ? (process.execPath.replace('.exe', '.dmp')) : (process.execPath + '.dmp');
} else if (data.value === false) {
process.coreDumpLocation = null;
}
break;
default:
// Unknown action, ignore it.
break;
@ -2261,16 +2269,13 @@ function createMeshCore(agent) {
break;
}
case 'coredump':
if (args['_'].length != 1)
{
response = "Proper usage: coredump on|off|status"; // Display usage
}
else
{
if (args['_'].length != 1) {
response = "Proper usage: coredump on|off|status"; // Display usage
} else {
switch (args['_'][0].toLowerCase())
{
case 'on':
process.coreDumpLocation = process.platform == 'win32' ? (process.execPath.replace('.exe', '.dmp')) : (process.execPath + '.dmp');
process.coreDumpLocation = (process.platform == 'win32') ? (process.execPath.replace('.exe', '.dmp')) : (process.execPath + '.dmp');
response = 'coredump is now on';
break;
case 'off':
@ -2278,10 +2283,10 @@ function createMeshCore(agent) {
response = 'coredump is now off';
break;
case 'status':
response = 'coredump is: ' + (process.coreDumpLocation == null ? 'off' : 'on');
response = 'coredump is: ' + ((process.coreDumpLocation == null) ? 'off' : 'on');
break;
default:
response = "Proper usage: coredump on|off|status"; // Display usage
response = "Proper usage: coredump on|off|status"; // Display usage
break;
}
}
@ -2289,7 +2294,7 @@ function createMeshCore(agent) {
case 'service':
if (args['_'].length != 1)
{
response = "Proper usage: service status|restart"; // Display usage
response = "Proper usage: service status|restart"; // Display usage
}
else
{
@ -2310,7 +2315,7 @@ function createMeshCore(agent) {
}
break;
default:
response = "Proper usage: service status|restart"; // Display usage
response = "Proper usage: service status|restart"; // Display usage
break;
}
if (process.platform == 'win32') { s.close(); }
@ -2789,34 +2794,6 @@ function createMeshCore(agent) {
}
break;
}
case 'dump':
if (args['_'].length < 1) {
response = 'Proper usage: dump [on/off/status]'; // Display correct command usage
}
else {
switch (args['_'][0].toLowerCase()) {
case 'on':
process.coreDumpLocation = process.platform == 'win32' ? process.execPath.replace('.exe', '.dmp') : (process.execPath + '.dmp');
response = 'enabled';
break;
case 'off':
process.coreDumpLocation = null;
response = 'disabled';
break;
case 'status':
if (process.coreDumpLocation) {
response = 'Core Dump: [ENABLED' + (require('fs').existsSync(process.coreDumpLocation) ? (', (DMP file exists)]') : (']'));
}
else {
response = 'Core Dump: [DISABLED]';
}
break;
default:
response = 'Proper usage: dump [on/off/status]'; // Display correct command usage
break;
}
}
break;
case 'eval': { // Eval JavaScript
if (args['_'].length < 1) {
response = 'Proper usage: eval "JavaScript code"'; // Display correct command usage