diff --git a/MeshCentralServer.njsproj b/MeshCentralServer.njsproj index e72e3d05..d2d0cf3f 100644 --- a/MeshCentralServer.njsproj +++ b/MeshCentralServer.njsproj @@ -274,19 +274,14 @@ - - - - - diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index e2a53826..fab6f6fb 100644 Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index 9f2e6505..3c0f7ddb 100644 Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 3dfb676d..a7a848d1 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -2564,46 +2564,53 @@ function removeItemFromArray(array, element) { } // Run MeshCmd, but before we do, we need to see if what type of service we are going to be -var serviceName = null; -var serviceOpSpecified = 0; -var serviceInstall = 0; - +var serviceName = null, serviceDisplayName = null, serviceDesc = null; for (var i in process.argv) { - if (process.argv[i].toLowerCase() == 'install') { serviceInstall = 1 } else if (process.argv[i].toLowerCase() == 'uninstall') { serviceInstall = -1 } - if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; break; } - if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; break; } + if (process.argv[i].toLowerCase() == 'install') { process.argv[i] = '-install'; } + if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; } + if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { + serviceName = 'MicroLMS'; + serviceDisplayName = 'MicroLMS Service for Intel(R) AMT'; + serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)'; + } else if ((process.argv[i].toLowerCase() == 'intellms')) { + serviceName = 'LMS'; + serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service'; + serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.'; + } else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { + serviceName = 'MeshCommander'; + serviceDisplayName = 'MeshCommander, Intel AMT Management console'; + serviceDesc = 'MeshCommander is a Intel AMT management console.'; + } } if (serviceName == null) { - for (var i in process.argv) { - if ((process.argv[i].toLowerCase() == 'install') || (process.argv[i].toLowerCase() == 'uninstall')) { - console.log('In order to install/uninstall, a service type must be specified.'); - process.exit(); - } - } if (process.execPath.includes('MicroLMS')) { serviceName = 'MicroLMS'; } + else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; } else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; } - else { serviceName = 'not_a_service'; } + if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } } + if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); } } -if (serviceInstall == 0) { - run(process.argv); -} else { - var serviceHost = require('service-host'); - var meshcmdService = new serviceHost({ name: serviceName, startType: 'AUTO_START' }); +var serviceHost = require('service-host'); +var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc }); - // Called when the background service is started. - meshcmdService.on('serviceStart', function onStart() { - console.setDestination(console.Destinations.DISABLED); // Disable console.log(). - if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // - else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } - else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); } - }); +// Called when the background service is started. +meshcmdService.on('serviceStart', function onStart() { + //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp'; + //process.on('exit', function () { console.log('exit3'); _debugCrash(); }); + console.setDestination(console.Destinations.DISABLED); // Disable console.log(). + //console.setDestination(console.Destinations.LOGFILE); + //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log); - // Called when the background service is stopping - meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. + if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander + else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); } +}); - // Called when the executable is not running as a service, run normally. - meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } }); - meshcmdService.run(); -} +// Called when the background service is stopping +meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. + +// Called when the executable is not running as a service, run normally. +meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } }); +meshcmdService.run(); diff --git a/agents/meshcmd.min.js b/agents/meshcmd.min.js index 3dfb676d..a7a848d1 100644 --- a/agents/meshcmd.min.js +++ b/agents/meshcmd.min.js @@ -2564,46 +2564,53 @@ function removeItemFromArray(array, element) { } // Run MeshCmd, but before we do, we need to see if what type of service we are going to be -var serviceName = null; -var serviceOpSpecified = 0; -var serviceInstall = 0; - +var serviceName = null, serviceDisplayName = null, serviceDesc = null; for (var i in process.argv) { - if (process.argv[i].toLowerCase() == 'install') { serviceInstall = 1 } else if (process.argv[i].toLowerCase() == 'uninstall') { serviceInstall = -1 } - if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { serviceName = 'MicroLMS'; break; } - if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { serviceName = 'MeshCommander'; break; } + if (process.argv[i].toLowerCase() == 'install') { process.argv[i] = '-install'; } + if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; } + if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) { + serviceName = 'MicroLMS'; + serviceDisplayName = 'MicroLMS Service for Intel(R) AMT'; + serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)'; + } else if ((process.argv[i].toLowerCase() == 'intellms')) { + serviceName = 'LMS'; + serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service'; + serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.'; + } else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) { + serviceName = 'MeshCommander'; + serviceDisplayName = 'MeshCommander, Intel AMT Management console'; + serviceDesc = 'MeshCommander is a Intel AMT management console.'; + } } if (serviceName == null) { - for (var i in process.argv) { - if ((process.argv[i].toLowerCase() == 'install') || (process.argv[i].toLowerCase() == 'uninstall')) { - console.log('In order to install/uninstall, a service type must be specified.'); - process.exit(); - } - } if (process.execPath.includes('MicroLMS')) { serviceName = 'MicroLMS'; } + else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; } else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; } - else { serviceName = 'not_a_service'; } + if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } } + if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); } } -if (serviceInstall == 0) { - run(process.argv); -} else { - var serviceHost = require('service-host'); - var meshcmdService = new serviceHost({ name: serviceName, startType: 'AUTO_START' }); +var serviceHost = require('service-host'); +var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc }); - // Called when the background service is started. - meshcmdService.on('serviceStart', function onStart() { - console.setDestination(console.Destinations.DISABLED); // Disable console.log(). - if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // - else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } - else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); } - }); +// Called when the background service is started. +meshcmdService.on('serviceStart', function onStart() { + //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp'; + //process.on('exit', function () { console.log('exit3'); _debugCrash(); }); + console.setDestination(console.Destinations.DISABLED); // Disable console.log(). + //console.setDestination(console.Destinations.LOGFILE); + //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log); - // Called when the background service is stopping - meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. + if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS + else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander + else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); } +}); - // Called when the executable is not running as a service, run normally. - meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } }); - meshcmdService.run(); -} +// Called when the background service is stopping +meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set. + +// Called when the executable is not running as a service, run normally. +meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } }); +meshcmdService.run(); diff --git a/agents/modules_meshcmd/service-host.js b/agents/modules_meshcmd/service-host.js deleted file mode 100644 index fabc4e81..00000000 --- a/agents/modules_meshcmd/service-host.js +++ /dev/null @@ -1,389 +0,0 @@ -/* -Copyright 2018 Intel Corporation - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -var SERVICE_WIN32 = 0x00000010 | 0x00000020; -var SERVICE_STATE = { STOPPED: 0x00000001, SERVICE_START_PENDING: 0x00000002, SERVICE_STOP_PENDING: 0x00000003, RUNNING: 0x00000004 }; -var SERVICE_ACCEPT = { SERVICE_ACCEPT_STOP: 0x00000001, SERVICE_ACCEPT_SHUTDOWN: 0x00000004, SERVICE_ACCEPT_POWEREVENT: 0x00000040, SERVICE_ACCEPT_SESSIONCHANGE: 0x00000080 }; - -var SERVICE_CONTROL = { SERVICE_CONTROL_SHUTDOWN: 0x00000005, SERVICE_CONTROL_STOP: 0x00000001, SERVICE_CONTROL_POWEREVENT: 0x0000000D, SERVICE_CONTROL_SESSIONCHANGE: 0x0000000E}; -var SESSION_CHANGE_TYPE = -{ - WTS_CONSOLE_CONNECT: 0x1, - WTS_CONSOLE_DISCONNECT: 0x2, - WTS_REMOTE_CONNECT: 0x3, - WTS_REMOTE_DISCONNECT: 0x4, - WTS_SESSION_LOGON: 0x5, - WTS_SESSION_LOGOFF: 0x6, - WTS_SESSION_LOCK: 0x7, - WTS_SESSION_UNLOCK: 0x8, - WTS_SESSION_REMOTE_CONTROL: 0x9, - WTS_SESSION_CREATE: 0xa, - WTS_SESSION_TERMINATE: 0xb -}; - - -var NO_ERROR = 0; - -var serviceManager = require('service-manager'); - -function serviceHost(serviceName) -{ - this._ObjectID = 'service-host'; - var emitterUtils = require('events').inherits(this); - emitterUtils.createEvent('serviceStart'); - emitterUtils.createEvent('serviceStop'); - emitterUtils.createEvent('normalStart'); - emitterUtils.createEvent('session'); - emitterUtils.createEvent('powerStateChange'); - - if (process.platform == 'win32') - { - this.GM = require('_GenericMarshal'); - this.Advapi = this.GM.CreateNativeProxy('Advapi32.dll'); - this.Advapi.CreateMethod({ method: 'StartServiceCtrlDispatcherA', threadDispatch: 1 }); - this.Advapi.CreateMethod('RegisterServiceCtrlHandlerExA'); - this.Advapi.CreateMethod('SetServiceStatus'); - this.Kernel32 = this.GM.CreateNativeProxy('Kernel32.dll'); - this.Kernel32.CreateMethod('GetLastError'); - - this.Ole32 = this.GM.CreateNativeProxy('Ole32.dll'); - this.Ole32.CreateMethod('CoInitializeEx'); - this.Ole32.CreateMethod('CoUninitialize'); - - this._ServiceName = this.GM.CreateVariable(typeof (serviceName) == 'string' ? serviceName : serviceName.name); - this._ServiceMain = this.GM.GetGenericGlobalCallback(2); - this._ServiceMain.Parent = this; - this._ServiceMain.GM = this.GM; - this._ServiceMain.on('GlobalCallback', function onGlobalCallback(argc, argv) - { - //ToDo: Check to make sure this is for us - - this.Parent._ServiceStatus = this.GM.CreateVariable(28); - //typedef struct _SERVICE_STATUS { - // DWORD dwServiceType; - // DWORD dwCurrentState; - // DWORD dwControlsAccepted; - // DWORD dwWin32ExitCode; - // DWORD dwServiceSpecificExitCode; - // DWORD dwCheckPoint; - // DWORD dwWaitHint; - //} SERVICE_STATUS, *LPSERVICE_STATUS; - - // Initialise service status - this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_WIN32); - this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.SERVICE_STOPPED, 4); - this.Parent._ServiceStatusHandle = this.Parent.Advapi.RegisterServiceCtrlHandlerExA(this.Parent._ServiceName, this.Parent._ServiceControlHandler, this.Parent.GM.StashObject(this.Parent._ServiceControlHandler)); - if(this.Parent._ServiceStatusHandle.Val == 0) - { - process.exit(1); - } - - // Service is starting - this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.SERVICE_START_PENDING, 4); - this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle, this.Parent._ServiceStatus); - - // Service running - this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.RUNNING, 4); - this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_ACCEPT.SERVICE_ACCEPT_STOP | SERVICE_ACCEPT.SERVICE_ACCEPT_POWEREVENT | SERVICE_ACCEPT.SERVICE_ACCEPT_SESSIONCHANGE, 8); - this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle, this.Parent._ServiceStatus); - - this.Parent.Ole32.CoInitializeEx(0, 2); - this.Parent.on('~', function OnServiceHostFinalizer() - { - var GM = require('_GenericMarshal'); - var Advapi = GM.CreateNativeProxy('Advapi32.dll'); - Advapi.CreateMethod('SetServiceStatus'); - - Kernel32 = this.GM.CreateNativeProxy('Kernel32.dll'); - Kernel32.CreateMethod('GetLastError'); - - var status = GM.CreateVariable(28); - - // Service was stopped - status.toBuffer().writeUInt32LE(SERVICE_WIN32); - status.toBuffer().writeUInt32LE(0x00000001, 4); - status.toBuffer().writeUInt32LE(0, 8); - - Advapi.SetServiceStatus(this._ServiceStatusHandle, status); - - this.Ole32.CoUninitialize(); - }); - - this.Parent.emit('serviceStart'); - }); - this._ServiceControlHandler = this.GM.GetGenericGlobalCallback(4); - this._ServiceControlHandler.Parent = this; - this._ServiceControlHandler.GM = this.GM; - this._ServiceControlHandler.on('GlobalCallback', function onServiceControlHandler(code, eventType, eventData, context) - { - var j = this.Parent.GM.UnstashObject(context); - if (j != null && j == this) - { - switch (code.Val) - { - case SERVICE_CONTROL.SERVICE_CONTROL_SHUTDOWN: - case SERVICE_CONTROL.SERVICE_CONTROL_STOP: - this.Parent.emit('serviceStop'); - return; - case SERVICE_CONTROL.SERVICE_CONTROL_SESSIONCHANGE: - var sessionId = eventData.Deref(4, 4).toBuffer().readUInt32LE(); - switch(eventType.Val) - { - case SESSION_CHANGE_TYPE.WTS_SESSION_LOGON: - case SESSION_CHANGE_TYPE.WTS_SESSION_LOGOFF: - require('user-sessions').emit('changed'); - break; - } - break; - default: - break; - } - - this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle, this.Parent._ServiceStatus); - } - }); - } - - if (serviceName) { this._ServiceOptions = typeof (serviceName) == 'object' ? serviceName : { name: serviceName }; } - else - { - throw ('Must specify either ServiceName or Options'); - } - if (!this._ServiceOptions.servicePath) - { - this._ServiceOptions.servicePath = process.execPath; - } - - this.run = function run() - { - var serviceOperation = 0; - - for(var i = 0; iStandardOutPath\n' + options.stdout + '') : ''); - var autoStart = (options.startType == 'AUTO_START' ? '' : ''); - var params = ' ProgramArguments\n'; - params += ' \n'; - params += (' /usr/local/mesh_services/' + options.name + '/' + options.name + '\n'); - if(options.parameters) - { - for(var itm in options.parameters) - { - params += (' ' + options.parameters[itm] + '\n'); - } - } - params += ' \n'; - - var plist = '\n'; - plist += '\n'; - plist += '\n'; - plist += ' \n'; - plist += ' Label\n'; - plist += (' ' + options.name + '\n'); - plist += (params + '\n'); - plist += ' WorkingDirectory\n'; - plist += (' /usr/local/mesh_services/' + options.name + '\n'); - plist += (stdoutpath + '\n'); - plist += ' RunAtLoad\n'; - plist += (autoStart + '\n'); - plist += ' \n'; - plist += ''; - - if (!require('fs').existsSync('/usr/local/mesh_services')) { require('fs').mkdirSync('/usr/local/mesh_services'); } - if (!require('fs').existsSync('/Library/LaunchDaemons/' + options.name + '.plist')) - { - if (!require('fs').existsSync('/usr/local/mesh_services/' + options.name)) { require('fs').mkdirSync('/usr/local/mesh_services/' + options.name); } - if (options.binary) - { - require('fs').writeFileSync('/usr/local/mesh_services/' + options.name + '/' + options.name, options.binary); - } - else - { - require('fs').copyFileSync(options.servicePath, '/usr/local/mesh_services/' + options.name + '/' + options.name); - } - require('fs').writeFileSync('/Library/LaunchDaemons/' + options.name + '.plist', plist); - var m = require('fs').statSync('/usr/local/mesh_services/' + options.name + '/' + options.name).mode; - m |= (require('fs').CHMOD_MODES.S_IXUSR | require('fs').CHMOD_MODES.S_IXGRP); - require('fs').chmodSync('/usr/local/mesh_services/' + options.name + '/' + options.name, m); - } - else - { - throw ('Service: ' + options.name + ' already exists'); - } - } - } - this.uninstallService = function uninstallService(name) - { - if (!this.isAdmin()) { throw ('Uninstalling a service, requires admin'); } - - if (typeof (name) == 'object') { name = name.name; } - if (process.platform == 'win32') - { - var service = this.getService(name); - if (service.status.state == undefined || service.status.state == 'STOPPED') - { - if (this.proxy.DeleteService(service._service) == 0) - { - throw ('Uninstall Service for: ' + name + ', failed with error: ' + this.proxy2.GetLastError()); - } - else - { - try - { - require('fs').unlinkSync(this.getServiceFolder() + '\\' + name + '.exe'); - } - catch(e) - { - } - } - } - else - { - throw ('Cannot uninstall service: ' + name + ', because it is: ' + service.status.state); - } - } - else if(process.platform == 'linux') - { - switch (this.getServiceType()) - { - case 'init': - this._update = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM }); - this._update.stdout.on('data', function (chunk) { }); - this._update.stdin.write('service ' + name + ' stop\n'); - this._update.stdin.write('update-rc.d -f ' + name + ' remove\n'); - this._update.stdin.write('exit\n'); - this._update.waitExit(); - try - { - require('fs').unlinkSync('/etc/init.d/' + name); - console.log(name + ' uninstalled'); - - } - catch (e) - { - console.log(name + ' could not be uninstalled', e) - } - break; - case 'systemd': - this._update = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM }); - this._update.stdout.on('data', function (chunk) { }); - this._update.stdin.write('systemctl stop ' + name + '.service\n'); - this._update.stdin.write('systemctl disable ' + name + '.service\n'); - this._update.stdin.write('exit\n'); - this._update.waitExit(); - try - { - require('fs').unlinkSync('/usr/local/mesh/' + name); - require('fs').unlinkSync('/lib/systemd/system/' + name + '.service'); - console.log(name + ' uninstalled'); - } - catch (e) - { - console.log(name + ' could not be uninstalled', e) - } - break; - default: // unknown platform service type - break; - } - } - else if(process.platform == 'darwin') - { - if (require('fs').existsSync('/Library/LaunchDaemons/' + name + '.plist')) - { - var child = require('child_process').execFile('/bin/sh', ['sh']); - child.stdout.on('data', function (chunk) { }); - child.stdin.write('launchctl stop ' + name + '\n'); - child.stdin.write('launchctl unload /Library/LaunchDaemons/' + name + '.plist\n'); - child.stdin.write('exit\n'); - child.waitExit(); - - try - { - require('fs').unlinkSync('/usr/local/mesh_services/' + name + '/' + name); - require('fs').unlinkSync('/Library/LaunchDaemons/' + name + '.plist'); - } - catch(e) - { - throw ('Error uninstalling service: ' + name + ' => ' + e); - } - - try - { - require('fs').rmdirSync('/usr/local/mesh_services/' + name); - } - catch(e) - {} - } - else - { - throw ('Service: ' + name + ' does not exist'); - } - } - } - if(process.platform == 'linux') - { - this.getServiceType = function getServiceType() - { - return (require('process-manager').getProcessInfo(1).Name); - }; - } -} - -module.exports = serviceManager; \ No newline at end of file diff --git a/agents/modules_meshcmd_min/service-host.min.js b/agents/modules_meshcmd_min/service-host.min.js deleted file mode 100644 index b3a0287a..00000000 --- a/agents/modules_meshcmd_min/service-host.min.js +++ /dev/null @@ -1 +0,0 @@ -var SERVICE_WIN32=16|32;var SERVICE_STATE={STOPPED:1,SERVICE_START_PENDING:2,SERVICE_STOP_PENDING:3,RUNNING:4};var SERVICE_ACCEPT={SERVICE_ACCEPT_STOP:1,SERVICE_ACCEPT_SHUTDOWN:4,SERVICE_ACCEPT_POWEREVENT:64,SERVICE_ACCEPT_SESSIONCHANGE:128};var SERVICE_CONTROL={SERVICE_CONTROL_SHUTDOWN:5,SERVICE_CONTROL_STOP:1,SERVICE_CONTROL_POWEREVENT:13,SERVICE_CONTROL_SESSIONCHANGE:14};var SESSION_CHANGE_TYPE={WTS_CONSOLE_CONNECT:1,WTS_CONSOLE_DISCONNECT:2,WTS_REMOTE_CONNECT:3,WTS_REMOTE_DISCONNECT:4,WTS_SESSION_LOGON:5,WTS_SESSION_LOGOFF:6,WTS_SESSION_LOCK:7,WTS_SESSION_UNLOCK:8,WTS_SESSION_REMOTE_CONTROL:9,WTS_SESSION_CREATE:10,WTS_SESSION_TERMINATE:11};var NO_ERROR=0;var serviceManager=require("service-manager");function serviceHost(e){this._ObjectID="service-host";var a=require("events").inherits(this);a.createEvent("serviceStart");a.createEvent("serviceStop");a.createEvent("normalStart");a.createEvent("session");a.createEvent("powerStateChange");if(process.platform=="win32"){this.GM=require("_GenericMarshal");this.Advapi=this.GM.CreateNativeProxy("Advapi32.dll");this.Advapi.CreateMethod({method:"StartServiceCtrlDispatcherA",threadDispatch:1});this.Advapi.CreateMethod("RegisterServiceCtrlHandlerExA");this.Advapi.CreateMethod("SetServiceStatus");this.Kernel32=this.GM.CreateNativeProxy("Kernel32.dll");this.Kernel32.CreateMethod("GetLastError");this.Ole32=this.GM.CreateNativeProxy("Ole32.dll");this.Ole32.CreateMethod("CoInitializeEx");this.Ole32.CreateMethod("CoUninitialize");this._ServiceName=this.GM.CreateVariable(typeof(e)=="string"?e:e.name);this._ServiceMain=this.GM.GetGenericGlobalCallback(2);this._ServiceMain.Parent=this;this._ServiceMain.GM=this.GM;this._ServiceMain.on("GlobalCallback",function b(f,g){this.Parent._ServiceStatus=this.GM.CreateVariable(28);this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_WIN32);this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.SERVICE_STOPPED,4);this.Parent._ServiceStatusHandle=this.Parent.Advapi.RegisterServiceCtrlHandlerExA(this.Parent._ServiceName,this.Parent._ServiceControlHandler,this.Parent.GM.StashObject(this.Parent._ServiceControlHandler));if(this.Parent._ServiceStatusHandle.Val==0){process.exit(1)}this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.SERVICE_START_PENDING,4);this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle,this.Parent._ServiceStatus);this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_STATE.RUNNING,4);this.Parent._ServiceStatus.toBuffer().writeUInt32LE(SERVICE_ACCEPT.SERVICE_ACCEPT_STOP|SERVICE_ACCEPT.SERVICE_ACCEPT_POWEREVENT|SERVICE_ACCEPT.SERVICE_ACCEPT_SESSIONCHANGE,8);this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle,this.Parent._ServiceStatus);this.Parent.Ole32.CoInitializeEx(0,2);this.Parent.on("~",function h(){var j=require("_GenericMarshal");var i=j.CreateNativeProxy("Advapi32.dll");i.CreateMethod("SetServiceStatus");Kernel32=this.GM.CreateNativeProxy("Kernel32.dll");Kernel32.CreateMethod("GetLastError");var k=j.CreateVariable(28);k.toBuffer().writeUInt32LE(SERVICE_WIN32);k.toBuffer().writeUInt32LE(1,4);k.toBuffer().writeUInt32LE(0,8);i.SetServiceStatus(this._ServiceStatusHandle,k);this.Ole32.CoUninitialize()});this.Parent.emit("serviceStart")});this._ServiceControlHandler=this.GM.GetGenericGlobalCallback(4);this._ServiceControlHandler.Parent=this;this._ServiceControlHandler.GM=this.GM;this._ServiceControlHandler.on("GlobalCallback",function c(f,i,h,g){var k=this.Parent.GM.UnstashObject(g);if(k!=null&&k==this){switch(f.Val){case SERVICE_CONTROL.SERVICE_CONTROL_SHUTDOWN:case SERVICE_CONTROL.SERVICE_CONTROL_STOP:this.Parent.emit("serviceStop");return;case SERVICE_CONTROL.SERVICE_CONTROL_SESSIONCHANGE:var l=h.Deref(4,4).toBuffer().readUInt32LE();switch(i.Val){case SESSION_CHANGE_TYPE.WTS_SESSION_LOGON:case SESSION_CHANGE_TYPE.WTS_SESSION_LOGOFF:require("user-sessions").emit("changed");break}break;default:break}this.Parent.Advapi.SetServiceStatus(this.Parent._ServiceStatusHandle,this.Parent._ServiceStatus)}})}if(e){this._ServiceOptions=typeof(e)=="object"?e:{name:e}}else{throw ("Must specify either ServiceName or Options")}if(!this._ServiceOptions.servicePath){this._ServiceOptions.servicePath=process.execPath}this.run=function d(){var r=0;for(var h=0;hStandardOutPath\n"+r.stdout+""):"");var i=(r.startType=="AUTO_START"?"":"");var s=" ProgramArguments\n";s+=" \n";s+=(" /usr/local/mesh_services/"+r.name+"/"+r.name+"\n");if(r.parameters){for(var p in r.parameters){s+=(" "+r.parameters[p]+"\n")}}s+=" \n";var t='\n';t+='\n';t+='\n';t+=" \n";t+=" Label\n";t+=(" "+r.name+"\n");t+=(s+"\n");t+=" WorkingDirectory\n";t+=(" /usr/local/mesh_services/"+r.name+"\n");t+=(y+"\n");t+=" RunAtLoad\n";t+=(i+"\n");t+=" \n";t+="";if(!require("fs").existsSync("/usr/local/mesh_services")){require("fs").mkdirSync("/usr/local/mesh_services")}if(!require("fs").existsSync("/Library/LaunchDaemons/"+r.name+".plist")){if(!require("fs").existsSync("/usr/local/mesh_services/"+r.name)){require("fs").mkdirSync("/usr/local/mesh_services/"+r.name)}if(r.binary){require("fs").writeFileSync("/usr/local/mesh_services/"+r.name+"/"+r.name,r.binary)}else{require("fs").copyFileSync(r.servicePath,"/usr/local/mesh_services/"+r.name+"/"+r.name)}require("fs").writeFileSync("/Library/LaunchDaemons/"+r.name+".plist",t);var q=require("fs").statSync("/usr/local/mesh_services/"+r.name+"/"+r.name).mode;q|=(require("fs").CHMOD_MODES.S_IXUSR|require("fs").CHMOD_MODES.S_IXGRP);require("fs").chmodSync("/usr/local/mesh_services/"+r.name+"/"+r.name,q)}else{throw ("Service: "+r.name+" already exists")}}};this.uninstallService=function f(i){if(!this.isAdmin()){throw ("Uninstalling a service, requires admin")}if(typeof(i)=="object"){i=i.name}if(process.platform=="win32"){var j=this.getService(i);if(j.status.state==undefined||j.status.state=="STOPPED"){if(this.proxy.DeleteService(j._service)==0){throw ("Uninstall Service for: "+i+", failed with error: "+this.proxy2.GetLastError())}else{try{require("fs").unlinkSync(this.getServiceFolder()+"\\"+i+".exe")}catch(h){}}}else{throw ("Cannot uninstall service: "+i+", because it is: "+j.status.state)}}else{if(process.platform=="linux"){switch(this.getServiceType()){case"init":this._update=require("child_process").execFile("/bin/sh",["sh"],{type:require("child_process").SpawnTypes.TERM});this._update.stdout.on("data",function(k){});this._update.stdin.write("service "+i+" stop\n");this._update.stdin.write("update-rc.d -f "+i+" remove\n");this._update.stdin.write("exit\n");this._update.waitExit();try{require("fs").unlinkSync("/etc/init.d/"+i);console.log(i+" uninstalled")}catch(h){console.log(i+" could not be uninstalled",h)}break;case"systemd":this._update=require("child_process").execFile("/bin/sh",["sh"],{type:require("child_process").SpawnTypes.TERM});this._update.stdout.on("data",function(k){});this._update.stdin.write("systemctl stop "+i+".service\n");this._update.stdin.write("systemctl disable "+i+".service\n");this._update.stdin.write("exit\n");this._update.waitExit();try{require("fs").unlinkSync("/usr/local/mesh/"+i);require("fs").unlinkSync("/lib/systemd/system/"+i+".service");console.log(i+" uninstalled")}catch(h){console.log(i+" could not be uninstalled",h)}break;default:break}}else{if(process.platform=="darwin"){if(require("fs").existsSync("/Library/LaunchDaemons/"+i+".plist")){var g=require("child_process").execFile("/bin/sh",["sh"]);g.stdout.on("data",function(k){});g.stdin.write("launchctl stop "+i+"\n");g.stdin.write("launchctl unload /Library/LaunchDaemons/"+i+".plist\n");g.stdin.write("exit\n");g.waitExit();try{require("fs").unlinkSync("/usr/local/mesh_services/"+i+"/"+i);require("fs").unlinkSync("/Library/LaunchDaemons/"+i+".plist")}catch(h){throw ("Error uninstalling service: "+i+" => "+h)}try{require("fs").rmdirSync("/usr/local/mesh_services/"+i)}catch(h){}}else{throw ("Service: "+i+" does not exist")}}}}};if(process.platform=="linux"){this.getServiceType=function c(){return(require("process-manager").getProcessInfo(1).Name)}}}module.exports=serviceManager; \ No newline at end of file diff --git a/package.json b/package.json index ec75e3d0..9a90e6ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.3-a", + "version": "0.4.3-c", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/minify.bat b/public/minify.bat new file mode 100644 index 00000000..567c4800 --- /dev/null +++ b/public/minify.bat @@ -0,0 +1,3 @@ +@ECHO OFF +CD ..\translate +C:\Users\Default.DESKTOP-M9I88C9\AppData\Roaming\nvm\v12.13.0\node translate.js minifyall \ No newline at end of file diff --git a/public/player-min.htm b/public/player-min.htm index 942a7b6e..0f7af242 100644 --- a/public/player-min.htm +++ b/public/player-min.htm @@ -1 +1 @@ -
00:00:00
 
\ No newline at end of file +
00:00:00
 
\ No newline at end of file diff --git a/public/translations/player-min_fr.htm b/public/translations/player-min_fr.htm index 92c93734..08a0cf73 100644 --- a/public/translations/player-min_fr.htm +++ b/public/translations/player-min_fr.htm @@ -1 +1 @@ -
00:00:00
 
\ No newline at end of file +
00:00:00
 
\ No newline at end of file diff --git a/translate/translate.js b/translate/translate.js index 69bc5252..c5e51769 100644 --- a/translate/translate.js +++ b/translate/translate.js @@ -141,7 +141,7 @@ function start() { if (minifyLib = 2) { var minifiedOut = minify(fs.readFileSync(outname).toString(), { collapseBooleanAttributes: true, - collapseInlineTagWhitespace: true, + collapseInlineTagWhitespace: false, // This is not good. collapseWhitespace: true, minifyCSS: true, minifyJS: true, @@ -333,7 +333,7 @@ function translateFromHtml(lang, file, createSubDir) { if (minifyLib = 2) { var minifiedOut = minify(out, { collapseBooleanAttributes: true, - collapseInlineTagWhitespace: true, + collapseInlineTagWhitespace: false, // This is not good. collapseWhitespace: true, minifyCSS: true, minifyJS: true, diff --git a/views/agentinvite-min.handlebars b/views/agentinvite-min.handlebars index 621bfcd4..feb7ddeb 100644 --- a/views/agentinvite-min.handlebars +++ b/views/agentinvite-min.handlebars @@ -1 +1 @@ -MeshCentral - Agent Installation
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

Remote Agent Installation

You have been invited to install a software that will allow a remote operator to fully access your computer remotely including the desktop and files. Only follow the instructions below if this invitation was expected and you know who will be accessing your computer. Selecting your operation system and follow the instructions below.

Microsoft™ Windows 64bit

Download the software here, run it and press "Install" or "Connect".

Microsoft™ Windows 32bit

Download the software here, run it and press "Install" or "Connect".

Linux

To install, cut and paste the following command in a root terminal.

To uninstall, cut and paste the following command as root.



Apple™ MacOS

Download the installer here, right click on it or press "control" and click on the file. Then select "Open" and follow the instructions.

\ No newline at end of file +MeshCentral - Agent Installation
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

Remote Agent Installation

You have been invited to install a software that will allow a remote operator to fully access your computer remotely including the desktop and files. Only follow the instructions below if this invitation was expected and you know who will be accessing your computer. Selecting your operation system and follow the instructions below.

Microsoft™ Windows 64bit

Download the software here, run it and press "Install" or "Connect".

Microsoft™ Windows 32bit

Download the software here, run it and press "Install" or "Connect".

Linux

To install, cut and paste the following command in a root terminal.

To uninstall, cut and paste the following command as root.



Apple™ MacOS

Download the installer here, right click on it or press "control" and click on the file. Then select "Open" and follow the instructions.

\ No newline at end of file diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 59173b48..8e683d73 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1,4 +1,4 @@ -{{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

{{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file +{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/login-min.handlebars b/views/login-min.handlebars index 08876e88..e10557a7 100644 --- a/views/login-min.handlebars +++ b/views/login-min.handlebars @@ -1 +1 @@ -{{{title}}} - Login
{{{title}}}
{{{title2}}}

Welcome


\ No newline at end of file +{{{title}}} - Login
{{{title}}}
{{{title2}}}

Welcome


\ No newline at end of file diff --git a/views/login-mobile-min.handlebars b/views/login-mobile-min.handlebars index ddbe028e..352aaa7b 100644 --- a/views/login-mobile-min.handlebars +++ b/views/login-mobile-min.handlebars @@ -1 +1 @@ -MeshCentral - Login
{{{title}}}
{{{title2}}}
\ No newline at end of file +MeshCentral - Login
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/login-mobile.handlebars b/views/login-mobile.handlebars index 2ce21002..40352073 100644 --- a/views/login-mobile.handlebars +++ b/views/login-mobile.handlebars @@ -267,6 +267,8 @@ MeshCentral - Agent Installation
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

Remote Agent Installation

You have been invited to install a software that will allow a remote operator to fully access your computer remotely including the desktop and files. Only follow the instructions below if this invitation was expected and you know who will be accessing your computer. Selecting your operation system and follow the instructions below.

Microsoft™ Windows 64bit

Download the software here, run it and press "Install" or "Connect".

Microsoft™ Windows 32bit

Download the software here, run it and press "Install" or "Connect".

Linux

To install, cut and paste the following command in a root terminal.

To uninstall, cut and paste the following command as root.



Apple™ MacOS

Download the installer here, right click on it or press "control" and click on the file. Then select "Open" and follow the instructions.

\ No newline at end of file +MeshCentral - Agent Installation
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

Remote Agent Installation

You have been invited to install a software that will allow a remote operator to fully access your computer remotely including the desktop and files. Only follow the instructions below if this invitation was expected and you know who will be accessing your computer. Selecting your operation system and follow the instructions below.

Microsoft™ Windows 64bit

Download the software here, run it and press "Install" or "Connect".

Microsoft™ Windows 32bit

Download the software here, run it and press "Install" or "Connect".

Linux

To install, cut and paste the following command in a root terminal.

To uninstall, cut and paste the following command as root.



Apple™ MacOS

Download the installer here, right click on it or press "control" and click on the file. Then select "Open" and follow the instructions.

\ No newline at end of file diff --git a/views/translations/default-min_fr.handlebars b/views/translations/default-min_fr.handlebars index d828a15e..0c1c28c3 100644 --- a/views/translations/default-min_fr.handlebars +++ b/views/translations/default-min_fr.handlebars @@ -1,4 +1,4 @@ -{{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

{{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file +{{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/translations/login-min_fr.handlebars b/views/translations/login-min_fr.handlebars index 54ec8fe4..2bd7a83f 100644 --- a/views/translations/login-min_fr.handlebars +++ b/views/translations/login-min_fr.handlebars @@ -1 +1 @@ -{{{title}}} - Login
{{{title}}}
{{{title2}}}

Bienvenue


\ No newline at end of file +{{{title}}} - Login
{{{title}}}
{{{title2}}}

Bienvenue


\ No newline at end of file diff --git a/views/translations/login-mobile-min_fr.handlebars b/views/translations/login-mobile-min_fr.handlebars index 68a5c00d..89528bde 100644 --- a/views/translations/login-mobile-min_fr.handlebars +++ b/views/translations/login-mobile-min_fr.handlebars @@ -1 +1 @@ -MeshCentral - Login
{{{title}}}
{{{title2}}}
\ No newline at end of file +MeshCentral - Login
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/views/translations/login-mobile_fr.handlebars b/views/translations/login-mobile_fr.handlebars index e6d78ba7..f81ce8b9 100644 --- a/views/translations/login-mobile_fr.handlebars +++ b/views/translations/login-mobile_fr.handlebars @@ -265,6 +265,8 @@