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

Updated linux/freebsd user-sessions.consoleUid() to skip users logged in on a pseudo console.

This commit is contained in:
Bryan Roe
2020-05-31 22:12:07 -07:00
parent 6609e23f78
commit c97a58f037
2 changed files with 18 additions and 8 deletions

View File

@@ -557,7 +557,17 @@ function UserSessions()
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.stderr.str = ''; child.stderr.on('data', function (chunk) { this.str += chunk.toString(); });
child.stdin.write("who | tr '\\n' '\`' | awk '{ print $1 }'\nexit\n");
child.stdin.write("who | tr '\\n' '`' | awk -F'`' '{");
child.stdin.write(" for(i=1;i<NF;++i) ");
child.stdin.write(" { ");
child.stdin.write(' split($i,tok," "); x=split(tok[2],itm,"pts"); ');
child.stdin.write(' if(x==1) ');
child.stdin.write(' { ');
child.stdin.write(' print tok[1]; ');
child.stdin.write(' break; ');
child.stdin.write(' }');
child.stdin.write(' }');
child.stdin.write("}'\nexit\n");
child.waitExit();
if (child.stderr.str != '') { return (0); }