Fixed $ in device group on Linux when meshcmd amtconfig is used.

Ylian Saint-Hilaire committed Jul 14, 2021 at 14:57 UTC c28e08137554ad5ed0a5db90666d30607e609800
7 files changed +26 -15
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
agents/MeshService-signed.exe
Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ
agents/MeshService64-signed.exe
Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ
agents/meshcmd.js
+24 -13
@@ -110,7 +110,7 @@ function run(argv) {
110 //console.log('addedModules = ' + JSON.stringify(addedModules));
111 var actionpath = 'meshaction.txt';
112 if (args.actionfile != null) { actionpath = args.actionfile; }
113 - var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTINFO', 'AMTINFODEBUG', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE', 'AMTSTARTCONFIG', 'AMTSTOPCONFIG'];
113 + var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTINFO', 'AMTINFOJSON', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE', 'AMTSTARTCONFIG', 'AMTSTOPCONFIG'];
114
115 // Load the action file
116 var actionfile = null;
@@ -223,8 +223,12 @@ function run(argv) {
223 console.log(' --output [filename] Optional filename to write the results to.');
224 } else if (action == 'amtinfo') {
225 console.log('AmtInfo action will get the version and activation state of Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. Example usage:\r\n\r\n meshcmd amtinfo');
226 + console.log('\r\nPossible arguments:\r\n');
227 + console.log(' --json Display all Intel AMT state in JSON format.');
228 } else if ((action == 'amtversion') || (action == 'amtversions')) {
229 console.log('AmtVersions will display all version information about Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. Example usage:\r\n\r\n meshcmd amtversions');
230 + console.log('\r\nPossible arguments:\r\n');
231 + console.log(' --json Display all Intel AMT state in JSON format.');
232 } else if (action == 'amthashes') {
233 console.log('Amthashes will display all trusted activations hashes for Intel AMT on this computer. The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. These certificates hashes are used by Intel AMT when performing activation into ACM mode. Example usage:\r\n\r\n meshcmd amthashes');
234 } else if ((action == 'microlms') || (action == 'lms') || (action == 'amtlms')) {
@@ -485,15 +489,19 @@ function run(argv) {
489 try { amtMeiModule = require('amt-mei'); amtMei = new amtMeiModule(); } catch (ex) { console.log(ex); exit(1); return; }
490 amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; });
491 amtMei.getVersion(function (val) {
488 - console.log("BIOS Version = " + val.BiosVersion.toString());
489 - for (var version in val.Versions) {
490 - var extras = '', skuBits = ['', 'iQST', 'ASF', 'AMT', 'ISM', 'TPM', '', '', 'HomeIT', '', 'WOX', '', '', 'AT-p', 'Corporate', 'L3 Mgt Upgrade'];
491 - if (val.Versions[version].Description == 'Sku') {
492 - var n = parseInt(val.Versions[version].Version), x = [], xx = 1;
493 - for (var i = 0; i < skuBits.length; i++) { if ((n & xx) != 0) { x.push(skuBits[i]); } xx = xx << 1; }
494 - if (x.length > 0) { extras = ' (' + x.join(', ') + ')' }
492 + if (args.json) {
493 + console.log(JSON.stringify(val, null, 2));
494 + } else {
495 + console.log("BIOS Version = " + val.BiosVersion.toString());
496 + for (var version in val.Versions) {
497 + var extras = '', skuBits = ['', 'iQST', 'ASF', 'AMT', 'ISM', 'TPM', '', '', 'HomeIT', '', 'WOX', '', '', 'AT-p', 'Corporate', 'L3 Mgt Upgrade'];
498 + if (val.Versions[version].Description == 'Sku') {
499 + var n = parseInt(val.Versions[version].Version), x = [], xx = 1;
500 + for (var i = 0; i < skuBits.length; i++) { if ((n & xx) != 0) { x.push(skuBits[i]); } xx = xx << 1; }
501 + if (x.length > 0) { extras = ' (' + x.join(', ') + ')' }
502 + }
503 + console.log(val.Versions[version].Description + " = " + val.Versions[version].Version + extras);
504 }
496 - console.log(val.Versions[version].Description + " = " + val.Versions[version].Version + extras);
505 }
506 exit(1); return;
507 });
@@ -534,7 +542,7 @@ function run(argv) {
542 }
543 amtMei.getProvisioningState(function (result) { if (result) { mestate.ProvisioningState = result; } });
544 amtMei.getProvisioningMode(function (result) { if (result) { mestate.ProvisioningMode = result; } });
537 - amtMei.getEHBCState(function (result) { if (result) { mestate.ehbc = result; } });
545 + amtMei.getEHBCState(function (result) { mestate.ehbc = ((result === true) || (typeof result == 'object') && (result.EHBC === true)); });
546 amtMei.getControlMode(function (result) { if (result) { mestate.controlmode = result; } });
547 amtMei.getMACAddresses(function (result) { if (result) { mestate.mac = result; } });
548 amtMei.getLanInterfaceSettings(0, function (result) { if (result) { mestate.net0 = result; } });
@@ -543,7 +551,9 @@ function run(argv) {
551 amtMei.getRemoteAccessConnectionStatus(function (result) { if ((result != null) && (result.status == 0)) { mestate.networkStatus = result.networkStatus; mestate.remoteAccessStatus = result.remoteAccessStatus; mestate.remoteAccessTrigger = result.remoteAccessTrigger; mestate.mpsHostname = result.mpsHostname; } });
552 amtMei.getDnsSuffix(function (result) {
553 if (result) { mestate.DnsSuffix = result; }
546 - if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) {
554 + if (args.json) {
555 + console.log(JSON.stringify(mestate, null, 2));
556 + } else if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) {
557 var str = 'Intel ME v' + mestate.ver;
558 if (mestate.sku & 8) { str = 'Intel AMT v' + mestate.ver }
559 else if (mestate.sku & 16) { str = 'Intel SM v' + mestate.ver }
@@ -558,7 +568,7 @@ function run(argv) {
568 }
569 }
570 }
561 - if ((mestate.ehbc) && (mestate.ehbc.EHBC == true)) { str += ', EHBC enabled'; }
571 + if (mestate.ehbc) { str += ', EHBC enabled'; }
572 str += '.';
573 if (mestate.net0 != null) { str += '\r\nWired ' + ((mestate.net0.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net0.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net0.mac + (mestate.net0.address == '0.0.0.0' ? '' : (', ' + mestate.net0.address)); }
574 if (mestate.net1 != null) { str += '\r\nWireless ' + ((mestate.net1.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net1.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net1.mac + (mestate.net1.address == '0.0.0.0' ? '' : (', ' + mestate.net1.address)); }
@@ -596,7 +606,7 @@ function run(argv) {
606 }
607 });
608 } catch (ex) { console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; }
599 - } else if (settings.action == 'amtinfodebug') {
609 + } else if (settings.action == 'amtinfojson') {
610 // Display Intel AMT version and activation state
611 getMeiState(15, function (state) { console.log(JSON.stringify(state, null, 2)); exit(1); }); // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
612 } else if (settings.action == 'amtsavestate') {
@@ -639,6 +649,7 @@ function run(argv) {
649 // Start Intel AMT configuration
650 if ((settings.url == null) || (typeof settings.url != 'string') || (settings.url == '')) { console.log('No MeshCentral server URL specified, use --url [url].'); exit(1); return; }
651 if ((settings.id == null) || (typeof settings.id != 'string') || (settings.id == '')) { console.log('No device group identifier specified, use --id [identifier].'); exit(1); return; }
652 + settings.id = settings.id.replace('\'', ''); // Remove single quote.
653 debug(1, "Settings: " + JSON.stringify(settings));
654 configureAmt();
655 } else if (settings.action == 'amtccm') {
amtmanager.js
+1 -1
@@ -1875,7 +1875,7 @@ module.exports.CreateAmtManager = function (parent) {
1875 function activateIntelAmt(dev) {
1876 // Find the Intel AMT policy
1877 const mesh = parent.webserver.meshes[dev.meshid];
1878 - if (mesh == null) { dev.consoleMsg("Unable to find device group."); removeAmtDevice(dev, 36); return false; }
1878 + if (mesh == null) { dev.consoleMsg("Unable to find device group (" + dev.meshid + ")."); removeAmtDevice(dev, 36); return false; }
1879 var amtPolicy = 0; // 0 = Do nothing, 1 = Deactivate CCM, 2 = CCM, 3 = ACM
1880 var ccmPolicy = 0; // Only used when in ACM policy: 0 = Do nothing, 1 = Deactivate CCM, 2 = CCM is ACM fails
1881 if (mesh.amt != null) { if (typeof mesh.amt.type == 'number') { amtPolicy = mesh.amt.type; } if (typeof mesh.amt.ccm == 'number') { ccmPolicy = mesh.amt.ccm; } }
views/default.handlebars
+1 -1
@@ -4575,7 +4575,7 @@
4575 url = 'ws://' + servername + portStr + domainUrl;
4576 }
4577 var x = format("Add, activate and configure Intel&reg; AMT to group \"{0}\" by periodically running MeshCmd as administrator on the remote device.", EscapeHtml(mesh.name)) + '<br /><br />';
4578 - x += '<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtconfig --url ' + url + 'apf.ashx --id ' + meshid.split('/')[2] + ' --serverhttpshash ' + serverinfo.tlshash + '</textarea>';
4578 + x += '<textarea readonly=readonly style=width:100%;resize:none;height:100px;overflow:auto;font-size:12px readonly>meshcmd amtconfig --url ' + url + 'apf.ashx --id \'' + meshid.split('/')[2] + '\' --serverhttpshash ' + serverinfo.tlshash + '</textarea>';
4579 if (serverinfo.amtAcmFqdn != null) {
4580 x += ('<div style=margin-top:8px>' + "For ACM activation, Intel&reg; AMT will need to be set to the following trusted FQDN:" + ' <b>' + serverinfo.amtAcmFqdn.join(', ') + '</b></div>');
4581 }