Added domain wide terminal shell option.
Ylian Saint-Hilaire committed
Jan 20, 2021 at 12:43 UTC
921e610d19bf54098ac20fb52239e2c009244087
5 files changed
+37
-3
amtmanager.js
+2
@@ -869,6 +869,8 @@ module.exports.CreateAmtManager = function (parent) {
869
if (domain.amtmanager.tlsrootcert2 != null) {
870
xxCaPrivateKey = domain.amtmanager.tlsrootcert2.key;
871
issuerattributes = domain.amtmanager.tlsrootcert2.attributes;
872
+ // TODO: We should change the start and end dates of our issued certificate to at least match the root.
873
+ // TODO: We could do one better and auto-renew TLS certificates as needed.
874
}
875
876
// Set the extended key usages
meshcentral-config-schema.json
+11
@@ -302,6 +302,17 @@
302
"MaxSingleUserSessions": { "type": "integer" }
303
}
304
},
305
+ "terminal": {
306
+ "type": "object",
307
+ "description": "Values that affect the terminal feature",
308
+ "properties": {
309
+ "linuxshell": {
310
+ "type": "string",
311
+ "enum": [ "any", "root", "user", "login" ],
312
+ "default": "any"
313
+ }
314
+ }
315
+ },
316
"amtManager": {
317
"type": "object",
318
"additionalProperties": false,
meshuser.js
+3
@@ -467,6 +467,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
467
if (parent.parent.config.settings.managealldevicegroups.indexOf(user._id) >= 0) { serverinfo.manageAllDeviceGroups = true; }
468
if (obj.crossDomain === true) { serverinfo.crossDomain = []; for (var i in parent.parent.config.domains) { serverinfo.crossDomain.push(i); } }
469
}
470
+ if (typeof domain.terminal == 'object') { // Settings used for remote terminal feature
471
+ if ((typeof domain.terminal.linuxshell == 'string') && (domain.terminal.linuxshell != 'any')) { serverinfo.linuxshell = domain.terminal.linuxshell; }
472
+ }
473
474
// Send server information
475
try { ws.send(JSON.stringify({ action: 'serverinfo', serverinfo: serverinfo })); } catch (ex) { }
translate/translate.json
+7
-1
@@ -22819,6 +22819,12 @@
22819
"default.handlebars->31->1820"
22820
]
22821
},
22822
+ {
22823
+ "en": "Lock the remote computer",
22824
+ "xloc": [
22825
+ "default.handlebars->container->column_l->p11->deskarea0->deskarea4->1"
22826
+ ]
22827
+ },
22828
{
22829
"cs": "Zamknuto",
22830
"de": "Gesperrt",
@@ -46237,4 +46243,4 @@
46243
]
46244
}
46245
]
46240
-}
46246
+}
\ No newline at end of file
views/default.handlebars
+14
-2
@@ -4856,6 +4856,10 @@
4856
case 'termConnectButton': {
4857
// Terminal connect button context menu
4858
if ((currentNode == null) || (currentNode.agent == null)) return true;
4859
+
4860
+ // If the server has a specific terminal shell mode, don't show connection options
4861
+ if (serverinfo.linuxshell && (currentNode.agent.id > 4)) return;
4862
+
4863
contextelement = elem;
4864
var contextmenudiv = document.getElementById('termShellContextMenu'); // Windows options (Power Shell)
4865
if (currentNode.agent.id > 4) { contextmenudiv = document.getElementById('termShellContextMenuLinux'); } // Non-Windows options
@@ -8060,6 +8064,13 @@
8064
}
8065
}
8066
8067
+ // If the server requires a shell type
8068
+ if ((serverinfo.linuxshell) != null && (currentNode.agent.id > 4)) {
8069
+ if (serverinfo.linuxshell == 'root') { termoptions.protocol = 1; delete termoptions.requireLogin; }
8070
+ if (serverinfo.linuxshell == 'user') { termoptions.protocol = 8; delete termoptions.requireLogin; }
8071
+ if (serverinfo.linuxshell == 'login') { termoptions.protocol = 1; termoptions.requireLogin = true; }
8072
+ }
8073
+
8074
if (args.xterm !== 0) {
8075
// Setup a mesh agent xterm terminal
8076
QV('termarea3xdiv', true);
@@ -8081,11 +8092,12 @@
8092
});
8093
8094
// Setup a terminal tunnel to the agent
8084
- terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel(tunnelUpdate, options), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
8095
+ terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel(tunnelUpdate, termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
8096
terminal.debugmode = debugmode;
8097
terminal.m.debugmode = debugmode;
8098
+ terminal.options = termoptions;
8099
terminal.options = { cols: xterm.cols, rows: xterm.rows };
8088
- if (options && options.requireLogin) { terminal.options.requireLogin = true; }
8100
+ if (termoptions.requireLogin) { terminal.options.requireLogin = true; }
8101
terminal.Start(terminalNode._id);
8102
terminal.onStateChanged = onTerminalStateChange;
8103
terminal.contype = 1;