From e89effac46ac1d659eeeed27991c16a12f91047e Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 5 Jul 2022 14:25:38 -0700 Subject: [PATCH] Added options to remove the SSH Connect and SFTP connect from the terminal and files tab when other options exist, #4214 --- meshcentral-config-schema.json | 10 +++++++++- views/default.handlebars | 4 ++-- webserver.js | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index 09153ca4..544fbfc1 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -616,10 +616,18 @@ "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." } } }, + "files": { + "type": "object", + "description": "Values that affect the files feature", + "properties": { + "sftpConnect" : { "type": "boolean", "default": true, "description": "When false, removes the 'SFTP Connect' button from the files tab unless this is the only possible option." } + } + }, "terminal": { "type": "object", "description": "Values that affect the terminal feature", "properties": { + "sshConnect" : { "type": "boolean", "default": true, "description": "When false, removes the 'SSH Connect' button from the terminal tab unless this is the only possible option." }, "linuxShell": { "type": "string", "enum": [ "any", "root", "user", "login" ], @@ -637,7 +645,7 @@ }, "desktop": { "type": "object", - "description": "Values that affect the remote desktop feature", + "description": "Values that affect the desktop feature", "properties": { "viewonly": { "type": "boolean", diff --git a/views/default.handlebars b/views/default.handlebars index 6c722c92..037fcfc6 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -9726,7 +9726,7 @@ // Show the right buttons QV('disconnectbutton2span', (termState == true)); QV('connectbutton2span', (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.mtype != 3)); - QV('connectbutton2sspan', (features2 & 0x00000200) && (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.agent.id != 3) && (terminalNode.agent.id != 4)); + QV('connectbutton2sspan', (features2 & 0x00000200) && (termState == false) && (terminalNode.agent != null) && (terminalNode.agent.caps & 2) && (terminalNode.agent.id != 3) && (terminalNode.agent.id != 4) && ((features2 & 0x1000000) == 0)); if (terminalNode.mtype == 1) { QV('connectbutton2hspan', (termState == false) && (terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2)); QV('terminalSizeDropDown', (termState == false) && (terminalNode.intelamt != null) && (terminalNode.intelamt.state == 2)); @@ -10160,7 +10160,7 @@ QE('p13Connect', online); QE('p13Connects', online); QV('p13Connect', (files == null) && (filesNode.mtype == 2)); - QV('p13Connects', (files == null) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4)); + QV('p13Connects', (features2 & 0x200) && (files == null) && (filesNode.agent != null) && (filesNode.agent.id != 3) && (filesNode.agent.id != 4) && ((features2 & 0x800000) == 0)); QV('p13Disconnect', files != null); if (((samenode == false) || (online == false)) && files) { files.Stop(); files = null; } p13setActions(); diff --git a/webserver.js b/webserver.js index 6faf5ed4..fbf20ddd 100644 --- a/webserver.js +++ b/webserver.js @@ -2977,6 +2977,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF if (domain.nightmode === 1) { features2 += 0x00100000; } // Always night mode if (domain.nightmode === 2) { features2 += 0x00200000; } // Always day mode if (domain.allowsavingdevicecredentials == false) { features2 += 0x00400000; } // Do not allow device credentials to be saved on the server + if ((typeof domain.files == 'object') && (domain.files.sftpconnect === false)) { features2 += 0x00800000; } // Remove the "SFTP Connect" button in the "Files" tab when the device is agent managed + if ((typeof domain.terminal == 'object') && (domain.terminal.sshconnect === false)) { features2 += 0x01000000; } // Remove the "SSH Connect" button in the "Terminal" tab when the device is agent managed return { features: features, features2: features2 }; }