https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8054

            Bug ID: 8054
           Summary: Test failures in IPv6-only environments
           Product: Spamassassin
           Version: 4.0.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Building & Packaging
          Assignee: dev@spamassassin.apache.org
          Reporter: fr...@morgul.net
  Target Milestone: Undefined

Created attachment 5832
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=5832&action=edit
standalone repro

Several of the debian.org build systems are configured with only IPv6
addresses, with no IPv4 addresses (including 127.0.0.1) configured.  A number
of tests fail in this environment, as shown in build logs for 4.0.0 RC3 at
https://buildd.debian.org/status/fetch.php?pkg=spamassassin&arch=i386&ver=4.0.0%7Erc3-1&stamp=1664047286&raw=0

The issue seems to be with the code to detect the supported address families in
SATest.pm:

https://svn.apache.org/viewvc/spamassassin/trunk/t/SATest.pm?revision=1903581&view=markup#l52

  $have_inet4 = eval {
    require IO::Socket::INET;
    my $sock = IO::Socket::INET->new(LocalAddr => '0.0.0.0', Proto => 'udp');
    $sock->close or die "error closing inet socket: $!"  if $sock;
    $sock ? 1 : undef;
  };

  $have_inet6 = eval {
    require IO::Socket::INET6;
    my $sock = IO::Socket::INET6->new(LocalAddr => '::', Proto => 'udp');
    $sock->close or die "error closing inet6 socket: $!"  if $sock;
    $sock ? 1 : undef;
  };

Binding to 0.0.0.0 will succeed if IPv4 is supported, even if there aren't any
actual addresses configured on the host.  So this check ends up passing,
indicating IPv4 support, but later when running tests that involve spamd, it's
configured to bind to 127.0.0.1 and spamc is configured to use that as the
spamd host, which fails because that address isn't present locally.

We can see this if we extract the above code into a standalone program (see
attached) and running it with the following interface configuration:

builder@87459c532e90:/src/spamassassin$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group
default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
29: eth0@if30: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group
default 
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0

builder@87459c532e90:/src/spamassassin$ ./repro.pl 0.0.0.0
inet4 is supported
inet6 is supported

If we change the code to bind to 127.0.0.1 rather than 0.0.0.0, the test works
as intended:

builder@87459c532e90:/src/spamassassin$ ./repro.pl 127.0.0.1
inet6 is supported

Because this correctly identifies a lack of an IPv4 loopback address, tests are
performed using IPv6 and pass as expected.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to