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:
Julian Mehnle 2007-02-04 22:36:52 +00:00
commit 364bc8a754

View file

@ -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;
}