postfix-policyd-spf-perl/trunk/postfix-policyd-spf-perl
* Fixed handlers handling, keeping handler name and code separate, avoiding the use of symbolic references (i.e. the dual use of the handler name as both its name and its _function_ name).
This commit is contained in:
parent
305b57ec14
commit
364bc8a754
1 changed files with 13 additions and 6 deletions
|
|
@ -35,9 +35,13 @@ use Mail::SPF;
|
||||||
|
|
||||||
my $spf_server = Mail::SPF::Server->new();
|
my $spf_server = Mail::SPF::Server->new();
|
||||||
|
|
||||||
my @HANDLERS;
|
# Leaving this to make it easier to add more handlers later:
|
||||||
push(@HANDLERS, \&sender_policy_framework);
|
my @HANDLERS = (
|
||||||
# Leaving this to make it easier to add others later.
|
{
|
||||||
|
name => 'sender_policy_framework',
|
||||||
|
code => \&sender_policy_framework
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
my $VERBOSE = 0;
|
my $VERBOSE = 0;
|
||||||
|
|
||||||
|
|
@ -110,15 +114,18 @@ while (<STDIN>) {
|
||||||
my $action = $DEFAULT_RESPONSE;
|
my $action = $DEFAULT_RESPONSE;
|
||||||
my %responses;
|
my %responses;
|
||||||
foreach my $handler (@HANDLERS) {
|
foreach my $handler (@HANDLERS) {
|
||||||
my $response = $handler->(attr => \%attr);
|
my $handler_name = $handler->{name};
|
||||||
|
my $handler_code = $handler->{code};
|
||||||
|
|
||||||
|
my $response = $handler_code->(attr => \%attr);
|
||||||
|
|
||||||
if ($VERBOSE) {
|
if ($VERBOSE) {
|
||||||
syslog(debug => "handler %s: %s", $handler, $response);
|
syslog(debug => "handler %s: %s", $handler_name, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Picks whatever response is not dunno
|
# Picks whatever response is not dunno
|
||||||
if ($response and $response !~ /^dunno/i) {
|
if ($response and $response !~ /^dunno/i) {
|
||||||
syslog(info => "handler %s: is decisive.", $handler);
|
syslog(info => "handler %s: is decisive.", $handler_name);
|
||||||
$action = $response;
|
$action = $response;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue