This commit is contained in:
Jamie Cameron
2018-02-23 18:53:55 -08:00
parent 38732d0297
commit 6bb6f85460
2 changed files with 11 additions and 2 deletions

View File

@ -21,7 +21,8 @@ return &password_file($config{'gshadow_file'}) ? 2 : 0;
sub open_last_command sub open_last_command
{ {
local ($fh, $user) = @_; local ($fh, $user) = @_;
open($fh, "last $user |"); local $quser = quotemeta($user);
open($fh, "(last -F $quser || last $quser) |");
} }
# read_last_line(handle) # read_last_line(handle)
@ -35,9 +36,15 @@ while(1) {
if (!$line) { return (); } if (!$line) { return (); }
if ($line =~ /system boot/) { next; } if ($line =~ /system boot/) { next; }
if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+\-\s+(\S+)\s+\((\d+:\d+)\)/) { if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+\-\s+(\S+)\s+\((\d+:\d+)\)/) {
# jcameron pts/0 fudu Thu Feb 22 09:47 - 10:15
return ($1, $2, $3, $4, $5 eq "down" ? "Shutdown" : $5, $6);
}
elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+\-\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+\((\d+:\d+)\)/) {
# jcameron pts/0 fudu Thu Feb 22 09:47 - 10:15
return ($1, $2, $3, $4, $5 eq "down" ? "Shutdown" : $5, $6); return ($1, $2, $3, $4, $5 eq "down" ? "Shutdown" : $5, $6);
} }
elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+still/) { elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+still/) {
# root pts/0 fudu Fri Feb 23 18:46 still logged in
return ($1, $2, $3, $4); return ($1, $2, $3, $4);
} }
} }

View File

@ -27,12 +27,14 @@ elsif ($access{'logins'} ne "*") {
foreach $l (&list_last_logins($u, $config{'last_count'})) { foreach $l (&list_last_logins($u, $config{'last_count'})) {
$tm = defined(&mailboxes::parse_mail_date) ? $tm = defined(&mailboxes::parse_mail_date) ?
&mailboxes::parse_mail_date($l->[3]) : undef; &mailboxes::parse_mail_date($l->[3]) : undef;
$tm2 = defined(&mailboxes::parse_mail_date) ?
&mailboxes::parse_mail_date($l->[4]) : undef;
push(@table, [ push(@table, [
$u ? ( ) : ( "<tt>".&html_escape($l->[0])."</tt>" ), $u ? ( ) : ( "<tt>".&html_escape($l->[0])."</tt>" ),
&html_escape($l->[2]) || $text{'logins_local'}, &html_escape($l->[2]) || $text{'logins_local'},
&html_escape($l->[1]), &html_escape($l->[1]),
&html_escape($tm ? &make_date($tm) : $l->[3]), &html_escape($tm ? &make_date($tm) : $l->[3]),
$l->[4] ? ( &html_escape($l->[4]), $l->[4] ? ( &html_escape($tm2 ? &make_date($tm2) : $l->[4]),
&html_escape($l->[5]) ) &html_escape($l->[5]) )
: ( "<i>$text{'logins_still'}</i>", "" ), : ( "<i>$text{'logins_still'}</i>", "" ),
]); ]);