Improved AmtManager, Fixed missing image-size.
Ylian Saint-Hilaire committed
Feb 22, 2021 at 12:08 UTC
b7117641a058d2bf3d559975075486084b49a78d
6 files changed
+55
-39
amtmanager.js
+15
-16
@@ -255,6 +255,7 @@ module.exports.CreateAmtManager = function (parent) {
255
// Handle server events
256
// Make sure to only manage devices with connections to this server. In a multi-server setup, we don't want multiple managers talking to the same device.
257
obj.HandleEvent = function (source, event, ids, id) {
258
+ 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.
259
switch (event.action) {
260
case 'removenode': { // React to node being removed
261
removeDevice(event.nodeid);
@@ -266,22 +267,21 @@ module.exports.CreateAmtManager = function (parent) {
267
}
268
case 'changenode': { // React to changes in a device
269
var devices = obj.amtDevices[event.nodeid];
269
- if (devices = null) break; // We are not managing this device
270
- if (event.amtchange === 1) {
271
- // TODO
272
- } else {
273
- /*
274
- var dev = obj.amtDevices[event.nodeid];
275
- if (dev != null) {
276
- var amtchange = 0;
277
- if (dev.name != event.node.name) { dev.name = event.node.name; }
278
- if (dev.host != event.node.host) {
279
- dev.host = event.node.host;
280
- // The host has changed, if we are connected to this device locally, we need to reset.
281
- if ((dev.conn & 4) != 0) { removeDevice(dev.nodeid); return; } // We are going to wait for the AMT scanned to find this device again.
282
- }
270
+ if (devices == null) break; // We are not managing this device
271
+ for (var i in devices) {
272
+ var dev = devices[i];
273
+ if (dev.name != event.node.name) {
274
+ //console.log('device name change');
275
+ dev.name = event.node.name;
276
+ }
277
+ if (event.node.intelamt != null) {
278
+ dev.intelamt = event.node.intelamt;
279
+ }
280
+ if ((dev.connType == 3) && (dev.host != event.node.host)) {
281
+ //console.log('device host change', dev.host, event.node.host);
282
+ dev.host = event.node.host; // The host has changed, if we are connected to this device locally, we need to reset.
283
+ removeAmtDevice(dev); // We are going to wait for the AMT scanned to find this device again.
284
}
284
- */
285
}
286
break;
287
}
@@ -486,7 +486,6 @@ module.exports.CreateAmtManager = function (parent) {
486
dev.amtstack.dev = dev;
487
obj.activeLocalConnections[dev.host] = dev;
488
dev.amtstack.BatchEnum(null, ['*AMT_GeneralSettings', '*IPS_HostBasedSetupService'], attemptLocalConnectResponse);
489
- dev.conntype = 1; // LOCAL
489
}
490
break;
491
}
meshcentral-config-schema.json
+6
-6
@@ -336,16 +336,16 @@
336
}
337
},
338
"urlSwitching": { "type": "boolean", "default": true, "description": "When users navigate thru the web interface, the URL on top will change to point to the current screen. This allows a user to refresh or bookmark the URL and come back to the correct screen. Setting false here will disable this feature." },
339
- "desktopPrivacyBarText": { "type": "string" },
339
+ "desktopPrivacyBarText": { "type": "string", "description": "This is the text that will be shown in the remote desktop privacy bar. You can use {0} to display the account realname or {1} to display the account identifier in the string." },
340
"limits": {
341
"type": "object",
342
"additionalProperties": false,
343
"properties": {
344
- "MaxDevices": { "type": "integer" },
345
- "MaxUserAccounts": { "type": "integer" },
346
- "MaxUserSessions": { "type": "integer" },
347
- "MaxAgentSessions": { "type": "integer" },
348
- "MaxSingleUserSessions": { "type": "integer" }
344
+ "MaxDevices": { "type": "integer", "default": null, "description": "Maximum number of devices in this domain." },
345
+ "MaxUserAccounts": { "type": "integer", "default": null, "description": "Maximum number of devices in this domain." },
346
+ "MaxUserSessions": { "type": "integer", "default": null, "description": "Maximum number of user sessions that can connect to this server for this domain." },
347
+ "MaxAgentSessions": { "type": "integer", "default": null, "description": "Maximum number of agents that can connect to this server for this domain." },
348
+ "MaxSingleUserSessions": { "type": "integer", "default": null, "description": "Maximum number of sessions a single user can have. Each time a user opens a new browser tab or opens a new browser on a different computer, a new user session is created." }
349
}
350
},
351
"terminal": {
meshcentral.js
+3
-3
@@ -3039,7 +3039,7 @@ function mainStart() {
3039
var allsspi = true;
3040
var yubikey = false;
3041
var mstsc = false;
3042
- var recordingIndex = false;
3042
+ var sessionRecording = false;
3043
var domainCount = 0;
3044
var wildleek = false;
3045
var nodemailer = false;
@@ -3062,7 +3062,7 @@ function mainStart() {
3062
if ((typeof config.domains[i].authstrategies.azure == 'object') && (typeof config.domains[i].authstrategies.azure.clientid == 'string') && (typeof config.domains[i].authstrategies.azure.clientsecret == 'string') && (typeof config.domains[i].authstrategies.azure.tenantid == 'string') && (passport.indexOf('passport-azure-oauth2') == -1)) { passport.push('passport-azure-oauth2'); passport.push('jwt-simple'); }
3063
if ((typeof config.domains[i].authstrategies.saml == 'object') || (typeof config.domains[i].authstrategies.jumpcloud == 'object')) { passport.push('passport-saml'); }
3064
}
3065
- if ((config.domains[i].sessionrecording != null) && (config.domains[i].sessionrecording.index == true)) { recordingIndex = true; }
3065
+ if (config.domains[i].sessionrecording != null) { sessionRecording = true; }
3066
if ((config.domains[i].passwordrequirements != null) && (config.domains[i].passwordrequirements.bancommonpasswords == true)) { if (nodeVersion < 8) { config.domains[i].passwordrequirements = false; addServerWarning('Common password checking requires NodeJS v8 or above.'); } else { wildleek = true; } }
3067
}
3068
@@ -3072,7 +3072,7 @@ function mainStart() {
3072
if (ldap == true) { modules.push('ldapauth-fork'); }
3073
if (mstsc == true) { modules.push('node-rdpjs-2'); }
3074
if (passport != null) { modules.push(...passport); }
3075
- if (recordingIndex == true) { modules.push('image-size'); } // Need to get the remote desktop JPEG sizes to index the recodring file.
3075
+ if (sessionRecording == true) { modules.push('image-size'); } // Need to get the remote desktop JPEG sizes to index the recodring file.
3076
if (config.letsencrypt != null) { if (nodeVersion < 8) { addServerWarning("Let's Encrypt support requires Node v8.x or higher.", !args.launch); } else { modules.push('acme-client'); } } // Add acme-client module
3077
if (config.settings.mqtt != null) { modules.push('aedes'); } // Add MQTT Modules
3078
if (config.settings.mysql != null) { modules.push('mysql'); } // Add MySQL, official driver.
meshuser.js
+9
-2
@@ -4047,8 +4047,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4047
}
4048
if (command.desc != null && (command.desc != node.desc)) { change = 1; node.desc = command.desc; changes.push('description'); }
4049
if (command.intelamt != null) {
4050
- if ((parent.parent.amtManager == null) || (node.intelamt.user == null) || (node.intelamt.user == '') || ((node.intelamt.warn != null) && ((node.intelamt.warn) & 1 != 0))) { // Only allow changes to Intel AMT credentials if AMT manager is not running, or manager warned of unknown credentials.
4051
- if ((command.intelamt.user != null) && (command.intelamt.pass != null) && ((command.intelamt.user != node.intelamt.user) || (command.intelamt.pass != node.intelamt.pass))) { change = 1; node.intelamt.user = command.intelamt.user; node.intelamt.pass = command.intelamt.pass; changes.push('Intel AMT credentials'); amtchange = 1; }
4050
+ if ((parent.parent.amtManager == null) || (node.intelamt.user == null) || (node.intelamt.user == '') || ((node.intelamt.warn != null) && ((node.intelamt.warn) & 3 != 0))) { // Only allow changes to Intel AMT credentials if AMT manager is not running, or manager warned of unknown/trying credentials.
4051
+ if ((command.intelamt.user != null) && (command.intelamt.pass != null) && ((command.intelamt.user != node.intelamt.user) || (command.intelamt.pass != node.intelamt.pass))) {
4052
+ change = 1;
4053
+ node.intelamt.user = command.intelamt.user;
4054
+ node.intelamt.pass = command.intelamt.pass;
4055
+ node.intelamt.warn = 2; // Change warning to "Trying". Bit flags: 0 = Valid credentials, 1 = Invalid credentials, 2 = Trying new credentials.
4056
+ changes.push('Intel AMT credentials');
4057
+ amtchange = 1;
4058
+ }
4059
}
4060
// Only allow the user to set Intel AMT TLS state if AMT Manager is not active. AMT manager will auto-detect TLS state.
4061
if ((parent.parent.amtManager != null) && (command.intelamt.tls != null) && (command.intelamt.tls != node.intelamt.tls)) { change = 1; node.intelamt.tls = command.intelamt.tls; changes.push('Intel AMT TLS'); }
views/default-mobile.handlebars
+11
-6
@@ -3125,12 +3125,17 @@
3125
} else {
3126
str += ', <i style=color:#FF0000>' + "No Credentials" + '</i>';
3127
}
3128
- } else if (((features2 & 1) != 0) && (node.intelamt.warn != null) && ((node.intelamt.warn & 1) != 0)) { // If AMT manager is running and warned of invalid credentials, allow setting them.
3129
- if ((meshrights & 4) != 0) {
3130
- str += ', <i style=color:#FF0000;cursor:pointer title="' + "Edit Intel® AMT credentials" + '" onclick=editDeviceAmtSettings("' + node._id + '")>' + "Invalid Credentials" + '</i>';
3131
- editUserCredentialsIcon = true;
3132
- } else {
3133
- str += ', <i style=color:#FF0000>' + "Invalid Credentials" + '</i>';
3128
+ } else if (((features2 & 1) != 0) && (node.intelamt.warn != null)) { // If AMT manager is running and warned of invalid credentials, allow setting them.
3129
+ var warn = null;
3130
+ if ((node.intelamt.warn & 1) != 0) { warn = "Invalid Credentials"; }
3131
+ if ((node.intelamt.warn & 2) != 0) { warn = "Trying Credentials"; }
3132
+ if (warn != null) {
3133
+ if ((meshrights & 4) != 0) {
3134
+ str += ', <i style=color:#FF0000;cursor:pointer title="' + "Edit Intel® AMT credentials" + '" onclick=editDeviceAmtSettings("' + node._id + '")>' + warn + '</i>';
3135
+ editUserCredentialsIcon = true;
3136
+ } else {
3137
+ str += ', <i style=color:#FF0000>' + warn + '</i>';
3138
+ }
3139
}
3140
}
3141
views/default.handlebars
+11
-6
@@ -5924,12 +5924,17 @@
5924
} else {
5925
str += ', <i style=color:#FF0000>' + "No Credentials" + '</i>';
5926
}
5927
- } else if (((features2 & 1) != 0) && (node.intelamt.warn != null) && ((node.intelamt.warn & 1) != 0)) { // If AMT manager is running and warned of invalid credentials, allow setting them.
5928
- if ((meshrights & 4) != 0) {
5929
- str += ', <i style=color:#FF0000;cursor:pointer title="' + "Edit Intel® AMT credentials" + '" onclick=editDeviceAmtSettings("' + node._id + '")>' + "Invalid Credentials" + '</i>';
5930
- editUserCredentialsIcon = true;
5931
- } else {
5932
- str += ', <i style=color:#FF0000>' + "Invalid Credentials" + '</i>';
5927
+ } else if (((features2 & 1) != 0) && (node.intelamt.warn != null)) { // If AMT manager is running and warned of invalid credentials, allow setting them.
5928
+ var warn = null;
5929
+ if ((node.intelamt.warn & 1) != 0) { warn = "Invalid Credentials"; }
5930
+ if ((node.intelamt.warn & 2) != 0) { warn = "Trying Credentials"; }
5931
+ if (warn != null) {
5932
+ if ((meshrights & 4) != 0) {
5933
+ str += ', <i style=color:#FF0000;cursor:pointer title="' + "Edit Intel® AMT credentials" + '" onclick=editDeviceAmtSettings("' + node._id + '")>' + warn + '</i>';
5934
+ editUserCredentialsIcon = true;
5935
+ } else {
5936
+ str += ', <i style=color:#FF0000>' + warn + '</i>';
5937
+ }
5938
}
5939
}
5940