mirror of
https://github.com/darold/sendmailanalyzer.git
synced 2026-05-15 14:15:56 -06:00
Fix possible data file corruption with ipv6 addresses. Thanks to Eneko for the report.
This commit is contained in:
parent
ca5b12cb25
commit
b6d1df6d93
1 changed files with 39 additions and 2 deletions
41
sa_cache
41
sa_cache
|
|
@ -422,6 +422,10 @@ sub do_hour_cache
|
|||
chomp($l);
|
||||
# Format: Hour:Id:Sender:Size:Nrcpts:Relay:Subject
|
||||
@data = split(/:/, $l);
|
||||
if ($#data > 6) {
|
||||
@data = $l =~ m/^([^:]+):([^:]+):([^:]+):([^:]+):([^:]+):([a-zA-Z0-9\-\.]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\d{1,3}\.\d{1,3}\.\d{1,3}\(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\)|[0-9a-fA-F:\(\)]+)?:([^:]+)$/;
|
||||
}
|
||||
$data[5] = &clean_relay($data[5]);
|
||||
$data[0] =~ /^(\d{2})/;
|
||||
next if ($1 ne $hour);
|
||||
$localstat{$data[1]}{idx_sender} = "$1";
|
||||
|
|
@ -435,7 +439,7 @@ sub do_hour_cache
|
|||
$localstat{TOPDSN}{$sourceid{$data[1]}}{sender} = $data[2];
|
||||
$localstat{TOPDSN}{$sourceid{$data[1]}}{sender_relay} = $data[5];
|
||||
}
|
||||
if ($#data == 6) {
|
||||
if ($#data >= 6) {
|
||||
$localstat{$data[1]}{subject} = $data[6];
|
||||
}
|
||||
}
|
||||
|
|
@ -448,6 +452,10 @@ sub do_hour_cache
|
|||
chomp($l);
|
||||
# Format: Hour:Id:recipient:Relay:Status
|
||||
@data = split(/:/, $l);
|
||||
if ($#data > 4) {
|
||||
@data = $l =~ m/^([^:]+):([^:]+):([^:]+):([a-zA-Z0-9\-\.]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\d{1,3}\.\d{1,3}\.\d{1,3}\(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\)|[0-9a-fA-F:\(\)]+)?:([^:]+)$/;
|
||||
}
|
||||
$data[3] = &clean_relay($data[3]);
|
||||
$data[0] =~ /^(\d{2})/;
|
||||
next if ($1 ne $hour);
|
||||
$localstat{$data[1]}{idx_rcpt} = "$1";
|
||||
|
|
@ -470,6 +478,10 @@ sub do_hour_cache
|
|||
chomp($l);
|
||||
# Format: Hour:Id:Rule:Relay:Arg1:Status
|
||||
@data = split(/:/, $l);
|
||||
if ($#data > 5) {
|
||||
@data = $l =~ m/^([^:]+):([^:]+):([^:]+):([a-zA-Z0-9\-\.]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\d{1,3}\.\d{1,3}\.\d{1,3}\(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\)|[0-9a-fA-F:\(\)]+)?:([^:]+):([^:]+)$/;
|
||||
}
|
||||
$data[3] = &clean_relay($data[3]);
|
||||
$data[0] =~ /^(\d{2})/;
|
||||
next if ($1 ne $hour);
|
||||
$localstat{$data[1]}{idx_reject} = "$1";
|
||||
|
|
@ -584,7 +596,14 @@ sub do_hour_cache
|
|||
while (my $l = <IN>) {
|
||||
chomp($l);
|
||||
# Format: Hour:Id:Relay:From:To:Action:Reason
|
||||
@data = split(/:/, $l, 7);
|
||||
@data = split(/:/, $l);
|
||||
if ($#data > 6) {
|
||||
@data = $l =~ m/^([^:]+):([^:]+):([a-zA-Z0-9\-\.]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\d{1,3}\.\d{1,3}\.\d{1,3}\(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\)|[0-9a-fA-F:\(\)]+)?:([^:]+):([^:]*):([^:]+):([^:]+)$/;
|
||||
# Fix a possible bug corruption of the data files
|
||||
$data[3] =~ s/(.*\@.*)\@localhost/$1/;
|
||||
$data[4] =~ s/(.*\@.*)\@localhost/$1/;
|
||||
}
|
||||
$data[2] = &clean_relay($data[2]);
|
||||
$data[0] =~ /^(\d{2})/;
|
||||
next if ($1 ne $hour);
|
||||
$localstat{$data[1]}{idx_postgrey} = "$1";
|
||||
|
|
@ -625,6 +644,10 @@ sub do_hour_cache
|
|||
chomp($l);
|
||||
# Format: Hour:Id:Relay:Mech:Type
|
||||
@data = split(/:/, $l);
|
||||
if ($#data > 4) {
|
||||
@data = $l =~ m/^([^:]+):([^:]+):([a-zA-Z0-9\-\.]+|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\d{1,3}\.\d{1,3}\.\d{1,3}\(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\)|[0-9a-fA-F:\(\)]+)?:([^:]+):([^:]+)$/;
|
||||
}
|
||||
$data[2] = &clean_relay($data[2]);
|
||||
$data[0] =~ /^(\d{2})(\d{2})/;
|
||||
next if ($1 ne $hour);
|
||||
push(@{$localstat{$data[1]}{idx_auth}}, "$1");
|
||||
|
|
@ -5078,4 +5101,18 @@ sub get_day_of_week
|
|||
return $weekDay;
|
||||
}
|
||||
|
||||
####
|
||||
# Fix relay not sanityzed in sendmailanalyzer script
|
||||
####
|
||||
sub clean_relay
|
||||
{
|
||||
my $relay = shift;
|
||||
|
||||
if ( $relay =~ s/\(([a-fA-F0-9\.\:]+)\)// ) {
|
||||
$relay = $1;
|
||||
}
|
||||
$relay =~ s/:/_/g; # fix ipv6 to remove data field separator
|
||||
|
||||
return $relay;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue