Added option to remove guest sharing links.

Ylian Saint-Hilaire committed Jan 20, 2021 at 00:26 UTC ceedd0c7567466cd3c212dc98eeeed90f04a7b46
7 files changed +12 -4
agents/hashagents.js
+1 -1
@@ -12,7 +12,7 @@ var agents = {
12 'meshagent_osx-x86-64': 16,
13 'meshagent_poky64': 18,
14 'meshagent_x86_nokvm': 19,
15 - 'meshagent_x86-64_nokvm': 20,
15 + 'meshagent_x86-64_nokvm': 20,
16 'meshagent_arm-linaro': 24,
17 'meshagent_armhf': 25,
18 'meshagent_arm64': 26,
agents/meshcore.js
+1 -1
@@ -979,7 +979,7 @@ function createMeshCore(agent) {
979 }
980 case 'setclip': {
981 // Set the load clipboard to a user value
982 - //sendConsoleText('setClip: ' + JSON.stringify(data));
982 + sendConsoleText('setClip: ' + JSON.stringify(data));
983 if (typeof data.data == 'string') {
984 MeshServerLogEx(22, [data.data.length], "Setting clipboard content, " + data.data.length + " byte(s)", data);
985 if (require('MeshAgent').isService) { require('clipboard').dispatchWrite(data.data); } else { require("clipboard")(data.data); } // Set the clipboard
meshcentral-config-schema.json
+2 -1
@@ -167,7 +167,7 @@
167 "meshQuota": { "type": "integer" },
168 "loginKey": { "type": [ "string", "array" ], "items": { "type": "string" }, "default": null, "description": "Requires that users add the value ?key=xxx in the URL in order to see the web site." },
169 "minify": { "type": "boolean", "default": false, "description": "When enabled, the server will send reduced sided web pages." },
170 - "newAccounts": { "type": "boolean" },
170 + "newAccounts": { "type": "boolean", "default": false, "description": "When set to true, allow new user accounts to be created from the login page." },
171 "newAccountsUserGroups": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
172 "userNameIsEmail": { "type": "boolean", "default": false, "description": "When enabled, the username of each account is also the email address of the account." },
173 "newAccountEmailDomains": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
@@ -177,6 +177,7 @@
177 "hide": { "type": "integer", "default": 0 },
178 "footer": { "type": "string", "default": null, "description": "This is a HTML string displayed at the bottom of the web page when a user is logged in." },
179 "loginfooter": { "type": "string", "default": null, "description": "This is a HTML string displayed at the bottom of the web page when a user is not logged in." },
180 + "guestDeviceSharing": { "type": "boolean", "default": true, "description": "When set to false, the desktop/terminal sharing link feature is not available." },
181 "certUrl": {
182 "type": "string",
183 "format": "uri",
meshuser.js
+4
@@ -460,6 +460,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
460 }
461 serverinfo.https = true;
462 serverinfo.redirport = args.redirport;
463 + if (domain.guestdevicesharing === false) { serverinfo.guestdevicesharing = false; }
464 if (typeof domain.userconsentflags == 'number') { serverinfo.consent = domain.userconsentflags; }
465 if ((typeof domain.usersessionidletimeout == 'number') && (domain.usersessionidletimeout > 0)) { serverinfo.timeout = (domain.usersessionidletimeout * 60 * 1000); }
466 if (user.siteadmin === SITERIGHT_ADMIN) {
@@ -4682,6 +4683,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4683 break;
4684 }
4685 case 'deviceShares': {
4686 + if (domain.guestdevicesharing === false) return; // This feature is not allowed.
4687 var err = null;
4688
4689 // Argument validation
@@ -4733,6 +4735,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4735 break;
4736 }
4737 case 'removeDeviceShare': {
4738 + if (domain.guestdevicesharing === false) return; // This feature is not allowed.
4739 var err = null;
4740
4741 // Argument validation
@@ -4797,6 +4800,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4800 break;
4801 }
4802 case 'createDeviceShareLink': {
4803 + if (domain.guestdevicesharing === false) return; // This feature is not allowed.
4804 var err = null;
4805
4806 // Argument validation
sample-config-advanced.json
+1
@@ -127,6 +127,7 @@
127 "_userQuota": 1048576,
128 "_meshQuota": 248576,
129 "minify": true,
130 + "_guestDeviceSharing" : false,
131 "_loginKey": [ "abc", "123" ],
132 "_newAccounts": true,
133 "_newAccountsUserGroups": [ "ugrp//xxxxxxxxxxxxxxxxx" ],
views/default.handlebars
+1 -1
@@ -5961,7 +5961,7 @@
5961 x += '<input type=button value="' + "Log Event" + '" title="' + "Write an event for this device" + '" onclick=writeDeviceEvent("' + encodeURIComponentEx(node._id) + '") />';
5962 if ((connectivity & 1) && (meshrights & 8) && (node.agent.id != 14)) { x += '<input type=button value="' + "Message" + '" title="' + "Display a text message on the remote device" + '" onclick=deviceMessageFunction() />'; }
5963 //if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast title="' + "Display a text message of the remote device" + '" onclick=deviceToastFunction() />'; }
5964 - if ((node.agent!=null) && (node.agent.caps & 3) && (connectivity & 1) && (meshrights & 8) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 4352) == 0))) { x += '<input type=button value="' + "Share" + '" title="' + "Create a link to share this device with a guest" + '" onclick=showShareDevice() />'; }
5964 + if ((serverinfo.guestdevicesharing !== false) && (node.agent != null) && (node.agent.caps & 3) && (connectivity & 1) && (meshrights & 8) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 4352) == 0))) { x += '<input type=button value="' + "Share" + '" title="' + "Create a link to share this device with a guest" + '" onclick=showShareDevice() />'; }
5965
5966 // Custom UI
5967 if ((customui != null) && (customui.devicebuttons != null)) {
webserver.js
+2
@@ -3033,6 +3033,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3033 const domain = getDomain(req, res);
3034 if (domain == null) { return; }
3035 if (req.query.c == null) { res.sendStatus(404); return; }
3036 + if (domain.guestdevicesharing === false) { res.sendStatus(404); return; } // This feature is not allowed.
3037
3038 // Check the inbound desktop sharing cookie
3039 var c = obj.parent.decodeCookie(req.query.c, obj.parent.invitationLinkEncryptionKey, 60); // 60 minute timeout
@@ -3071,6 +3072,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3072 const domain = getDomain(req, res);
3073 if (domain == null) { return; }
3074 if (req.query.c == null) { res.sendStatus(404); return; }
3075 + if (domain.guestdevicesharing === false) { res.sendStatus(404); return; } // This feature is not allowed.
3076
3077 // Check the inbound desktop sharing cookie
3078 var c = obj.parent.decodeCookie(req.query.c, obj.parent.invitationLinkEncryptionKey, 60); // 60 minute timeout