mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-24 06:05:53 -05:00
Fixed desktop tools
This commit is contained in:
parent
7aa41fbfc3
commit
fa5ce67e67
@ -31,8 +31,6 @@
|
|||||||
<Compile Include="agents\modules_meshcmd\amt-xml.js" />
|
<Compile Include="agents\modules_meshcmd\amt-xml.js" />
|
||||||
<Compile Include="agents\modules_meshcmd\amt.js" />
|
<Compile Include="agents\modules_meshcmd\amt.js" />
|
||||||
<Compile Include="agents\modules_meshcmd\process-manager.js" />
|
<Compile Include="agents\modules_meshcmd\process-manager.js" />
|
||||||
<Compile Include="agents\modules_meshcmd\serviceHost.js" />
|
|
||||||
<Compile Include="agents\modules_meshcmd\serviceManager.js" />
|
|
||||||
<Compile Include="agents\modules_meshcmd\smbios.js" />
|
<Compile Include="agents\modules_meshcmd\smbios.js" />
|
||||||
<Compile Include="agents\modules_meshcmd\user-sessions.js" />
|
<Compile Include="agents\modules_meshcmd\user-sessions.js" />
|
||||||
<Compile Include="agents\modules_meshcore\amt-lme.js" />
|
<Compile Include="agents\modules_meshcore\amt-lme.js" />
|
||||||
|
@ -14,11 +14,13 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// JavaScript source code
|
|
||||||
var GM = require('_GenericMarshal');
|
var GM = require('_GenericMarshal');
|
||||||
|
|
||||||
|
// Used on Windows and Linux to get information about running processes
|
||||||
function processManager() {
|
function processManager() {
|
||||||
this._ObjectID = 'processManager';
|
this._ObjectID = 'process-manager'; // Used for debugging, allows you to get the object type at runtime.
|
||||||
|
|
||||||
|
// Setup the platform specific calls.
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
this._kernel32 = GM.CreateNativeProxy('kernel32.dll');
|
this._kernel32 = GM.CreateNativeProxy('kernel32.dll');
|
||||||
@ -32,12 +34,16 @@ function processManager() {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw (process.platform + ' not supported');
|
throw (process.platform + ' not supported');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a object of: pid -> process information.
|
||||||
this.getProcesses = function getProcesses(callback) {
|
this.getProcesses = function getProcesses(callback) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
default:
|
default: // This is not a supported platform.
|
||||||
throw ('Enumerating processes on ' + process.platform + ' not supported');
|
throw ('Enumerating processes on ' + process.platform + ' not supported');
|
||||||
case 'win32':
|
break;
|
||||||
|
case 'win32': // Windows processes
|
||||||
var retVal = {};
|
var retVal = {};
|
||||||
var h = this._kernel32.CreateToolhelp32Snapshot(2, 0);
|
var h = this._kernel32.CreateToolhelp32Snapshot(2, 0);
|
||||||
var info = GM.CreateVariable(304);
|
var info = GM.CreateVariable(304);
|
||||||
@ -49,7 +55,7 @@ function processManager() {
|
|||||||
}
|
}
|
||||||
if (callback) { callback.apply(this, [retVal]); }
|
if (callback) { callback.apply(this, [retVal]); }
|
||||||
break;
|
break;
|
||||||
case 'linux':
|
case 'linux': // Linux processes
|
||||||
if (!this._psp) { this._psp = {}; }
|
if (!this._psp) { this._psp = {}; }
|
||||||
var p = this._childProcess.execFile("/bin/ps", ["ps", "-uxa"], { type: this._childProcess.SpawnTypes.TERM });
|
var p = this._childProcess.execFile("/bin/ps", ["ps", "-uxa"], { type: this._childProcess.SpawnTypes.TERM });
|
||||||
this._psp[p.pid] = p;
|
this._psp[p.pid] = p;
|
||||||
@ -68,8 +74,8 @@ function processManager() {
|
|||||||
if (i == 0 && tokens[x]) { key[tokens[x]] = keyi++; }
|
if (i == 0 && tokens[x]) { key[tokens[x]] = keyi++; }
|
||||||
if (i > 0 && tokens[x]) { tokenList.push(tokens[x]); }
|
if (i > 0 && tokens[x]) { tokenList.push(tokens[x]); }
|
||||||
}
|
}
|
||||||
if ((i > 0) && (tokenList[key.PID])) {
|
if (i > 0) {
|
||||||
retVal[tokenList[key.PID]] = { user: tokenList[key.USER], cmd: tokenList[key.COMMAND] };
|
if (tokenList[key.PID]) { retVal[tokenList[key.PID]] = { user: tokenList[key.USER], cmd: tokenList[key.COMMAND] }; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.callback) {
|
if (this.callback) {
|
||||||
@ -81,18 +87,23 @@ function processManager() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get information about a specific process on Linux
|
||||||
this.getProcessInfo = function getProcessInfo(pid) {
|
this.getProcessInfo = function getProcessInfo(pid) {
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
default:
|
default:
|
||||||
throw ('getProcessInfo() not supported for ' + process.platform);
|
throw ('getProcessInfo() not supported for ' + process.platform);
|
||||||
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
var status = require('fs').readFileSync('/proc/' + pid + '/status'), info = {}, lines = status.toString().split('\n');
|
var status = require('fs').readFileSync('/proc/' + pid + '/status');
|
||||||
|
var info = {}, lines = status.toString().split('\n');
|
||||||
for (var i in lines) {
|
for (var i in lines) {
|
||||||
var tokens = lines[i].split(':');
|
var tokens = lines[i].split(':');
|
||||||
if (tokens.length > 1) { tokens[1] = tokens[1].trim(); }
|
if (tokens.length > 1) { tokens[1] = tokens[1].trim(); }
|
||||||
info[tokens[0]] = tokens[1];
|
info[tokens[0]] = tokens[1];
|
||||||
}
|
}
|
||||||
return (info);
|
return (info);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,14 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
var GM = require('_GenericMarshal');
|
var GM = require('_GenericMarshal');
|
||||||
|
|
||||||
function processManager()
|
// Used on Windows and Linux to get information about running processes
|
||||||
{
|
function processManager() {
|
||||||
this._ObjectID = 'process-manager';
|
this._ObjectID = 'process-manager'; // Used for debugging, allows you to get the object type at runtime.
|
||||||
switch(process.platform)
|
|
||||||
{
|
// Setup the platform specific calls.
|
||||||
|
switch (process.platform) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
this._kernel32 = GM.CreateNativeProxy('kernel32.dll');
|
this._kernel32 = GM.CreateNativeProxy('kernel32.dll');
|
||||||
this._kernel32.CreateMethod('GetLastError');
|
this._kernel32.CreateMethod('GetLastError');
|
||||||
@ -36,27 +36,26 @@ function processManager()
|
|||||||
throw (process.platform + ' not supported');
|
throw (process.platform + ' not supported');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.getProcesses = function getProcesses(callback)
|
|
||||||
{
|
// Return a object of: pid -> process information.
|
||||||
switch(process.platform)
|
this.getProcesses = function getProcesses(callback) {
|
||||||
{
|
switch (process.platform) {
|
||||||
default:
|
default: // This is not a supported platform.
|
||||||
throw ('Enumerating processes on ' + process.platform + ' not supported');
|
throw ('Enumerating processes on ' + process.platform + ' not supported');
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32': // Windows processes
|
||||||
var retVal = [];
|
var retVal = {};
|
||||||
var h = this._kernel32.CreateToolhelp32Snapshot(2, 0);
|
var h = this._kernel32.CreateToolhelp32Snapshot(2, 0);
|
||||||
var info = GM.CreateVariable(304);
|
var info = GM.CreateVariable(304);
|
||||||
info.toBuffer().writeUInt32LE(304, 0);
|
info.toBuffer().writeUInt32LE(304, 0);
|
||||||
var nextProcess = this._kernel32.Process32First(h, info);
|
var nextProcess = this._kernel32.Process32First(h, info);
|
||||||
while (nextProcess.Val)
|
while (nextProcess.Val) {
|
||||||
{
|
retVal[info.Deref(8, 4).toBuffer().readUInt32LE(0)] = { cmd: info.Deref(GM.PointerSize == 4 ? 36 : 44, 260).String };
|
||||||
retVal.push({ pid: info.Deref(8, 4).toBuffer().readUInt32LE(0), command: info.Deref(GM.PointerSize == 4 ? 36 : 44, 260).String });
|
|
||||||
nextProcess = this._kernel32.Process32Next(h, info);
|
nextProcess = this._kernel32.Process32Next(h, info);
|
||||||
}
|
}
|
||||||
if (callback) { callback.apply(this, [retVal]); }
|
if (callback) { callback.apply(this, [retVal]); }
|
||||||
break;
|
break;
|
||||||
case 'linux':
|
case 'linux': // Linux processes
|
||||||
if (!this._psp) { this._psp = {}; }
|
if (!this._psp) { this._psp = {}; }
|
||||||
var p = this._childProcess.execFile("/bin/ps", ["ps", "-uxa"], { type: this._childProcess.SpawnTypes.TERM });
|
var p = this._childProcess.execFile("/bin/ps", ["ps", "-uxa"], { type: this._childProcess.SpawnTypes.TERM });
|
||||||
this._psp[p.pid] = p;
|
this._psp[p.pid] = p;
|
||||||
@ -65,32 +64,21 @@ function processManager()
|
|||||||
p.callback = callback;
|
p.callback = callback;
|
||||||
p.args = [];
|
p.args = [];
|
||||||
for (var i = 1; i < arguments.length; ++i) { p.args.push(arguments[i]); }
|
for (var i = 1; i < arguments.length; ++i) { p.args.push(arguments[i]); }
|
||||||
p.on('exit', function onGetProcesses()
|
p.on('exit', function onGetProcesses() {
|
||||||
{
|
delete this.Parent._psp[this.pid];
|
||||||
delete this.Parent._psp[this.pid];
|
var retVal = {}, lines = this.ps.split('\x0D\x0A'), key = {}, keyi = 0;
|
||||||
var retVal = [];
|
for (var i in lines) {
|
||||||
var lines = this.ps.split('\x0D\x0A');
|
|
||||||
var key = {};
|
|
||||||
var keyi = 0;
|
|
||||||
for (var i in lines)
|
|
||||||
{
|
|
||||||
var tokens = lines[i].split(' ');
|
var tokens = lines[i].split(' ');
|
||||||
var tokenList = [];
|
var tokenList = [];
|
||||||
for(var x in tokens)
|
for (var x in tokens) {
|
||||||
{
|
|
||||||
if (i == 0 && tokens[x]) { key[tokens[x]] = keyi++; }
|
if (i == 0 && tokens[x]) { key[tokens[x]] = keyi++; }
|
||||||
if (i > 0 && tokens[x]) { tokenList.push(tokens[x]);}
|
if (i > 0 && tokens[x]) { tokenList.push(tokens[x]); }
|
||||||
}
|
}
|
||||||
if(i>0)
|
if (i > 0) {
|
||||||
{
|
if (tokenList[key.PID]) { retVal[tokenList[key.PID]] = { user: tokenList[key.USER], cmd: tokenList[key.COMMAND] }; }
|
||||||
if (tokenList[key.PID])
|
|
||||||
{
|
|
||||||
retVal.push({ pid: tokenList[key.PID], user: tokenList[key.USER], command: tokenList[key.COMMAND] });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.callback)
|
if (this.callback) {
|
||||||
{
|
|
||||||
this.args.unshift(retVal);
|
this.args.unshift(retVal);
|
||||||
this.callback.apply(this.parent, this.args);
|
this.callback.apply(this.parent, this.args);
|
||||||
}
|
}
|
||||||
@ -99,19 +87,17 @@ function processManager()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.getProcessInfo = function getProcessInfo(pid)
|
|
||||||
{
|
// Get information about a specific process on Linux
|
||||||
switch(process.platform)
|
this.getProcessInfo = function getProcessInfo(pid) {
|
||||||
{
|
switch (process.platform) {
|
||||||
default:
|
default:
|
||||||
throw ('getProcessInfo() not supported for ' + process.platform);
|
throw ('getProcessInfo() not supported for ' + process.platform);
|
||||||
break;
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
var status = require('fs').readFileSync('/proc/' + pid + '/status');
|
var status = require('fs').readFileSync('/proc/' + pid + '/status');
|
||||||
var info = {};
|
var info = {}, lines = status.toString().split('\n');
|
||||||
var lines = status.toString().split('\n');
|
for (var i in lines) {
|
||||||
for(var i in lines)
|
|
||||||
{
|
|
||||||
var tokens = lines[i].split(':');
|
var tokens = lines[i].split(':');
|
||||||
if (tokens.length > 1) { tokens[1] = tokens[1].trim(); }
|
if (tokens.length > 1) { tokens[1] = tokens[1].trim(); }
|
||||||
info[tokens[0]] = tokens[1];
|
info[tokens[0]] = tokens[1];
|
||||||
|
@ -1522,7 +1522,7 @@
|
|||||||
QV('NoMeshesPanel', meshcount == 0);
|
QV('NoMeshesPanel', meshcount == 0);
|
||||||
QV('devListToolbarView', (meshcount != 0) && (nodes.length > 0));
|
QV('devListToolbarView', (meshcount != 0) && (nodes.length > 0));
|
||||||
QV('devListToolbarSort', (meshcount != 0) && (nodes.length > 0) && (view < 4));
|
QV('devListToolbarSort', (meshcount != 0) && (nodes.length > 0) && (view < 4));
|
||||||
if ((meshcount == 0) || (nodes.length == 0)) { view = 1; }
|
if ((meshcount == 0) || (nodes.length == 0)) { view = 1; sort = 0; }
|
||||||
if (view == 4) {
|
if (view == 4) {
|
||||||
setTimeout( function() { if (xxmap.map != null) { xxmap.map.updateSize(); } }, 200);
|
setTimeout( function() { if (xxmap.map != null) { xxmap.map.updateSize(); } }, 200);
|
||||||
// TODO
|
// TODO
|
||||||
@ -3711,7 +3711,6 @@
|
|||||||
if (Q('DeskTools').nodeid != message.nodeid) return;
|
if (Q('DeskTools').nodeid != message.nodeid) return;
|
||||||
var p = [], processes = null;
|
var p = [], processes = null;
|
||||||
try { processes = JSON.parse(message.value); } catch (e) { }
|
try { processes = JSON.parse(message.value); } catch (e) { }
|
||||||
console.log(processes);
|
|
||||||
if (processes != null) {
|
if (processes != null) {
|
||||||
for (var pid in processes) { p.push( { p:parseInt(pid), c:processes[pid].cmd, d:processes[pid].cmd.toLowerCase(), u: processes[pid].user } ); }
|
for (var pid in processes) { p.push( { p:parseInt(pid), c:processes[pid].cmd, d:processes[pid].cmd.toLowerCase(), u: processes[pid].user } ); }
|
||||||
if (deskTools.sort == 0) { p.sort(sortProcessPid); } else if (deskTools.sort == 1) { p.sort(sortProcessName); }
|
if (deskTools.sort == 0) { p.sort(sortProcessPid); } else if (deskTools.sort == 1) { p.sort(sortProcessName); }
|
||||||
|
@ -653,7 +653,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
obj.users[req.session.userid] = { type: 'user', _id: req.session.userid, name: '~', email: '~', domain: domain.id, siteadmin: 0xFFFFFFFF };
|
obj.users[req.session.userid] = { type: 'user', _id: req.session.userid, name: '~', email: '~', domain: domain.id, siteadmin: 0xFFFFFFFF };
|
||||||
obj.db.SetUser(obj.users[req.session.userid]);
|
obj.db.SetUser(obj.users[req.session.userid]);
|
||||||
}
|
}
|
||||||
} else if (obj.args.user && (!req.session || !req.session.userid) && obj.users['user/' + domain.id + '/' + obj.args.user.toLowerCase()]) {
|
} else if (obj.args.user && obj.users['user/' + domain.id + '/' + obj.args.user.toLowerCase()]) {
|
||||||
// If a default user is active, setup the session here.
|
// If a default user is active, setup the session here.
|
||||||
if (req.session && req.session.loginmode) { delete req.session.loginmode; }
|
if (req.session && req.session.loginmode) { delete req.session.loginmode; }
|
||||||
req.session.userid = 'user/' + domain.id + '/' + obj.args.user.toLowerCase();
|
req.session.userid = 'user/' + domain.id + '/' + obj.args.user.toLowerCase();
|
||||||
|
Loading…
Reference in New Issue
Block a user