Fixed MeshCMD amtconfig occasionally not matching the device group.

Ylian Saint-Hilaire committed Apr 1, 2021 at 14:07 UTC 51bdd977804d2b955eda733771d53f4be1779a47
1 file changed +10 -2
mpsserver.js
+10 -2
@@ -603,8 +603,16 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) {
603 SendUserAuthFail(socket);
604 return -1;
605 }
606 - var meshIdStart = '/' + username, mesh = null;
607 - if (obj.parent.webserver.meshes) { for (var i in obj.parent.webserver.meshes) { if (obj.parent.webserver.meshes[i]._id.replace(/\@/g, 'X').replace(/\$/g, 'X').indexOf(meshIdStart) > 0) { mesh = obj.parent.webserver.meshes[i]; break; } } }
606 + // Find the device group for this CIRA connection. Since Intel AMT does not allow @ or $ in the username, we escape these.
607 + // For possible for CIRA-LMS connections to still send @ or $, so we need to escape both sides.
608 + var meshIdStart = ('/' + username).replace(/\@/g, 'X').replace(/\$/g, 'X'), mesh = null;
609 + if (obj.parent.webserver.meshes) {
610 + for (var i in obj.parent.webserver.meshes) {
611 + if (obj.parent.webserver.meshes[i]._id.replace(/\@/g, 'X').replace(/\$/g, 'X').indexOf(meshIdStart) > 0) {
612 + mesh = obj.parent.webserver.meshes[i]; break;
613 + }
614 + }
615 + }
616 if (mesh == null) {
617 meshNotFoundCount++;
618 socket.ControlMsg({ action: 'console', msg: 'Device group not found' });