From 364bc8a75420cf033bcf5cf7958a87c908ae97e5 Mon Sep 17 00:00:00 2001 From: Julian Mehnle <> Date: Sun, 4 Feb 2007 22:36:52 +0000 Subject: [PATCH] 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). --- postfix-policyd-spf-perl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/postfix-policyd-spf-perl b/postfix-policyd-spf-perl index 229f961..8ad66e4 100755 --- a/postfix-policyd-spf-perl +++ b/postfix-policyd-spf-perl @@ -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 () { 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; }