diff --git a/agents/MeshCmd-signed.exe b/agents/MeshCmd-signed.exe index 85256a0a..5a43721e 100644 Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ diff --git a/agents/MeshCmd64-signed.exe b/agents/MeshCmd64-signed.exe index 2d4ccf3a..67502c5f 100644 Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ diff --git a/agents/MeshService-signed.exe b/agents/MeshService-signed.exe index 7dcbff2c..d95330f8 100644 Binary files a/agents/MeshService-signed.exe and b/agents/MeshService-signed.exe differ diff --git a/agents/MeshService.exe b/agents/MeshService.exe index acc61f2f..d300c71e 100644 Binary files a/agents/MeshService.exe and b/agents/MeshService.exe differ diff --git a/agents/MeshService64-signed.exe b/agents/MeshService64-signed.exe index 1c209b3c..f0357e1e 100644 Binary files a/agents/MeshService64-signed.exe and b/agents/MeshService64-signed.exe differ diff --git a/agents/MeshService64.exe b/agents/MeshService64.exe index 9298d169..27dea3f6 100644 Binary files a/agents/MeshService64.exe and b/agents/MeshService64.exe differ diff --git a/agents/meshcmd.js b/agents/meshcmd.js index 8c1225e9..22ec6bcf 100644 --- a/agents/meshcmd.js +++ b/agents/meshcmd.js @@ -342,9 +342,9 @@ function run(argv) { var amtMeiModule = require('amt-mei'); var amtMei = new amtMeiModule(); amtMei.on('error', function (e) { console.log('ERROR: ' + e); exit(1); return; }); - amtMei.getVersion(function (val) { for (var version in val.Versions) { if (val.Versions[version].Description == 'AMT') { mestate.ver = val.Versions[version].Version; } } }); - amtMei.getProvisioningState(function (result) { mestate.ProvisioningState = result; }); - amtMei.getProvisioningMode(function (result) { mestate.ProvisioningMode = result; }); + amtMei.getVersion(function (result) { if (result) { for (var version in result.Versions) { if (result.Versions[version].Description == 'AMT') { mestate.ver = result.Versions[version].Version; } } } }); + amtMei.getProvisioningState(function (result) { if (result) { mestate.ProvisioningState = result; } }); + amtMei.getProvisioningMode(function (result) { if (result) { mestate.ProvisioningMode = result; } }); amtMei.getEHBCState(function (result) { if (result) { mestate.ehbc = result; } }); amtMei.getControlMode(function (result) { if (result) { mestate.controlmode = result; } }); amtMei.getMACAddresses(function (result) { if (result) { mestate.mac = result; } }); @@ -352,24 +352,28 @@ function run(argv) { amtMei.getLanInterfaceSettings(1, function (result) { if (result) { mestate.net1 = result; } }); amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { mestate.uuid = result.uuid; } }); amtMei.getDnsSuffix(function (result) { - mestate.dns = result; - var str = 'Intel AMT v' + mestate.ver; - if (mestate.ProvisioningState.stateStr == 'PRE') { str += ', pre-provisioning state'; } - else if (mestate.ProvisioningState.stateStr == 'IN') { str += ', in-provisioning state'; } - else if (mestate.ProvisioningState.stateStr == 'POST') { - if (mestate.ProvisioningMode) { - if (mestate.controlmode) { - if (mestate.ProvisioningMode.modeStr == 'ENTERPRISE') { str += ', activated in ' + ["none", "client control mode", "admin control mode", "remote assistance mode"][mestate.controlmode.controlMode]; } else { str += ', activated in ' + mestate.ProvisioningMode.modeStr; } - } else { - str += ', activated in ' + mestate.ProvisioningMode.modeStr; + if (result) { mestate.dns = result; } + if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) { + var str = 'Intel AMT v' + mestate.ver; + if (mestate.ProvisioningState.stateStr == 'PRE') { str += ', pre-provisioning state'; } + else if (mestate.ProvisioningState.stateStr == 'IN') { str += ', in-provisioning state'; } + else if (mestate.ProvisioningState.stateStr == 'POST') { + if (mestate.ProvisioningMode) { + if (mestate.controlmode) { + if (mestate.ProvisioningMode.modeStr == 'ENTERPRISE') { str += ', activated in ' + ["none", "client control mode", "admin control mode", "remote assistance mode"][mestate.controlmode.controlMode]; } else { str += ', activated in ' + mestate.ProvisioningMode.modeStr; } + } else { + str += ', activated in ' + mestate.ProvisioningMode.modeStr; + } } } + if ((mestate.ehbc) && (mestate.ehbc.EHBC == true)) { str += ', EHBC enabled'; } + str += '.'; + if (mestate.net0 != null) { str += '\r\nWired ' + ((mestate.net0.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net0.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net0.mac + (mestate.net0.address == '0.0.0.0' ? '' : (', ' + mestate.net0.address)); } + if (mestate.net1 != null) { str += '\r\nWireless ' + ((mestate.net1.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net1.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net1.mac + (mestate.net1.address == '0.0.0.0' ? '' : (', ' + mestate.net1.address)); } + console.log(str + '.'); + } else { + console.log('Intel(R) AMT not supported.'); } - if ((mestate.ehbc) && (mestate.ehbc.EHBC == true)) { str += ', EHBC enabled'; } - str += '.'; - if (mestate.net0 != null) { str += '\r\nWired ' + ((mestate.net0.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net0.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net0.mac + (mestate.net0.address == '0.0.0.0' ? '' : (', ' + mestate.net0.address)); } - if (mestate.net1 != null) { str += '\r\nWireless ' + ((mestate.net1.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net1.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net1.mac + (mestate.net1.address == '0.0.0.0' ? '' : (', ' + mestate.net1.address)); } - console.log(str + '.'); exit(1); }); } else if (settings.action == 'amtinfodebug') { diff --git a/agents/modules_meshcore/linux-dbus.js b/agents/modules_meshcore/linux-dbus.js index 390bbfea..cdd6d82e 100644 --- a/agents/modules_meshcore/linux-dbus.js +++ b/agents/modules_meshcore/linux-dbus.js @@ -25,7 +25,7 @@ function dbus(address, uid) .createEvent('signal'); Object.defineProperty(this, "uid", { value: uid }); this._child = require('child_process').execFile("/bin/sh", ["sh"], { type: require('child_process').SpawnTypes.TERM, uid: uid == null ? -1 : uid }); - this._child.stdin.write('dbus-monitor --session "type=\'signal\', interface=\'' + address + '\'" | ( while true; do read X; echo "$X"; done )\n'); + this._child.stdin.write('dbus-monitor --session "type=\'signal\', interface=\'' + address + '\'" | ( while read X; do echo "$X"; done )\n'); this._child.stdout.dbus = this; this._child.stdout.on('data', function (chunk) { diff --git a/meshuser.js b/meshuser.js index c9696732..b5f611bd 100644 --- a/meshuser.js +++ b/meshuser.js @@ -86,7 +86,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) { req.session.currentNode = ''; } else { // Close the websocket connection - try { obj.ws.close(); } catch (e) { } return; + console.log('NOAUTH1'); + ws.send(JSON.stringify({ action: 'close', cause: 'noauth' })); + try { obj.ws.close(); } catch (e) { } + return; } } req.session.ws = obj.ws; // Associate this websocket session with the web session @@ -120,8 +123,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) { } }; - user.subscriptions = obj.parent.subscribe(user._id, ws); // Subscribe to events - obj.ws._socket.setKeepAlive(true, 240000); // Set TCP keep alive + user.subscriptions = obj.parent.subscribe(user._id, ws); // Subscribe to events + try { obj.ws._socket.setKeepAlive(true, 240000); } catch (ex) { } // Set TCP keep alive // Send current server statistics obj.SendServerStats = function () { @@ -329,7 +332,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) { command.sessionid = ws.sessionId; // Set the session id, required for responses. command.rights = rights.rights; // Add user rights flags to the message delete command.nodeid; // Remove the nodeid since it's implyed. - agent.send(JSON.stringify(command)); + try { agent.send(JSON.stringify(command)); } catch (ex) { } } } else { // Check if a peer server is connected to this agent @@ -601,7 +604,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) { // Get the list of sessions for this user var sessions = obj.parent.wssessions[command.userid]; - if (sessions != null) { for (i in sessions) { sessions[i].send(JSON.stringify(notification)); } } + if (sessions != null) { for (i in sessions) { try { sessions[i].send(JSON.stringify(notification)); } catch (ex) { } } } if (obj.parent.parent.multiServer != null) { // TODO: Add multi-server support @@ -925,7 +928,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) { var agent = obj.parent.wsagents[i]; if ((targetMeshes.indexOf(agent.dbMeshKey) >= 0) && (agent.authenticated == 2)) { //console.log('Asking agent ' + agent.dbNodeKey + ' to wake ' + macs.join(',')); - agent.send(JSON.stringify({ action: 'wakeonlan', macs: macs })); + try { agent.send(JSON.stringify({ action: 'wakeonlan', macs: macs })); } catch (ex) { } wakeActions++; } } @@ -966,7 +969,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) { var agent = obj.parent.wsagents[node._id]; if (agent != null) { // Send the power command - agent.send(JSON.stringify({ action: 'poweraction', actiontype: command.actiontype })); + try { agent.send(JSON.stringify({ action: 'poweraction', actiontype: command.actiontype })); } catch (ex) { } powerActions++; } } @@ -1004,7 +1007,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) { var agent = obj.parent.wsagents[node._id]; if (agent != null) { // Send the power command - agent.send(JSON.stringify({ action: 'toast', title: command.title, msg: command.msg })); + try { agent.send(JSON.stringify({ action: 'toast', title: command.title, msg: command.msg })); } catch (ex) { } } } } diff --git a/mpsserver.js b/mpsserver.js index 3ea365a1..8517636b 100644 --- a/mpsserver.js +++ b/mpsserver.js @@ -679,7 +679,7 @@ module.exports.CreateMpsServer = function (parent, db, args, certificates) { }; function ChangeHostname(socket, host) { - if (socket.tag.host == host) return; // Nothing to change + if (socket.tag.host === host) return; // Nothing to change socket.tag.host = host; // Change the device diff --git a/package.json b/package.json index 3aded37c..c81dc1c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.2.2-c", + "version": "0.2.2-d", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default.handlebars b/views/default.handlebars index 38f2ec44..a11a44cd 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -155,58 +155,59 @@

My Devices

-
-
 
-
-     -   -   - OS Name -
-
-     -   - Auto  -   -
-
-    - - -
-
-
-
 
- -
- Sort - -   -
-
- Size - -   -
-
-
+ + + + + + + + + +
+     +   +   + OS Name + +     +   + Auto  +   + +    + + + + +
+ Sort + +   +
+
+ Size + +   +
+
'; - if ((message.current == message.latest) || ((features & 2048) == 0)) { + if ((message.latest.indexOf('.') == -1) || (message.current == message.latest) || ((features & 2048) == 0)) { setDialogMode(2, "MeshCentral Version", 1, null, x); } else { setDialogMode(2, "MeshCentral Version", 3, server_showVersionDlgEx, x + '
Check and click OK to start server self-update.'); @@ -2595,6 +2594,7 @@ } catch (ex) { console.log(ex); QV('viewselectmapoption', false); + QV('devViewButton4', false); xxmap = null; } } @@ -6176,9 +6176,7 @@ for (var i in message.values) { x += '
' + i + '
'; for (var j in message.values[i]) { - x += '
'; - x += '
'; - x += '
' + j + '' + message.values[i][j] + '
'; + x += '
' + j + '' + message.values[i][j] + '
'; } } } diff --git a/webserver.js b/webserver.js index 4633ca21..24e2e601 100644 --- a/webserver.js +++ b/webserver.js @@ -214,7 +214,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { if (!module.parent) console.log('authenticating %s:%s:%s', domain.id, name, pass); var user = obj.users['user/' + domain.id + '/' + name.toLowerCase()]; // Query the db for the given username - if (!user) return fn(new Error('cannot find user')); + if (!user) { fn(new Error('cannot find user')); return; } // Apply the same algorithm to the POSTed password, applying the hash against the pass / salt, if there is a match we found the user if (user.salt == null) { fn(new Error('invalid password')); @@ -1803,7 +1803,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.app.post(url + 'amtevents.ashx', obj.handleAmtEventRequest); obj.app.get(url + 'webrelay.ashx', function (req, res) { res.send('Websocket connection expected'); }); obj.app.ws(url + 'webrelay.ashx', handleRelayWebSocket); - obj.app.ws(url + 'control.ashx', function (ws, req) { try { var domain = checkUserIpAddress(ws, req); if (domain != null) { obj.meshUserHandler.CreateMeshUser(obj, obj.db, ws, req, obj.args, domain); } } catch (e) { console.log(e); } }); obj.app.get(url + 'meshagents', obj.handleMeshAgentRequest); obj.app.get(url + 'meshosxagent', obj.handleMeshOsxAgentRequest); obj.app.get(url + 'meshsettings', obj.handleMeshSettingsRequest); @@ -1814,6 +1813,57 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.app.ws(url + 'echo.ashx', handleEchoWebSocket); obj.app.ws(url + 'meshrelay.ashx', function (ws, req) { try { obj.meshRelayHandler.CreateMeshRelay(obj, ws, req, getDomain(req)); } catch (e) { console.log(e); } }); + // User login + obj.app.ws(url + 'control.ashx', function (ws, req) { + try { + var domain = checkUserIpAddress(ws, req); + if (domain != null) { + var loginok = false; + // Check if the user is logged in + if ((!req.session) || (!req.session.userid) || (req.session.domainid != domain.id)) { + // If a default user is active, setup the session here. + if (obj.args.user && obj.users['user/' + domain.id + '/' + obj.args.user.toLowerCase()]) { + if (req.session && req.session.loginmode) { delete req.session.loginmode; } + req.session.userid = 'user/' + domain.id + '/' + obj.args.user.toLowerCase(); + req.session.domainid = domain.id; + req.session.currentNode = ''; + obj.meshUserHandler.CreateMeshUser(obj, obj.db, ws, req, obj.args, domain); // Accept the connection + loginok = true; + } else { + // See the the user/pass is provided in URL arguments + if ((req.query.user != null) && (req.query.pass != null)) { + loginok = true; + obj.authenticate(req.query.user, req.query.pass, domain, function (err, userid) { + var loginok2 = false; + if (err == null) { + var user = obj.users[userid]; + if (user) { + req.session.userid = userid; + req.session.domainid = domain.id; + req.session.currentNode = ''; + obj.meshUserHandler.CreateMeshUser(obj, obj.db, ws, req, obj.args, domain); // Accept the connection + loginok2 = true; + } + } + if (loginok2 == false) { + // Close the websocket connection + try { ws.send(JSON.stringify({ action: 'close', cause: 'noauth' })); ws.close(); } catch (e) { } + } + }); + } + } + } else { + obj.meshUserHandler.CreateMeshUser(obj, obj.db, ws, req, obj.args, domain); // Accept the connection + loginok = true; + } + if (loginok == false) { + // Close the websocket connection + try { ws.send(JSON.stringify({ action: 'close', cause: 'noauth' })); ws.close(); } catch (e) { } + } + } + } catch (e) { console.log(e); } + }); + // Server picture obj.app.get(url + 'serverpic.ashx', function (req, res) { // Check if we have "server.png" in the data folder, if so, use that.