dmarc: added support for DMARC policy pct=NNN

This commit is contained in:
Matt Simerson 2013-04-24 16:16:00 -04:00
parent c0210a7877
commit ebfccec5b3

View File

@ -52,7 +52,7 @@ _dmarc IN TXT "v=DMARC1; p=reject; pct=100; rua=mailto:dmarc-feedback@example.c
3. activate this plugin (add to config/plugins) 3. activate this plugin (add to config/plugins)
Be sure to run the DMARC after the SPF & DKIM plugins, and you should also have I<reject 0> set for both SPF and DKIM. Be sure to run the DMARC plugin after the SPF & DKIM plugins. Configure the SPF and DKIM messages to not reject mail.
=head2 Parse dmarc feedback reports into a database =head2 Parse dmarc feedback reports into a database
@ -146,6 +146,12 @@ sub data_post_handler {
# Domain Owner. See Section 6.2 for details. # Domain Owner. See Section 6.2 for details.
return DECLINED if lc $policy->{p} eq 'none'; return DECLINED if lc $policy->{p} eq 'none';
my $pct = $policy->{pct} || 100;
if ( $pct != 100 && int(rand(100)) >= $pct ) {
$self->log("fail, tolerated, policy, sampled out");
return DECLINED;
};
return $self->get_reject("failed DMARC policy"); return $self->get_reject("failed DMARC policy");
} }
@ -348,6 +354,7 @@ sub host_has_rr {
$self->log(LOGDEBUG, "fail, non-existent domain: $domain"); $self->log(LOGDEBUG, "fail, non-existent domain: $domain");
return; return;
} }
return if $res->errorstring eq 'NOERROR';
$self->log(LOGINFO, "error, looking up $domain: " . $res->errorstring); $self->log(LOGINFO, "error, looking up $domain: " . $res->errorstring);
return; return;
}; };