diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index fc9d32c6..2f742130 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -251,6 +251,17 @@ "Files": { "type": "string" } } }, + "agentCustomization": { + "type": "object", + "additionalProperties": false, + "description": "Use this section to customize the agent branding.", + "properties": { + "displayName": { "type": "string", "default": "MeshCentral Agent", "description": "The name of the agent as displayed to the user." }, + "description": { "type": "string", "default": "Mesh Agent background service", "description": "The description of the agent as displayed to the user." }, + "companyName": { "type": "string", "default": "Mesh Agent", "description": "This will be used as the path to install the agent, by default this is 'Mesh Agent' in Windows and 'meshagent' in other OS's." }, + "serviceName": { "type": "string", "default": "Mesh Agent", "description": "The name of the background service, by default this is 'Mesh Agent' in Windows and 'meshagent' in other OS's but should be set to an all lower case, no space string." } + } + }, "userAllowedIP": { "type": "string" }, "userBlockedIP": { "type": "string" }, "agentAllowedIP": { "type": "string" }, diff --git a/meshcentral.js b/meshcentral.js index 7d427721..00a97367 100644 --- a/meshcentral.js +++ b/meshcentral.js @@ -1100,6 +1100,16 @@ function CreateMeshCentralServer(config, args) { if ((obj.config.domains[i].webpublicpath == null) && (obj.fs.existsSync(obj.path.join(__dirname, '../meshcentral-web-' + i + '/public')))) { obj.config.domains[i].webpublicpath = obj.path.join(__dirname, '../meshcentral-web-' + i + '/public'); } if ((obj.config.domains[i].webemailspath == null) && (obj.fs.existsSync(obj.path.join(__dirname, '../meshcentral-web-' + i + '/emails')))) { obj.config.domains[i].webemailspath = obj.path.join(__dirname, '../meshcentral-web-' + i + '/emails'); } } + + // Check agent customization if any + if (typeof obj.config.domains[i].agentcustomization == 'object') { + if (typeof obj.config.domains[i].agentcustomization.displayname != 'string') { delete obj.config.domains[i].agentcustomization.displayname; } else { obj.config.domains[i].agentcustomization.displayname = obj.config.domains[i].agentcustomization.displayname.split('\r').join('').split('\n').join(''); } + if (typeof obj.config.domains[i].agentcustomization.description != 'string') { delete obj.config.domains[i].agentcustomization.description; } else { obj.config.domains[i].agentcustomization.description = obj.config.domains[i].agentcustomization.description.split('\r').join('').split('\n').join(''); } + if (typeof obj.config.domains[i].agentcustomization.companyname != 'string') { delete obj.config.domains[i].agentcustomization.companyname; } else { obj.config.domains[i].agentcustomization.companyname = obj.config.domains[i].agentcustomization.companyname.split('\r').join('').split('\n').join(''); } + if (typeof obj.config.domains[i].agentcustomization.servicename != 'string') { delete obj.config.domains[i].agentcustomization.servicename; } else { obj.config.domains[i].agentcustomization.servicename = obj.config.domains[i].agentcustomization.servicename.split('\r').join('').split('\n').join('').split(' ').join('').split('"').join('').split('\'').join('').split('>').join('').split('<').join('').split('/').join('').split('\\').join(''); } + } else { + delete obj.config.domains[i].agentcustomization; + } } // Log passed arguments into Windows Service Log diff --git a/sample-config-advanced.json b/sample-config-advanced.json index e2ac8fc6..091b26b8 100644 --- a/sample-config-advanced.json +++ b/sample-config-advanced.json @@ -179,6 +179,12 @@ "terminal": "{0} started a remote terminal session.", "files": "{0} started a remote files session." }, + "agentCustomization": { + "displayName": "Compagny® Product™", + "description": "Compagny® Product™ agent for remote monitoring, management and assistance.", + "companyName": "Compagny®", + "serviceName": "compagnyagent" + }, "_userAllowedIP": "127.0.0.1,192.168.1.0/24", "_userBlockedIP": "127.0.0.1,::1,192.168.0.100", "_agentAllowedIP": "192.168.0.100/24", diff --git a/webserver.js b/webserver.js index a9d9633a..f69aa91a 100644 --- a/webserver.js +++ b/webserver.js @@ -4209,7 +4209,12 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { if ((domain.agentnoproxy === true) || (obj.args.lanonly == true)) { meshsettings += 'ignoreProxyFile=1\r\n'; } if (obj.args.agentconfig) { for (var i in obj.args.agentconfig) { meshsettings += obj.args.agentconfig[i] + '\r\n'; } } if (domain.agentconfig) { for (var i in domain.agentconfig) { meshsettings += domain.agentconfig[i] + '\r\n'; } } - + if (domain.agentcustomization != null) { // Add agent customization + if (domain.agentcustomization.displayname != null) { meshsettings += 'displayName=' + domain.agentcustomization.displayname + '\r\n'; } + if (domain.agentcustomization.description != null) { meshsettings += 'description=' + domain.agentcustomization.description + '\r\n'; } + if (domain.agentcustomization.companyname != null) { meshsettings += 'companyName=' + domain.agentcustomization.companyname + '\r\n'; } + if (domain.agentcustomization.servicename != null) { meshsettings += 'meshServiceName=' + domain.agentcustomization.servicename + '\r\n'; } + } setContentDispositionHeader(res, 'application/octet-stream', meshfilename, null, argentInfo.rname); obj.parent.exeHandler.streamExeWithMeshPolicy({ platform: 'win32', sourceFileName: obj.parent.meshAgentBinaries[req.query.id].path, destinationStream: res, msh: meshsettings, peinfo: obj.parent.meshAgentBinaries[req.query.id].pe }); } @@ -4510,6 +4515,12 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { if ((domain.agentnoproxy === true) || (obj.args.lanonly == true)) { meshsettings += 'ignoreProxyFile=1\r\n'; } if (obj.args.agentconfig) { for (var i in obj.args.agentconfig) { meshsettings += obj.args.agentconfig[i] + '\r\n'; } } if (domain.agentconfig) { for (var i in domain.agentconfig) { meshsettings += domain.agentconfig[i] + '\r\n'; } } + if (domain.agentcustomization != null) { // Add agent customization + if (domain.agentcustomization.displayname != null) { meshsettings += 'displayName=' + domain.agentcustomization.displayname + '\r\n'; } + if (domain.agentcustomization.description != null) { meshsettings += 'description=' + domain.agentcustomization.description + '\r\n'; } + if (domain.agentcustomization.companyname != null) { meshsettings += 'companyName=' + domain.agentcustomization.companyname + '\r\n'; } + if (domain.agentcustomization.servicename != null) { meshsettings += 'meshServiceName=' + domain.agentcustomization.servicename + '\r\n'; } + } // Setup the response output var archive = require('archiver')('zip', { level: 5 }); // Sets the compression method. @@ -4602,6 +4613,12 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { if ((domain.agentnoproxy === true) || (obj.args.lanonly == true)) { meshsettings += 'ignoreProxyFile=1\r\n'; } if (obj.args.agentconfig) { for (var i in obj.args.agentconfig) { meshsettings += obj.args.agentconfig[i] + '\r\n'; } } if (domain.agentconfig) { for (var i in domain.agentconfig) { meshsettings += domain.agentconfig[i] + '\r\n'; } } + if (domain.agentcustomization != null) { // Add agent customization + if (domain.agentcustomization.displayname != null) { meshsettings += 'displayName=' + domain.agentcustomization.displayname + '\r\n'; } + if (domain.agentcustomization.description != null) { meshsettings += 'description=' + domain.agentcustomization.description + '\r\n'; } + if (domain.agentcustomization.companyname != null) { meshsettings += 'companyName=' + domain.agentcustomization.companyname + '\r\n'; } + if (domain.agentcustomization.servicename != null) { meshsettings += 'meshServiceName=' + domain.agentcustomization.servicename + '\r\n'; } + } return meshsettings; }