Subject: | Net::DNS 0.77 cannot deal with trailing comments in /etc/resolv.conf |
Date: | Sun, 29 Jun 2014 15:24:01 +0200 |
To: | bug-Net-DNS [...] rt.cpan.org |
From: | Michael Grimm <trashcan [...] odo.in-berlin.de> |
Hi --
After upgrading from Net::DNS 0.76 to Net::DNS 0.77 spamassassin failed to daemonize. After some investigations I found the reason in Net::DNS 0.77 lack of stripping trailing comments in /etc/resolv.conf:
Will be parsed correctly in <= 0.76 but will not work with spamassassin and Net::DNS 0.77:
/etc/resolv.conf
nameserver 8.8.8.8 # Google
Removing those trailing comments will work with spamassassin and Net::DNS 0.77:
/etc/resolv.conf
nameserver 8.8.8.8
The following patch will re-introduce that part of the code responsible for dealing with comments in versions <= 0.76:
------------------------------------- SNIP -----------------------------
--- /usr/local/lib/perl5/site_perl/5.16/mach/Net/DNS/Resolver/Base.pm 2014-06-13 23:02:31.000000000 +0200
+++ Base.pm--0.76-way-to-strip-comments-in-resolv.conf 2014-06-28 18:31:06.492446355 +0200
@@ -234,6 +234,10 @@
local $_;
while (<FILE>) {
+ s/\s*[;#].*$//; # strip comment
+ next unless m/\S/; # skip empty line
+ s/^\s+//; # strip leading space
+
/^nameserver/ && do {
my ( $keyword, @ip ) = split;
push @ns, map { $_ eq '0' ? '0.0.0.0' : $_ } @ip;
------------------------------------- SNIP -----------------------------
Here are the details of OS, Perl and Net::DNS port installed:
Show quoted text
test> uname -v
FreeBSD 10.0-STABLE #0 r267840: Tue Jun 24 23:08:16 CEST 2014 root@kaan-bock.net:/usr/obj/usr/src/sys/CUSTOM
Show quoted texttest> perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for amd64-freebsd-thread-multi
Show quoted texttest> pkg info | grep DNS
p5-Net-DNS-0.77 Perl5 interface to the DNS resolver, and dynamic updates
Regards,
Michael