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 @HANDLERS;
|
||||
push(@HANDLERS, \&sender_policy_framework);
|
||||
# Leaving this to make it easier to add others later.
|
||||
# Leaving this to make it easier to add more handlers later:
|
||||
my @HANDLERS = (
|
||||
{
|
||||
name => 'sender_policy_framework',
|
||||
code => \&sender_policy_framework
|
||||
}
|
||||
);
|
||||
|
||||
my $VERBOSE = 0;
|
||||
|
||||
|
|
@ -110,15 +114,18 @@ while (<STDIN>) {
|
|||
my $action = $DEFAULT_RESPONSE;
|
||||
my %responses;
|
||||
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) {
|
||||
syslog(debug => "handler %s: %s", $handler, $response);
|
||||
syslog(debug => "handler %s: %s", $handler_name, $response);
|
||||
}
|
||||
|
||||
# Picks whatever response is not dunno
|
||||
if ($response and $response !~ /^dunno/i) {
|
||||
syslog(info => "handler %s: is decisive.", $handler);
|
||||
syslog(info => "handler %s: is decisive.", $handler_name);
|
||||
$action = $response;
|
||||
last;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue