1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-02-14 12:01:52 +00:00

Fix for invalid amtactivation.log parsing.

This commit is contained in:
Ylian Saint-Hilaire 2021-10-12 22:36:41 -07:00
parent 7e0e790e39
commit 0240d1a651

View file

@ -2851,11 +2851,13 @@ function CreateMeshCentralServer(config, args) {
obj.fs.readFile(amtlogfilename, 'utf8', function (err, data) {
var amtPasswords = {}; // UUID --> [Passwords]
if ((err == null) && (data != null)) {
const lines = data.split('\r\n');
const lines = data.split('\r\n').join('\n').split('\n');
for (var i in lines) {
var line = lines[i];
if (line.startsWith('{')) {
var j = JSON.parse(line);
var j = null;
try { j = JSON.parse(line); } catch (ex) { }
if ((j != null) && (typeof j == 'object')) {
if ((typeof j.amtUuid == 'string') && (typeof j.password == 'string')) {
if (amtPasswords[j.amtUuid] == null) {
amtPasswords[j.amtUuid] = [j.password]; // Add password to array
@ -2865,6 +2867,7 @@ function CreateMeshCentralServer(config, args) {
}
}
}
}
// Remove all duplicates and only keep the 3 last passwords for any given device
for (var i in amtPasswords) {
amtPasswords[i] = [...new Set(amtPasswords[i])];