More work on Intel AMT Click Once Recovery.
Ylian Saint-Hilaire committed
Mar 22, 2021 at 19:00 UTC
1c47f13090460072a27af3e7df39e04703499693
2 files changed
+28
-3
meshuser.js
+24
-2
@@ -5492,8 +5492,30 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5492
}
5493
break;
5494
}
5495
- case 'clickoncerecovery': {
5496
- console.log(command); // TODO
5495
+ case 'clickoncerecovery': { // Intel(R) AMT Click once recovery
5496
+ if (common.validateStrArray(command.nodeids, 1) == false) break; // Check nodeids
5497
+ if (common.validateString(command.path, 1, 2048) == false) break; // Check file path
5498
+ if (command.type != 'diskimage') break; // Make sure type is correct
5499
+
5500
+ var file = parent.getServerFilePath(user, domain, command.path);
5501
+ if (file == null) return;
5502
+
5503
+ // For each nodeid, change the group
5504
+ for (var i = 0; i < command.nodeids.length; i++) {
5505
+ var xnodeid = command.nodeids[i];
5506
+ if (xnodeid.indexOf('/') == -1) { xnodeid = 'node/' + domain.id + '/' + xnodeid; }
5507
+
5508
+ // Get the node and the rights for this node
5509
+ parent.GetNodeWithRights(domain, user, xnodeid, function (node, rights, visible) {
5510
+ // Check if we found this device and if we have full rights
5511
+ if ((node == null) || (rights != 0xFFFFFFFF)) return;
5512
+
5513
+ // Perform Intel AMT Click Once Recovery
5514
+ console.log('ClickOnceRecovery', node._id, file.fullpath);
5515
+ });
5516
+ }
5517
+
5518
+ //console.log(command, file);
5519
break;
5520
}
5521
default: {
webserver.js
+4
-1
@@ -3438,7 +3438,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3438
if ((node == null) || (rights != 0xFFFFFFFF) || (visible == false)) { res.sendStatus(404); return; } // We don't have remote control rights to this device
3439
for (var i in files.files) {
3440
var file = files.files[i];
3441
- console.log('ClickOnceRecovery', file); // TODO
3441
+
3442
+ // Perform Intel AMT Click Once Recovery
3443
+ console.log('ClickOnceRecovery', node._id, file.path);
3444
+
3445
try { obj.fs.unlinkSync(file.path); } catch (e) { }
3446
}
3447
res.send('');