#782625 spamassassin: 'Unresolvable name: localhost' fail in daily updates

#782625#5
Date:
2015-04-15 06:42:21 UTC
From:
To:
Dear Maintainer,

I get this error (daily mail to root) when spamassassin tries to update it:

/etc/cron.daily/spamassassin:
unresolvable name: localhost at /usr/bin/sa-update line 432.
sa-update failed for unknown reasons

If I execute "sa-update" I get the same error:

unresolvable name: localhost at /usr/bin/sa-update line 432

The system is Debian Jessie.

spamassassin --version: 3.4.0 running on Perl version 5.20.2
sa-update --version: svn1475932 running on Perl version 5.20.2

Sincerely yours,
Pablo Pascual

#782625#8
Date:
2015-04-16 00:03:54 UTC
From:
To:
Pablo Pascual wrote:

Note that I am not the maintainer but am another user trying to help.

Could you do some additional testing on your system?  It would help to
understand the issue.  What is the output of these commands?

  grep hosts /etc/nsswitch.conf

  grep localhost /etc/hosts

  getent hosts localhost

Thanks,
Bob

#782625#13
Date:
2015-04-20 06:06:18 UTC
From:
To:
Dear Bob

Sorry for response delay, these days I've been out of office.

These are the outputs:

grep hosts /etc/nsswitch.conf:
hosts:          files mdns4_minimal [NOTFOUND=return] dns ldap

grep localhost /etc/hosts:
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback

getent hosts localhost:
::1             localhost ip6-localhost ip6-loopback

Thanks for your help!

Sincerely yours,
Pablo Pascual

2015-04-16 2:03 GMT+02:00 Bob Proulx <bob@proulx.com>:

#782625#18
Date:
2015-04-20 06:39:33 UTC
From:
To:
Hi Pablo,

Pablo Pascual wrote:

Mail is store and forward.  It will wait.  :-)

Whenever I see mdns I have an immune reponse reaction.  But that
should be the problem here.  The very first entry is files.  That
means that /etc/hosts should be first in the priority for resolving
localhost.  And your data shows localhost there.

Good.

Good.  Resolving localhost works.  It just so happens that IPv6 is
preferred if both are available.  Therefore the ::1 is returned.

Those are all good but unfortunately to don't help to diagnose the
problem.  I was hoping to see that localhost wasn't found because it
had been moved from /etc/hosts or something.  Or that nsswitch.conf
had been modified not to use files.  But everything looks okay to me.
Which is in conflict with the error messages presented.

That error says perl's resolver could not translate the name to the
address.  The name is "localhost".  Why can't it resolve localhost?
That is really quite a strange situation.  The name "localhost" should
always be resolved.  It should resolve to either 127.0.0.1 for an IPv4
address or it is possible ::1 for an IPv6 address.  But in your case
it is failing to do this.  And therefore the question comes about as
to why?

Can you ping localhost?  This is rather a brute force test but useful.

  ping localhost

What address is displayed when you ping localhost?  I expect to see
127.0.0.1 there.

And if that works then why doesn't Perl's line 432 resolve localhost?
That is the question.

Just to make sure we are looking at the same lines could you print
this out just to show us the lines around 432 in your file?  I am
expecting to see this there.

  $ cat -n /usr/bin/sa-update | sed -n '431,435p'
  431 } else {
  432   $res = Net::DNS::Resolver->new();
  433   $res->force_v4(1)  if $have_inet4 &&
  434                         $opt{'force_pf'} && $opt{'force_pf'} eq 'inet';
  435 }

Bob

#782625#23
Date:
2015-04-24 08:28:18 UTC
From:
To:
Hi Bob


Can you ping localhost?  This is rather a brute force test but useful.
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.054 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.047 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.044 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.038 ms
^C
--- localhost ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.038/0.045/0.054/0.010 ms


Others ways to resolve "localhost" shows identical result, for example
"nslookup":

nslookup localhost
Server:         127.0.0.1
Address:        127.0.0.1#53
Name:   localhost
Address: 127.0.0.1

Just to make sure we are looking at the same lines could you print
The content around line 432 in my computer is exactly as you expected:

cat -n /usr/bin/sa-update | sed -n '431,435p'
   431  } else {
   432    $res = Net::DNS::Resolver->new();
   433    $res->force_v4(1)  if $have_inet4 &&
   434                          $opt{'force_pf'} && $opt{'force_pf'} eq
'inet';
   435  }

Since I'm guess it's a problem in perl, I've made a very simple perl test
file (dns.perl):

use Net::DNS;
$resolver = new Net::DNS::Resolver();

If I execute I get same error:
perl dns.perl
unresolvable name: localhost at dns.perl line 2.

But if I execute in other computer I get no error. Both computers have the
same perl version (5.20.2).

Maybe I've a bad perl configuration? I'm known nothing about perl :(

Pablo

#782625#28
Date:
2015-04-24 08:32:55 UTC
From:
To:
After investigating for a while I think I found the problem source. I've
the file "/etc/resolv.conf" as follows:

nameserver localhost
...

I've changed to:

nameserver 127.0.0.1
...

and the error is gone out.

Sorry for the inconvenience and thanks a lot for your help.

Pablo