Bug#845200: libnet-dns-perl: Setting $/ to "\r\n" breaks Net::DNS
Benoit Panizzon
panizzon at woody.ch
Mon Nov 21 12:28:02 UTC 2016
Package: libnet-dns-perl
Version: 0.81-2+deb8u1
Severity: normal
Dear Net::DNS Maintainer.
I'm not so sure this is a bug or some kind of expected behaviour.
I was coding some email application and for that I needed to set the 'line ending'
$/ to "\r\n".
As I wanted to enhance that application by querying RBL Blacklists I started
using Net::DNS which I use in a lot of other applications.
It turned out, that Net::DNS always sent the requestst to 127.0.0.1 or ::1 instead
of the nameservers found in /etc/resolv.conf of the name passed via
$res->nameservers() list.
If I specified an IP Address in $res->nameservers that worked fine, but as DNS tents
mostly support ipv6 I wanted to avoid using ip addresses in favour of hostnames.
Some more debugging revealed that $res->nameservers also failed to resolve the name-
server because it send the requests to 'localhost'.
So I re-made a simple example to figure out what causes the issue.
It turned out to be setting $/ to "\r\n";
--- snipp --------
#!/usr/bin/perl
use strict;
use warnings;
use Net::DNS;
$/ = "\r\n";
my $host = "www.google.com.";
my $res = Net::DNS::Resolver->new ( debug => 1) ;
$res->udp_timeout(3);
$res->tcp_timeout(3);
my $dnsquery = $res->search("$host");
if ($dnsquery) {
foreach my $rr ( $dnsquery->answer ) {
next unless $rr->type eq "A";
warn "Found an A record!\n";
}
} else {
if ( !$res->errorstring =~ /NXDOMAIN/ ) {
warn "query failed: ", $res->errorstring, "\n";
} else {
warn "Domain not found!\n";
}
}
--- snapp ---
this fails until you comment out the $/ line.
I don't know if the root cause might be, that /etc/resolv.conf cannot be read anymore.
-Benoit-
-- System Information:
Debian Release: 8.6
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 3.16.0-4-686-pae (SMP w/2 CPU cores)
Locale: LANG=de_CH.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages libnet-dns-perl depends on:
ii libc6 2.19-18+deb8u6
ii libdigest-hmac-perl 1.03+dfsg-1
ii libio-socket-inet6-perl 2.72-1
ii libnet-ip-perl 1.26-1
ii perl 5.20.2-3+deb8u6
ii perl-base [perlapi-5.20.2] 5.20.2-3+deb8u6
libnet-dns-perl recommends no packages.
libnet-dns-perl suggests no packages.
-- no debconf information
More information about the pkg-perl-maintainers
mailing list