mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-01-06 18:43:46 +00:00
1. Fixed uncaught exception that occurs on linux when you logout/logon
2. Added timer on logon, to allow time for dbus session to start
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -431,10 +431,18 @@ function UserSessions()
|
|||||||
child.stdin.write("who | tr '\\n' '`' | awk -F'`' '" + '{ printf "{"; for(a=1;a<NF;++a) { n=split($a, tok, " "); printf "%s\\"%s\\": \\"%s\\"", (a>1?",":""), tok[2], tok[1]; } printf "}"; }\'\nexit\n');
|
child.stdin.write("who | tr '\\n' '`' | awk -F'`' '" + '{ printf "{"; for(a=1;a<NF;++a) { n=split($a, tok, " "); printf "%s\\"%s\\": \\"%s\\"", (a>1?",":""), tok[2], tok[1]; } printf "}"; }\'\nexit\n');
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
|
|
||||||
var ret = JSON.parse(child.stdout.str.trim());
|
var ret = {};
|
||||||
for (var key in ret)
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ret = JSON.parse(child.stdout.str.trim());
|
||||||
|
for (var key in ret)
|
||||||
|
{
|
||||||
|
ret[key] = { Username: ret[key], SessionId: key, State: 'Active', uid: this.getUid(ret[key]) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
{
|
{
|
||||||
ret[key] = { Username: ret[key], SessionId: key, State: 'Active', uid: this.getUid(ret[key]) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(ret, 'Active', { value: showActiveOnly(ret) });
|
Object.defineProperty(ret, 'Active', { value: showActiveOnly(ret) });
|
||||||
@@ -451,7 +459,8 @@ function UserSessions()
|
|||||||
if (require('fs').watch) {
|
if (require('fs').watch) {
|
||||||
this._linuxWatcher = require('fs').watch('/var/run/utmp');
|
this._linuxWatcher = require('fs').watch('/var/run/utmp');
|
||||||
this._linuxWatcher.user_session = this;
|
this._linuxWatcher.user_session = this;
|
||||||
this._linuxWatcher.on('change', function (a, b) {
|
this._linuxWatcher.on('change', function (a, b)
|
||||||
|
{
|
||||||
this.user_session.emit('changed');
|
this.user_session.emit('changed');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -529,7 +538,15 @@ function UserSessions()
|
|||||||
}
|
}
|
||||||
return (ret);
|
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.
|
this.on('changed', function ()
|
||||||
|
{
|
||||||
|
// For linux Lock/Unlock monitoring, we need to watch for LogOn/LogOff, and keep track of the UID.
|
||||||
|
this._changedTimeout = setTimeout(function (that)
|
||||||
|
{
|
||||||
|
// Doing this in a timeout, becuase there is a race between when logon is detected, and when dbus session is spawned
|
||||||
|
that._recheckLoggedInUsers.call(that);
|
||||||
|
}, 2000, this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.minUid = function minUid()
|
this.minUid = function minUid()
|
||||||
@@ -674,7 +691,15 @@ function UserSessions()
|
|||||||
child.stderr.str = ''; child.stderr.on('data', function(c){this.str += c.toString();});
|
child.stderr.str = ''; child.stderr.on('data', function(c){this.str += c.toString();});
|
||||||
child.stdin.write('ps -e -o pid -o user -o cmd ' + grep + ' |' + " tr '\n' '`' | awk -F'`' '{ " + 'printf "["; for(i=1;i<NF;++i) { split($i, tok, " "); printf "%s%s",(i!=1?",":""), tok[1]; } printf "]"; }\'\nexit\n');
|
child.stdin.write('ps -e -o pid -o user -o cmd ' + grep + ' |' + " tr '\n' '`' | awk -F'`' '{ " + 'printf "["; for(i=1;i<NF;++i) { split($i, tok, " "); printf "%s%s",(i!=1?",":""), tok[1]; } printf "]"; }\'\nexit\n');
|
||||||
child.waitExit();
|
child.waitExit();
|
||||||
return (JSON.parse(child.stdout.str.trim()));
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (JSON.parse(child.stdout.str.trim()));
|
||||||
|
}
|
||||||
|
catch(ee)
|
||||||
|
{
|
||||||
|
return([]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
this.findEnvEntry = function findEnvEntry(options)
|
this.findEnvEntry = function findEnvEntry(options)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user