2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 22:35:35 +00:00

##rmor_notify: show last date when using -s # -v

This commit is contained in:
Jamie Strandboge
2010-05-14 00:08:31 +02:00

View File

@@ -252,7 +252,6 @@ sub format_message {
defined($name) and $formatted .= "Name: $name\n";
defined($denied) and $formatted .= "Denied: $denied\n";
defined($family) and defined ($sock_type) and $formatted .= "Family: $family\nSocket type: $sock_type\n";
#defined($date) and $since > 0 and $formatted .= "Date: ". scalar(localtime($date)) ."\n";
$formatted .= "Logfile: $logfile\n";
return $formatted;
@@ -447,6 +446,7 @@ sub do_notify {
sub show_since {
my %msg_hash;
my %last_date;
my @msg_list;
my $count = 0;
while(my $msg = <LOGFILE>) {
@@ -455,10 +455,11 @@ sub show_since {
my $m = format_message(@attrib);
$m ne "" or next;
my $date = $attrib[6];
if ($opt_v) {
if (exists($msg_hash{$m})) {
$msg_hash{$m}++;
defined($date) and $last_date{$m} = scalar(localtime($date));
} else {
$msg_hash{$m} = 1;
push(@msg_list, $m);
@@ -470,7 +471,11 @@ sub show_since {
foreach my $m (@msg_list) {
print "$m";
if ($msg_hash{$m} gt 1) {
print "($msg_hash{$m} found)\n";
print "($msg_hash{$m} found";
if (exists($last_date{$m})) {
print ", most recent from '$last_date{$m}'";
}
print ")\n";
}
print "\n";
}