1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 04:04:31 +00:00

The following updates, fix KVM for openSUSE and other distros with similar behavior

1. Removed 'setDisplay()' because it doesn't work
2. Added more descriptive error message when XOpenDisplay fails
3. Added ability to set XAUTHORITY in the child process if it wasn't set, by finding how X was started
This commit is contained in:
Bryan Roe
2019-01-24 11:19:33 -08:00
parent bf6e9ce1e0
commit 559928de5b
4 changed files with 67 additions and 47 deletions

View File

@@ -1,16 +1,25 @@
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = '';
child.stdin.write('ps -e -o user -o command | awk {\'printf "%s,",$1;$1="";printf "%s\\n", $0\'} | grep X\nexit\n');
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.waitExit();
var lines = child.stdout.str.split('\n');
for (var i in lines)
function getAuthToken()
{
var tokens = lines[i].split(',');
console.log(tokens[0] + ' => ' + tokens[1]);
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = '';
child.stdin.write('ps -e -o user -o command | awk {\'printf "%s,",$1;$1="";printf "%s\\n", $0\'} | grep X\nexit\n');
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.waitExit();
var lines = child.stdout.str.split('\n');
for (var i in lines) {
var tokens = lines[i].split(',');
if (tokens[0]) {
var items = tokens[1].split(' ');
for (var x = 0; x < items.length; ++x) {
if (items[x] == '-auth' && items.length > (x + 1)) {
return (items[x + 1]);
}
}
}
}
return (null);
}
//console.log(child.stdout.str);
console.log('AuthToken => ' + getAuthToken());
process.exit();