Logging and other code cleanup.

This commit is contained in:
Scott Kitterman 2007-02-04 22:25:18 +00:00
commit 305b57ec14
2 changed files with 19 additions and 12 deletions

View file

@ -87,10 +87,10 @@ openlog($syslog_ident, $syslog_options, $syslog_facility);
# #
# Receive a bunch of attributes, evaluate the policy, send the result. # Receive a bunch of attributes, evaluate the policy, send the result.
# #
my %attr;
while (<STDIN>) { while (<STDIN>) {
chomp; chomp;
my %attr;
if (/=/) { if (/=/) {
my ($key, $value) =split (/=/, $_, 2); my ($key, $value) =split (/=/, $_, 2);
$attr{$key} = $value; $attr{$key} = $value;
@ -124,9 +124,10 @@ while (<STDIN>) {
} }
} }
syslog(info => "Policy action=%s", $action); syslog(info => "%s: Policy action=%s", $attr{queue_id}, $action);
STDOUT->print("action=$action\n\n"); STDOUT->print("action=$action\n\n");
%attr = ();
} }
# ---------------------------------------------------------- # ----------------------------------------------------------
@ -164,11 +165,13 @@ sub sender_policy_framework {
my $helo_authority_exp = $helo_result->authority_explanation my $helo_authority_exp = $helo_result->authority_explanation
if $helo_result->is_code('fail'); if $helo_result->is_code('fail');
my $helo_spf_header = $helo_result->received_spf_header; my $helo_spf_header = $helo_result->received_spf_header;
if ($VERBOSE) {
syslog( syslog(
info => "%s: SPF %s: HELO/EHLO: %s, IP Address: %s, Recipient: %s", info => "%s: SPF %s: HELO/EHLO: %s, IP Address: %s, Recipient: %s",
$attr->{queue_id}, $helo_result, $attr->{helo_name}, $attr->{client_address}, $attr->{recipient} $attr->{queue_id}, $helo_result, $attr->{helo_name}, $attr->{client_address},
); $attr->{recipient}
);
};
# Reject on HELO fail. Defer on HELO temperror if message would otherwise # Reject on HELO fail. Defer on HELO temperror if message would otherwise
# be accepted. Use the HELO result and return for null sender. # be accepted. Use the HELO result and return for null sender.
@ -211,10 +214,13 @@ sub sender_policy_framework {
if $mfrom_result->is_code('fail'); if $mfrom_result->is_code('fail');
my $mfrom_spf_header = $mfrom_result->received_spf_header; my $mfrom_spf_header = $mfrom_result->received_spf_header;
syslog( if ($VERBOSE) {
info => "%s: SPF %s: Envelope-from: %s, IP Address: %s, Recipient: %s", syslog(
$attr->{queue_id}, $mfrom_result, $attr->{sender}, $attr->{client_address}, $attr->{recipient} info => "%s: SPF %s: Envelope-from: %s, IP Address: %s, Recipient: %s",
); $attr->{queue_id}, $mfrom_result, $attr->{sender}, $attr->{client_address},
$attr->{recipient}
);
};
# Same approach as HELO.... # Same approach as HELO....
if ($mfrom_result->is_code('fail')) { if ($mfrom_result->is_code('fail')) {

View file

@ -53,3 +53,4 @@ helo_name=mailout02.controlledmail.com
sender= sender=
recipient=bogus@kitterman.org recipient=bogus@kitterman.org
queue_id=q1234 queue_id=q1234