| version 1.1, 2005/12/02 17:56:50 |
version 1.2, 2005/12/02 20:56:12 |
|
|
| use Fcntl; |
use Fcntl; |
| use Carp; |
use Carp; |
| use Sys::Syslog qw(:DEFAULT setlogsock); |
use Sys::Syslog qw(:DEFAULT setlogsock); |
| |
use Time::HiRes qw(gettimeofday tv_interval usleep sleep); |
| use strict; |
use strict; |
| |
|
| # ---------------------------------------------------------- |
# ---------------------------------------------------------- |
|
|
| push @HANDLERS, "sender_permitted_from"; use Mail::SPF::Query; |
push @HANDLERS, "sender_permitted_from"; use Mail::SPF::Query; |
| |
|
| my $VERBOSE = 1; |
my $VERBOSE = 1; |
| |
#my $VERBOSE = 0; |
| |
|
| my $DEFAULT_RESPONSE = "DUNNO"; |
my $DEFAULT_RESPONSE = "DUNNO"; |
| |
|
| Line 159 while (<STDIN>) { |
|
| Line 161 while (<STDIN>) { |
|
| if (/=/) { my ($k, $v) = split (/=/, $_, 2); $attr{$k} = $v; next } |
if (/=/) { my ($k, $v) = split (/=/, $_, 2); $attr{$k} = $v; next } |
| elsif (length) { syslog('warning', "warning: ignoring garbage: %.100s", $_); next; } |
elsif (length) { syslog('warning', "warning: ignoring garbage: %.100s", $_); next; } |
| |
|
| if ($VERBOSE) { |
if (0 && $VERBOSE) { |
| for (sort keys %attr) { |
for (sort keys %attr) { |
| syslog('debug', "Attribute: %s=%s", $_, $attr{$_}); |
syslog('debug', "Attribute: %s=%s", $_, $attr{$_}); |
| } |
} |
| Line 169 while (<STDIN>) { |
|
| Line 171 while (<STDIN>) { |
|
| |
|
| my $action = $DEFAULT_RESPONSE; |
my $action = $DEFAULT_RESPONSE; |
| my %responses; |
my %responses; |
| |
my $ts0 = [gettimeofday]; |
| 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; |
| } |
} |
| } |
} |
| |
if ($VERBOSE) { |
| |
syslog('debug', "SPF-REQUIRED-TIME: %s seconds", tv_interval($ts0, [gettimeofday])); |
| |
} |
| |
|
| syslog('info', "decided action=%s", $action); |
syslog('info', "decided action=%s", $action); |
| |
|