mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 08:13:30 +00:00
1. Added 'getEnvFromPid' to user-sessions, to read environment vars by PID
2 Updated getXInfo() in monitor-info, so it'll try to get XAUTHORITY from env vars is it can't determine it by looking at the XServer instance.
This commit is contained in:
@@ -590,6 +590,30 @@ function UserSessions()
|
||||
child.waitExit();
|
||||
return (child.stdout.str.trim());
|
||||
};
|
||||
this.getEnvFromPid = function getEnvFromPid(pid)
|
||||
{
|
||||
var ret = {};
|
||||
var ps, psx, v, vs = 0;
|
||||
try
|
||||
{
|
||||
ps = require('fs').readFileSync('/proc/' + pid + '/environ');
|
||||
}
|
||||
catch(pse)
|
||||
{
|
||||
return (ret);
|
||||
}
|
||||
|
||||
for (psx = 0; psx < ps.length; ++psx)
|
||||
{
|
||||
if (ps[psx] == 0)
|
||||
{
|
||||
v = ps.slice(vs, psx).toString().split('=');
|
||||
ret[v[0]] = v[1];
|
||||
vs = psx + 1;
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
};
|
||||
|
||||
this.on('changed', this._recheckLoggedInUsers); // For linux Lock/Unlock monitoring, we need to watch for LogOn/LogOff, and keep track of the UID.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user