1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Description: Use consolekit to find console users if 'who' do not find anyone.
Use ck-list-sessions to find the console users of 'who' have none
listed.
Author: Petter Reinholdtsen <pere@debian.org>
Bug-Debian: http://bugs.debian.org/714428
Last-Update: 2014-09-28
Index: killer-git/killer
===================================================================
--- killer-git.orig/killer 2014-09-28 19:39:33.121975224 +0200
+++ killer-git/killer 2014-09-28 19:40:31.302428667 +0200
@@ -890,23 +890,48 @@
$consoleuser = "";
- open ( W, "$whocmd|") || return;
-
- while ( <W> ) {
- chop;
- @parts = split(/[ \t]+/);
- if ( $parts[1] eq 'console'
- || $parts[1] =~ '^:\d+$' # kdm
- || $parts[1] =~ '^tty\d$' # gdm
- ) {
- $consoleuser = $parts[0];
- $tty2idletime{$parts[1]}=0; # do not kill processes for the console user (set idle time to 0)
- push (@{$user2ttys{$consoleuser}}, $parts[1]);
- } else {
- $self->initializeTty($parts[1], stat("/dev/" . $parts[1]));
+ if (open ( W, "$whocmd|")) {
+ while ( <W> ) {
+ chop;
+ @parts = split(/[ \t]+/);
+ if ( $parts[1] eq 'console'
+ || $parts[1] =~ '^:\d+$' # kdm
+ || $parts[1] =~ '^tty\d$' # gdm
+ ) {
+ $consoleuser = $parts[0];
+ $tty2idletime{$parts[1]}=0; # do not kill processes for the console user (set idle time to 0)
+ push (@{$user2ttys{$consoleuser}}, $parts[1]);
+ } else {
+ $self->initializeTty($parts[1], stat("/dev/" . $parts[1]));
+ }
+ }
+ close(W);
}
+ # FIXME figure out how to handle several console users for multiseat machine
+ my $consolekitcmd = '/usr/bin/ck-list-sessions';
+ if ( ! $consoleuser && -x $consolekitcmd) {
+ print "found no console user using who, trying consolekit\n" if $debug;
+ if (open ( W, "$consolekitcmd|")) {
+ my $uid;
+ my $user;
+ while ( <W> ) {
+ chomp;
+ if (/^\tunix-user = '(\d+)'/) {
+ $uid = $1;
+ $user = (getpwuid($uid))[0];
+ print "Found consolekit user $user / $uid\n" if $debug;
+ }
+ if (/^\tis-local = (.+)$/) {
+ if ('TRUE' eq $1) {
+ $consoleuser = $user;
+ print "Found local consolekit user $user\n" if $debug;
+ }
+ }
+ }
+ close(W);
+ }
}
- close(W);
+ return;
}
=head2 showConsoleUser
|