mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Fix to bring back support for limit in last command
https://forum.virtualmin.com/t/is-this-process-normal-or-should-i-worry/128835/10?u=ilia
This commit is contained in:
@@ -17,12 +17,13 @@ sub groupfiles_type
|
||||
return 0;
|
||||
}
|
||||
|
||||
# open_last_command(handle, user)
|
||||
# open_last_command(handle, user, [max])
|
||||
sub open_last_command
|
||||
{
|
||||
local ($fh, $user) = @_;
|
||||
local $quser = quotemeta($user);
|
||||
open($fh, "(last -w $quser || last $quser) |");
|
||||
my ($fh, $user, $max) = @_;
|
||||
my $quser = quotemeta($user);
|
||||
$max = " -n $max" if ($max);
|
||||
open($fh, "(last -w$max $quser || last$max $quser) |");
|
||||
}
|
||||
|
||||
# read_last_line(handle)
|
||||
|
||||
@@ -17,12 +17,13 @@ sub groupfiles_type
|
||||
return &password_file($config{'gshadow_file'}) ? 2 : 0;
|
||||
}
|
||||
|
||||
# open_last_command(handle, user)
|
||||
# open_last_command(handle, user, [max])
|
||||
sub open_last_command
|
||||
{
|
||||
local ($fh, $user) = @_;
|
||||
local $quser = quotemeta($user);
|
||||
open($fh, "(last -F -w $quser || last -w $quser) |");
|
||||
my ($fh, $user, $max) = @_;
|
||||
my $quser = quotemeta($user);
|
||||
$max = " -n $max" if ($max);
|
||||
open($fh, "(last -F -w$max $quser || last -w$max $quser) |");
|
||||
}
|
||||
|
||||
# read_last_line(handle)
|
||||
|
||||
@@ -54,11 +54,12 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
# open_last_command(handle, user)
|
||||
# open_last_command(handle, user, [max])
|
||||
sub open_last_command
|
||||
{
|
||||
local ($fh, $user) = @_;
|
||||
open($fh, "last $user |");
|
||||
my ($fh, $user, $max) = @_;
|
||||
$max = " -n $max" if ($max);
|
||||
open($fh, "last$max $user |");
|
||||
}
|
||||
|
||||
# read_last_line(handle)
|
||||
|
||||
@@ -2552,11 +2552,13 @@ Returns a list of array references, each containing the details of a login.
|
||||
=cut
|
||||
sub list_last_logins
|
||||
{
|
||||
local @rv;
|
||||
&open_last_command(LAST, $_[0]);
|
||||
my ($user, $max) = @_;
|
||||
my @rv;
|
||||
undef($max) if (defined($max) && $max <= 0); # sanity check
|
||||
&open_last_command(LAST, $user, $max);
|
||||
while(@last = &read_last_line(LAST)) {
|
||||
push(@rv, [ @last ]);
|
||||
if ($_[1] && scalar(@rv) >= $_[1]) {
|
||||
if ($max && scalar(@rv) >= $max) {
|
||||
last; # reached max
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user