Add two patches from upstream bug #7265, which fixes incompatibilities with

Net::DNS 1.03. The FreeBSD p5-Net-DNS port has been downgraded to 1.02 but
Net::DNS will be re-issued at some point soon. The changes in these patches
seem to work well with Net::DNS 1.02.

While here, add some TEST_DEPENDS so I can run the plugin-based tests as well.

Bump PORTREVISION for spamassassin and japanese/spamassassin.

PR:		204682
Submitted by:	Mark.Martinec@ijs.si
Obtained from:	https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7265
This commit is contained in:
Adam Weinberger 2015-11-23 17:00:18 +00:00
parent 82abbbe8b6
commit b4a3b2f221
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=402285
3 changed files with 89 additions and 2 deletions

View File

@ -1,7 +1,7 @@
# Created by: TAOKA Fumiyoshi
# $FreeBSD$
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= japanese mail perl5
PKGNAMEPREFIX= ja-

View File

@ -3,7 +3,7 @@
PORTNAME= spamassassin
PORTVERSION= 3.4.1
PORTREVISION?= 4 # also bump japanese/spamassassin
PORTREVISION?= 5 # also bump japanese/spamassassin
CATEGORIES?= mail perl5
MASTER_SITES= APACHE/spamassassin/source CPAN/Mail
DISTNAME= Mail-SpamAssassin-${PORTVERSION}
@ -22,6 +22,10 @@ BUILD_DEPENDS= p5-Encode-Detect>=0:${PORTSDIR}/converters/p5-Encode-Detect \
RUN_DEPENDS:= ${BUILD_DEPENDS} \
re2c>=.12.0:${PORTSDIR}/devel/re2c
.for dep in DCC DKIM MYSQL PGSQL PYZOR RAZOR RELAY_COUNTRY SPF_QUERY SSL
TEST_DEPENDS+= ${${dep}_RUN_DEPENDS}
.endfor
CONFLICTS?= ja-spamassassin-[0-9]*
CPE_VENDOR= apache

View File

@ -0,0 +1,83 @@
--- lib/Mail/SpamAssassin/DnsResolver.pm (revision 1715195)
+++ lib/Mail/SpamAssassin/DnsResolver.pm (working copy)
@@ -725,6 +725,37 @@
###########################################################################
+=item $id = $res->bgread()
+
+Similar to C<Net::DNS::Resolver::bgread>. Reads a DNS packet from
+a supplied socket, decodes it, and returns a Net::DNS::Packet object
+if successful. Dies on error.
+
+=cut
+
+sub bgread() {
+ my ($self) = @_;
+ my $sock = $self->{sock};
+ my $packetsize = $self->{res}->udppacketsize;
+ $packetsize = 512 if $packetsize < 512; # just in case
+ my $data = '';
+ my $peeraddr = $sock->recv($data, $packetsize+256); # with some size margin for troubleshooting
+ defined $peeraddr or die "bgread: recv() failed: $!";
+ my $peerhost = $sock->peerhost;
+ $data ne '' or die "bgread: received empty packet from $peerhost";
+ dbg("dns: bgread: received %d bytes from %s", length($data), $peerhost);
+ my($answerpkt, $decoded_length) = Net::DNS::Packet->new(\$data);
+ $answerpkt or die "bgread: decoding DNS packet failed: $@";
+ $answerpkt->answerfrom($peerhost);
+ if ($decoded_length ne length($data)) {
+ warn sprintf("bgread: received a %d bytes packet from %s, decoded %d bytes\n",
+ length($data), $peerhost, $decoded_length);
+ }
+ return $answerpkt;
+}
+
+###########################################################################
+
=item $nfound = $res->poll_responses()
See if there are any C<bgsend> reply packets ready, and return
@@ -772,13 +803,25 @@
$timeout = 0; # next time around collect whatever is available, then exit
last if $nfound == 0;
- my $packet = $self->{res}->bgread($self->{sock});
+ my $packet;
+ eval {
+ $packet = $self->bgread();
+ } or do {
+ undef $packet;
+ my $eval_stat = $@ ne '' ? $@ : "errno=$!"; chomp $eval_stat;
+ # resignal if alarm went off
+ die $eval_stat if $eval_stat =~ /__alarm__ignore__\(.*\)/s;
+ info("dns: bad dns reply: %s", $eval_stat);
+ };
+# Bug 7265, use our own bgread()
+# my $packet = $self->{res}->bgread($self->{sock});
+
if (!$packet) {
- my $dns_err = $self->{res}->errorstring;
- # resignal if alarm went off
- die "dns (3) $dns_err\n" if $dns_err =~ /__alarm__ignore__\(.*\)/s;
- info("dns: bad dns reply: $dns_err");
+ # error already reported above
+# my $dns_err = $self->{res}->errorstring;
+# die "dns (3) $dns_err\n" if $dns_err =~ /__alarm__ignore__\(.*\)/s;
+# info("dns: bad dns reply: $dns_err");
} else {
my $header = $packet->header;
if (!$header) {
--- lib/Mail/SpamAssassin/Plugin/DKIM.pm (revision 1715196)
+++ lib/Mail/SpamAssassin/Plugin/DKIM.pm (working copy)
@@ -794,7 +794,8 @@
# Only do so if EDNS0 provides a reasonably-sized UDP payload size,
# as our interface does not provide a DNS fallback to TCP, unlike
# the Net::DNS::Resolver::send which does provide it.
- my $res = $self->{main}->{resolver}->get_resolver;
+ my $res = $self->{main}->{resolver};
+ dbg("dkim: providing our own resolver: %s", ref $res);
Mail::DKIM::DNS::resolver($res);
}
}