mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 00:03:45 +00:00
Updated installer to save ID of user that installed agent
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -22,9 +22,20 @@ function installService(params)
|
||||
if (process.platform == 'win32')
|
||||
{
|
||||
proxyFile = proxyFile.split('.exe').join('.proxy');
|
||||
params.push('--installedByUser="' + require('win-registry').usernameToUserKey(require('user-sessions').getProcessOwnerName(process.pid).name) + '"');
|
||||
}
|
||||
else
|
||||
{
|
||||
var u = require('user-sessions').tty();
|
||||
var uid = 0;
|
||||
try
|
||||
{
|
||||
uid = require('user-sessions').getUid(u);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
}
|
||||
params.push('--installedByUser=' + uid);
|
||||
proxyFile += '.proxy';
|
||||
}
|
||||
|
||||
|
||||
@@ -969,6 +969,17 @@ function UserSessions()
|
||||
|
||||
if(process.platform != 'win32') // Linux, MacOS, FreeBSD
|
||||
{
|
||||
this.tty = function tty()
|
||||
{
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh'], { type: require('child_process').SpawnTypes.TERM });
|
||||
child.stdout.str = ''; child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
|
||||
child.stdin.write("tty | awk -F/ '{ printf \"\\x1e%s\\x1e\",$2; }'\nexit\n");
|
||||
child.stdin.write("tty\nexit\n");
|
||||
child.waitExit();
|
||||
|
||||
var val = child.stdout.str.split('\x1e');
|
||||
return (val.length > 1 ? val[1] : 'root');
|
||||
}
|
||||
this.Self = function Self()
|
||||
{
|
||||
var child = require('child_process').execFile('/usr/bin/id', ['id', '-u']);
|
||||
|
||||
Reference in New Issue
Block a user