postfix-policyd-spf-perl/trunk/postfix-policyd-spf
* Version 1.07.
This commit is contained in:
parent
5e0cd7d9a0
commit
0bd77bdc15
1 changed files with 14 additions and 15 deletions
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
# postfix-policyd-spf
|
# postfix-policyd-spf
|
||||||
# http://www.openspf.org
|
# http://www.openspf.org
|
||||||
# version 1.06
|
# version 1.07
|
||||||
# $Id$
|
# $Id: postfix-policyd-spf 147 2006-03-14 21:51:58Z julian $
|
||||||
|
|
||||||
use Fcntl;
|
use Fcntl;
|
||||||
use Sys::Syslog qw(:DEFAULT setlogsock);
|
use Sys::Syslog qw(:DEFAULT setlogsock);
|
||||||
|
|
@ -120,9 +120,9 @@ my $syslog_ident = "postfix/policy-spf";
|
||||||
# Log an error and abort.
|
# Log an error and abort.
|
||||||
#
|
#
|
||||||
sub fatal_exit {
|
sub fatal_exit {
|
||||||
syslog(err => "fatal_exit: @_");
|
syslog(err => "fatal_exit: @_");
|
||||||
syslog(warn => "fatal_exit: @_");
|
syslog(warning => "fatal_exit: @_");
|
||||||
syslog(info => "fatal_exit: @_");
|
syslog(info => "fatal_exit: @_");
|
||||||
die "fatal: @_";
|
die "fatal: @_";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,11 +149,11 @@ my %attr;
|
||||||
while (<STDIN>) {
|
while (<STDIN>) {
|
||||||
chomp;
|
chomp;
|
||||||
if (/=/) { my ($k, $v) = split (/=/, $_, 2); $attr{$k} = $v; next }
|
if (/=/) { my ($k, $v) = split (/=/, $_, 2); $attr{$k} = $v; next }
|
||||||
elsif (length) { syslog(warn=>sprintf("warning: ignoring garbage: %.100s", $_)); next; }
|
elsif (length) { syslog(warning => sprintf("warning: ignoring garbage: %.100s", $_)); next; }
|
||||||
|
|
||||||
if ($VERBOSE) {
|
if ($VERBOSE) {
|
||||||
for (sort keys %attr) {
|
for (sort keys %attr) {
|
||||||
syslog(debug=> "Attribute: %s=%s", $_, $attr{$_});
|
syslog(debug => "Attribute: %s=%s", $_, $attr{$_});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,14 +164,14 @@ while (<STDIN>) {
|
||||||
foreach my $handler (@HANDLERS) {
|
foreach my $handler (@HANDLERS) {
|
||||||
no strict 'refs';
|
no strict 'refs';
|
||||||
my $response = $handler->(attr=>\%attr);
|
my $response = $handler->(attr=>\%attr);
|
||||||
syslog(debug=> "handler %s: %s", $handler, $response);
|
syslog(debug => "handler %s: %s", $handler, $response);
|
||||||
if ($response and $response !~ /^dunno/i) {
|
if ($response and $response !~ /^dunno/i) {
|
||||||
syslog(info=> "handler %s: %s is decisive.", $handler, $response);
|
syslog(info => "handler %s: %s is decisive.", $handler, $response);
|
||||||
$action = $response; last;
|
$action = $response; last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog(info=> "decided action=%s", $action);
|
syslog(info => "decided action=%s", $action);
|
||||||
|
|
||||||
print STDOUT "action=$action\n\n";
|
print STDOUT "action=$action\n\n";
|
||||||
%attr = ();
|
%attr = ();
|
||||||
|
|
@ -188,13 +188,13 @@ sub sender_permitted_from {
|
||||||
sender=>$attr{sender},
|
sender=>$attr{sender},
|
||||||
helo =>$attr{helo_name}) };
|
helo =>$attr{helo_name}) };
|
||||||
if ($@) {
|
if ($@) {
|
||||||
syslog(info=>"%s: Mail::SPF::Query->new(%s, %s, %s) failed: %s",
|
syslog(info => "%s: Mail::SPF::Query->new(%s, %s, %s) failed: %s",
|
||||||
$attr{queue_id}, $attr{client_address}, $attr{sender}, $attr{helo_name}, $@);
|
$attr{queue_id}, $attr{client_address}, $attr{sender}, $attr{helo_name}, $@);
|
||||||
return "DUNNO";
|
return "DUNNO";
|
||||||
}
|
}
|
||||||
my ($result, $smtp_comment, $header_comment) = $query->result();
|
my ($result, $smtp_comment, $header_comment) = $query->result();
|
||||||
|
|
||||||
syslog(info=>"%s: SPF %s: smtp_comment=%s, header_comment=%s",
|
syslog(info => "%s: SPF %s: smtp_comment=%s, header_comment=%s",
|
||||||
$attr{queue_id}, $result, $smtp_comment, $header_comment);
|
$attr{queue_id}, $result, $smtp_comment, $header_comment);
|
||||||
|
|
||||||
if ($result eq "fail") { return "REJECT $smtp_comment"; }
|
if ($result eq "fail") { return "REJECT $smtp_comment"; }
|
||||||
|
|
@ -214,12 +214,11 @@ sub testing {
|
||||||
and
|
and
|
||||||
$attr{recipient} =~ /policyblock/) {
|
$attr{recipient} =~ /policyblock/) {
|
||||||
|
|
||||||
syslog(info=>"%s: testing: will block as requested",
|
syslog(info => "%s: testing: will block as requested", $attr{queue_id});
|
||||||
$attr{queue_id});
|
|
||||||
return "REJECT smtpd-policy blocking $attr{recipient}";
|
return "REJECT smtpd-policy blocking $attr{recipient}";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
syslog(info=>"%s: testing: stripped sender=%s, stripped rcpt=%s",
|
syslog(info => "%s: testing: stripped sender=%s, stripped rcpt=%s",
|
||||||
$attr{queue_id},
|
$attr{queue_id},
|
||||||
address_stripped($attr{sender}),
|
address_stripped($attr{sender}),
|
||||||
address_stripped($attr{recipient}),
|
address_stripped($attr{recipient}),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue