Fixed issue where if first remote desktop user was view-only, it would block all input in desktop multiplexor mode.
Ylian Saint-Hilaire committed
Aug 4, 2021 at 21:12 UTC
90c7fc98542eb79d153b222f671b2c1b7b473aaa
2 files changed
+11
-3
meshdesktopmultiplex.js
+3
@@ -989,6 +989,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
989
};
990
991
obj.sendAgentMessage = function (command, userid, domainid) {
992
+ console.log('sendAgentMessage');
993
var rights, mesh;
994
if (command.nodeid == null) return false;
995
var user = parent.users[userid];
@@ -1006,6 +1007,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
1007
if ((rights != null) && (mesh != null) || ((rights & 16) != 0)) { // TODO: 16 is console permission, may need more gradular permission checking
1008
if (ws.sessionId) { command.sessionid = ws.sessionId; } // Set the session id, required for responses.
1009
command.rights = rights; // Add user rights flags to the message
1010
+ if ((command.rights != 0xFFFFFFFF) && ((command.rights & 0x100) != 0)) { command.rights -= 0x100; } // Since the multiplexor will enforce view-only, remove MESHRIGHT_REMOTEVIEWONLY
1011
if (typeof command.consent == 'number') { command.consent = command.consent | mesh.consent; } else { command.consent = mesh.consent; } // Add user consent
1012
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
1013
command.username = user.name; // Add user name
@@ -1025,6 +1027,7 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
1027
if (rights != null || ((rights & 16) != 0)) { // TODO: 16 is console permission, may need more gradular permission checking
1028
if (ws.sessionId) { command.fromSessionid = ws.sessionId; } // Set the session id, required for responses.
1029
command.rights = rights; // Add user rights flags to the message
1030
+ if ((command.rights != 0xFFFFFFFF) && ((command.rights & 0x00000100) != 0)) { command.rights -= 0x00000100; } // Since the multiplexor will enforce view-only, remove MESHRIGHT_REMOTEVIEWONLY
1031
if (typeof command.consent == 'number') { command.consent = command.consent | mesh.consent; } else { command.consent = mesh.consent; } // Add user consent
1032
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
1033
command.username = user.name; // Add user name
meshuser.js
+8
-3
@@ -225,7 +225,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
225
}
226
227
// Route a command to a target node
228
- function routeCommandToNode(command, requiredRights, requiredNonRights, func) {
228
+ function routeCommandToNode(command, requiredRights, requiredNonRights, func, options) {
229
if (common.validateString(command.nodeid, 8, 128) == false) { if (func) { func(false); } return false; }
230
var splitnodeid = command.nodeid.split('/');
231
// Check that we are in the same domain and the user has rights over this node.
@@ -242,6 +242,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
242
243
command.sessionid = ws.sessionId; // Set the session id, required for responses
244
command.rights = rights; // Add user rights flags to the message
245
+ if ((options != null) && (options.removeViewOnlyLimitation === true) && (command.rights != 0xFFFFFFFF) && ((command.rights & 0x100) != 0)) { command.rights -= 0x100; } // Since the multiplexor will enforce view-only, remove MESHRIGHT_REMOTEVIEWONLY
246
command.consent = 0;
247
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
248
if (typeof mesh.consent == 'number') { command.consent |= mesh.consent; } // Add device group user consent
@@ -284,6 +285,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
285
if ((node != null) && (mesh != null) && ((rights & MESHRIGHT_REMOTECONTROL) || (rights & MESHRIGHT_REMOTEVIEWONLY))) { // 8 is remote control permission
286
command.fromSessionid = ws.sessionId; // Set the session id, required for responses
287
command.rights = rights; // Add user rights flags to the message
288
+ if ((options != null) && (options.removeViewOnlyLimitation === true) && (command.rights != 0xFFFFFFFF) && ((command.rights & 0x100) != 0)) { command.rights -= 0x100; } // Since the multiplexor will enforce view-only, remove MESHRIGHT_REMOTEVIEWONLY
289
command.consent = 0;
290
if (typeof domain.userconsentflags == 'number') { command.consent |= domain.userconsentflags; } // Add server required consent flags
291
if (typeof mesh.consent == 'number') { command.consent |= mesh.consent; } // Add device group user consent
@@ -854,7 +856,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
856
}
857
858
// Rights check
857
- var requiredRights = null, requiredNonRights = null;
859
+ var requiredRights = null, requiredNonRights = null, routingOptions = null;
860
861
// Complete the nodeid if needed
862
if (command.nodeid.indexOf('/') == -1) { command.nodeid = 'node/' + domain.id + '/' + command.nodeid; }
@@ -876,6 +878,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
878
if (url.query.p == '1') { requiredNonRights = MESHRIGHT_NOTERMINAL; }
879
else if ((url.query.p == '4') || (url.query.p == '5')) { requiredNonRights = MESHRIGHT_NOFILES; }
880
881
+ // If we are using the desktop multiplexor, remove the VIEWONLY limitation. The multiplexor will take care of enforcing that limitation when needed.
882
+ if (((parent.parent.config.settings.desktopmultiplex === true) || (domain.desktopmultiplex === true)) && (url.query.p == '2')) { routingOptions = { removeViewOnlyLimitation: true }; }
883
+
884
// Add server TLS cert hash
885
var tlsCertHash = null;
886
if ((parent.parent.args.ignoreagenthashcheck == null) || (parent.parent.args.ignoreagenthashcheck === false)) { // TODO: If ignoreagenthashcheck is an array of IP addresses, not sure how to handle this.
@@ -910,7 +915,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
915
if (command.responseid != null) { func = function (r) { try { ws.send(JSON.stringify({ action: 'msg', result: r ? 'OK' : 'Unable to route', tag: command.tag, responseid: command.responseid })); } catch (ex) { } } }
916
917
// Route this command to a target node
913
- routeCommandToNode(command, requiredRights, requiredNonRights, func);
918
+ routeCommandToNode(command, requiredRights, requiredNonRights, func, routingOptions);
919
break;
920
}
921
case 'events':