From d750077f451e3e4b56f99d628be3b0b7adaa1d35 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Mon, 22 Mar 2021 20:04:43 -0700 Subject: [PATCH] Click once work, UI fixes. --- amtmanager.js | 22 ++++++++++++++++++++++ meshuser.js | 4 ++-- public/styles/style.css | 1 + views/default.handlebars | 6 +++--- webserver.js | 6 +++--- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/amtmanager.js b/amtmanager.js index 5f71aa21..34887acf 100644 --- a/amtmanager.js +++ b/amtmanager.js @@ -295,6 +295,11 @@ module.exports.CreateAmtManager = function (parent) { if (Array.isArray(event.nodeids)) { for (var i in event.nodeids) { performPowerAction(event.nodeids[i], 2); } } break; } + case 'clickoncerecovery': { // React to Intel AMT Click Once Recovery command + if (event.noact == 1) return; // Take no action on these events. We are likely in peering mode and need to only act when the database signals the change in state. + if (Array.isArray(event.nodeids)) { for (var i in event.nodeids) { performClickOnceRecoveryAction(event.nodeids[i], event.file); } } + break; + } case 'changenode': { // React to changes in a device var devices = obj.amtDevices[event.nodeid], rescan = false; if (devices != null) { @@ -805,6 +810,23 @@ module.exports.CreateAmtManager = function (parent) { } + // Perform Intel AMT Click Once Recovery on a device + function performClickOnceRecoveryAction(nodeid, file) { + var devices = obj.amtDevices[nodeid]; + if (devices == null) return; + for (var i in devices) { + var dev = devices[i]; + // If not LMS, has a AMT stack present and is in connected state, perform operation. + if ((dev.connType != 2) && (dev.state == 1) && (dev.amtstack != null)) { + console.log('Perform Click Once Recovery', nodeid, file); + + // TODO: Make sure the MPS server root certificate is present. + // TODO: Generate the one-time URL. + // TODO: Issue the WSMAN command. + } + } + } + // // Intel AMT Clock Syncronization // diff --git a/meshuser.js b/meshuser.js index bbb1e83c..97f2869f 100644 --- a/meshuser.js +++ b/meshuser.js @@ -5510,8 +5510,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use // Check if we found this device and if we have full rights if ((node == null) || (rights != 0xFFFFFFFF)) return; - // Perform Intel AMT Click Once Recovery - console.log('ClickOnceRecovery', node._id, file.fullpath); + // Event Intel AMT Click Once Recovery, this will cause Intel AMT wake operations on this and other servers. + parent.parent.DispatchEvent('*', obj, { action: 'clickoncerecovery', userid: user._id, username: user.name, nodeids: [node._id], domain: domain.id, nolog: 1, file: file.fullpath }); }); } diff --git a/public/styles/style.css b/public/styles/style.css index 795375e3..4aef0a3e 100644 --- a/public/styles/style.css +++ b/public/styles/style.css @@ -2385,6 +2385,7 @@ a { grid-area: deskarea1; -ms-grid-column: 1; -ms-grid-row: 1; + height: 20px; } diff --git a/views/default.handlebars b/views/default.handlebars index cadff5d5..9cce2911 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -582,7 +582,7 @@     -  Disconnected +  Disconnected
@@ -676,7 +676,7 @@     -  Disconnected +  Disconnected
@@ -6613,7 +6613,7 @@ if (((currentNode.conn & 1) != 0) && ((rights & 131072) != 0)) { count++; y += ''; } // Remote command permission if ((currentNode.conn != 0) && ((rights & 262144) != 0)) { count++; y += ''; } if ((currentNode.conn & 16) != 0) { count++; y += ''; } - if ((getNodeAmtVersion(currentNode) >= 15) && ((currentNode.conn & 6) != 0) && (rights == 0xFFFFFFFF) && ((features & 0x00000400) == 0)) { count++; y += ''; } // CIRA (2) or AMT (4) connected + if ((getNodeAmtVersion(currentNode) >= 15) && (currentNode.intelamt.state == 2) && ((currentNode.conn & 6) != 0) && (rights == 0xFFFFFFFF) && ((features & 0x00000400) == 0)) { count++; y += ''; } // CIRA (2) or AMT (4) connected if (((currentNode.conn & 1) != 0) && ((rights & 32768) != 0)) { count++; y += ''; } y += ''; x += addHtmlValue("Operation", y); diff --git a/webserver.js b/webserver.js index df288eb1..1d308e2a 100644 --- a/webserver.js +++ b/webserver.js @@ -3439,10 +3439,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { for (var i in files.files) { var file = files.files[i]; - // Perform Intel AMT Click Once Recovery - console.log('ClickOnceRecovery', node._id, file.path); + // Event Intel AMT Click Once Recovery, this will cause Intel AMT wake operations on this and other servers. + parent.DispatchEvent('*', obj, { action: 'clickoncerecovery', userid: user._id, username: user.name, nodeids: [node._id], domain: domain.id, nolog: 1, file: file.path }); - try { obj.fs.unlinkSync(file.path); } catch (e) { } + try { obj.fs.unlinkSync(file.path); } catch (e) { } // TODO: Remove this file after 30 minutes. } res.send(''); });