Fixed MeshCMD AMT DNS suffix on Linux.
Ylian Saint-Hilaire committed
Jul 24, 2021 at 10:12 UTC
7766e1ca07278f2605d8d292bb41bcf1446c33ac
7 files changed
+62
-58
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
+61
-43
@@ -559,55 +559,60 @@ function run(argv) {
559
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; } });
560
amtMei.getDnsSuffix(function (result) {
561
if (result) { mestate.DnsSuffix = result; }
562
- if (args.json) {
563
- console.log(JSON.stringify(mestate, null, 2));
564
- } else if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) {
565
- var str = 'Intel ME v' + mestate.ver;
566
- if (mestate.sku & 8) { str = 'Intel AMT v' + mestate.ver }
567
- else if (mestate.sku & 16) { str = 'Intel SM v' + mestate.ver }
568
- if (mestate.ProvisioningState.stateStr == 'PRE') { str += ', pre-provisioning state'; }
569
- else if (mestate.ProvisioningState.stateStr == 'IN') { str += ', in-provisioning state'; }
570
- else if (mestate.ProvisioningState.stateStr == 'POST') {
571
- if (mestate.ProvisioningMode) {
572
- if (mestate.controlmode) {
573
- if (mestate.ProvisioningMode.modeStr == 'ENTERPRISE') { str += ', activated in ' + ["none", "Client Control Mode (CCM)", "Admin Control Mode (ACM)", "remote assistance mode"][mestate.controlmode.controlMode]; } else { str += ', activated in ' + mestate.ProvisioningMode.modeStr; }
574
- } else {
575
- str += ', activated in ' + mestate.ProvisioningMode.modeStr;
562
+ getAmtOsDnsSuffix(mestate, function() {
563
+ if (args.json) {
564
+ console.log(JSON.stringify(mestate, null, 2));
565
+ } else if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) {
566
+ var str = 'Intel ME v' + mestate.ver;
567
+ if (mestate.sku & 8) { str = 'Intel AMT v' + mestate.ver }
568
+ else if (mestate.sku & 16) { str = 'Intel SM v' + mestate.ver }
569
+ if (mestate.ProvisioningState.stateStr == 'PRE') { str += ', pre-provisioning state'; }
570
+ else if (mestate.ProvisioningState.stateStr == 'IN') { str += ', in-provisioning state'; }
571
+ else if (mestate.ProvisioningState.stateStr == 'POST') {
572
+ if (mestate.ProvisioningMode) {
573
+ if (mestate.controlmode) {
574
+ if (mestate.ProvisioningMode.modeStr == 'ENTERPRISE') { str += ', activated in ' + ["none", "Client Control Mode (CCM)", "Admin Control Mode (ACM)", "remote assistance mode"][mestate.controlmode.controlMode]; } else { str += ', activated in ' + mestate.ProvisioningMode.modeStr; }
575
+ } else {
576
+ str += ', activated in ' + mestate.ProvisioningMode.modeStr;
577
+ }
578
}
579
}
578
- }
579
- if (mestate.ehbc) { str += ', EHBC enabled'; }
580
- str += '.';
581
- 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)); }
582
- 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)); }
583
- if ((mestate.net0 != null) && (mestate.net0.enabled == 1)) {
584
- if (mestate.DnsSuffix != null) {
585
- // Intel AMT has a trusted DNS suffix set, use that one.
586
- str += '\r\nTrusted DNS suffix: ' + mestate.DnsSuffix;
587
- } else {
588
- // Look for the DNS suffix for the Intel AMT Ethernet interface
589
- var fqdn = null, interfaces = require('os').networkInterfaces();
590
- for (var i in interfaces) {
591
- for (var j in interfaces[i]) {
592
- if ((interfaces[i][j].mac == mestate.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { fqdn = interfaces[i][j].fqdn; }
580
+ if (mestate.ehbc) { str += ', EHBC enabled'; }
581
+ str += '.';
582
+ 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)); }
583
+ 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)); }
584
+ if ((mestate.net0 != null) && (mestate.net0.enabled == 1)) {
585
+ if (mestate.DnsSuffix != null) {
586
+ // Intel AMT has a trusted DNS suffix set, use that one.
587
+ str += '\r\nTrusted DNS suffix: ' + mestate.DnsSuffix;
588
+ } else if (mestate.OsDnsSuffix != null) {
589
+ // Already found the DNS suffix for the wired interface
590
+ str += '\r\nDNS suffix: ' + mestate.OsDnsSuffix;
591
+ } else {
592
+ // Look for the DNS suffix for the Intel AMT Ethernet interface
593
+ var fqdn = null, interfaces = require('os').networkInterfaces();
594
+ for (var i in interfaces) {
595
+ for (var j in interfaces[i]) {
596
+ if ((interfaces[i][j].mac == mestate.net0.mac) && (interfaces[i][j].fqdn != null) && (interfaces[i][j].fqdn != '')) { fqdn = interfaces[i][j].fqdn; }
597
+ }
598
}
599
+ if (fqdn != null) { str += '\r\nDNS suffix: ' + fqdn; }
600
}
595
- if (fqdn != null) { str += '\r\nDNS suffix: ' + fqdn; }
601
}
597
- }
598
- if (typeof mestate.networkStatus == 'number') {
599
- str += '\r\nConnection Status: ' + ['Direct', 'VPN', 'Outside', 'Unknown'][mestate.networkStatus];
600
- str += ', CIRA: ' + ['Disconnected', 'Connecting', 'Connected'][mestate.remoteAccessStatus];
601
- if ((mestate.remoteAccessStatus > 0) && (mestate.mpsHostname != null) && (mestate.mpsHostname.length > 0)) {
602
- str += ' to ' + mestate.mpsHostname + ', ' + ['User initiated', 'Alert', 'Periodic', 'Provisioning'][mestate.remoteAccessTrigger];
602
+ if (typeof mestate.networkStatus == 'number') {
603
+ str += '\r\nConnection Status: ' + ['Direct', 'VPN', 'Outside', 'Unknown'][mestate.networkStatus];
604
+ str += ', CIRA: ' + ['Disconnected', 'Connecting', 'Connected'][mestate.remoteAccessStatus];
605
+ if ((mestate.remoteAccessStatus > 0) && (mestate.mpsHostname != null) && (mestate.mpsHostname.length > 0)) {
606
+ str += ' to ' + mestate.mpsHostname + ', ' + ['User initiated', 'Alert', 'Periodic', 'Provisioning'][mestate.remoteAccessTrigger];
607
+ }
608
}
609
+ console.log(str + '.');
610
+ exit(0);
611
+ } else {
612
+ console.log('Intel(R) AMT not supported.');
613
+ exit(1);
614
}
605
- console.log(str + '.');
606
- exit(0);
607
- } else {
608
- console.log('Intel(R) AMT not supported.');
609
- exit(1);
610
- }
615
+ });
616
});
617
} else {
618
console.log("Unable to perform MEI operations, try running as " + ((process.platform == 'win32')?"administrator.":"root."));
@@ -1184,7 +1189,7 @@ function configureAmt() {
1189
getMeiState(15, function (state) { // Flags: 1 = Versions, 2 = OsAdmin, 4 = Hashes, 8 = Network
1190
if (state == null) { console.log("Unable to get Intel AMT state, try running as " + ((process.platform == 'win32')?"administrator.":"root.")); exit(1); return; }
1191
if (state.ProvisioningState == null) { console.log('Intel AMT not ready for configuration.'); exit(1); return; }
1187
- startLms(configureAmt2, false, state);
1192
+ getAmtOsDnsSuffix(state, function() { startLms(configureAmt2, false, state); });
1193
});
1194
}
1195
@@ -2987,6 +2992,19 @@ function getMeiState(flags, func) {
2992
} catch (e) { if (func != null) { func(null); } return; }
2993
}
2994
2995
+// On non-Windows platforms, we need to query the DHCP server for the DNS suffix
2996
+function getAmtOsDnsSuffix(mestate, func) {
2997
+ if ((process.platform == 'win32') || (mestate.net0 == null) || (mestate.net0.mac == null)) { func(mestate); return; }
2998
+ try { require('linux-dhcp') } catch (ex) { func(mestate); return; }
2999
+ require('linux-dhcp').client.info(mestate.net0.mac).then(function(d) {
3000
+ if ((typeof d.options == 'object') && (typeof d.options.domainname == 'string')) { mestate.OsDnsSuffix = d.options.domainname; }
3001
+ func(mestate);
3002
+ }, function(e) {
3003
+ console.log('DHCP error', e);
3004
+ func(mestate);
3005
+ });
3006
+}
3007
+
3008
3009
//
3010
// Startup
amtmanager.js
+1
-1
@@ -1897,7 +1897,7 @@ module.exports.CreateAmtManager = function (parent) {
1897
var trustedFqdn = null;
1898
if (dev.mpsConnection.tag.meiState.OsDnsSuffix != null) { trustedFqdn = dev.mpsConnection.tag.meiState.OsDnsSuffix; }
1899
if (dev.mpsConnection.tag.meiState.DnsSuffix != null) { trustedFqdn = dev.mpsConnection.tag.meiState.DnsSuffix; }
1900
- dev.consoleMsg("No opportunity for ACM activation, trusted FQDN: " + ((trustedFqdn == null) ? "(Not Set)" : (trustedFqdn + ", HEX: " + Buffer.from(trustedFqdn).toString('hex'))));
1900
+ dev.consoleMsg("No opportunity for ACM activation, trusted FQDN: " + ((trustedFqdn == null) ? "(Not Set)" : trustedFqdn));
1901
removeAmtDevice(dev, 38);
1902
return false; // We are not in CCM and policy restricts use of CCM, so exit now.
1903
}
webserver.js
-14
@@ -5721,20 +5721,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
5721
if (obj.parent.config.firebase.relayserver) { parent.debug('email', 'Firebase-relay-handler'); obj.app.ws(url + 'firebaserelay.aspx', handleFirebaseRelayRequest); }
5722
}
5723
5724
- /*
5725
- // Testing code only, display a POST and return 200 OK
5726
- obj.app.post(url + 'post.aspx', function (req, res) {
5727
- var body = [];
5728
- req.on('data', function(chunk) {
5729
- body.push(chunk);
5730
- }).on('end', () => {
5731
- body = Buffer.concat(body).toString();
5732
- console.log(body);
5733
- res.sendStatus(200);
5734
- });
5735
- });
5736
- */
5737
-
5724
// Setup auth strategies using passport if needed
5725
if (typeof domain.authstrategies == 'object') {
5726
const passport = domain.passport = require('passport');