]> git.pld-linux.org Git - packages/spamassassin.git/blob - spamassassin-bug-4619.patch
- require and conflict for older IO::Socket::INET6
[packages/spamassassin.git] / spamassassin-bug-4619.patch
1 Index: lib/Mail/SpamAssassin.pm
2 ===================================================================
3 --- lib/Mail/SpamAssassin.pm    (revision 322461)
4 +++ lib/Mail/SpamAssassin.pm    (working copy)
5 @@ -206,6 +206,11 @@
6  override the settings for C<rules_filename>, C<site_rules_filename>,
7  and C<userprefs_filename>.
8  
9 +=item force_ipv4
10 +
11 +If set to 1, DNS tests will not attempt to use IPv6. Use if the existing tests
12 +for IPv6 availablity produce incorrect results or crashes.
13 +
14  =item languages_filename
15  
16  If you want to be able to use the language-guessing rule
17 Index: lib/Mail/SpamAssassin/DnsResolver.pm
18 ===================================================================
19 --- lib/Mail/SpamAssassin/DnsResolver.pm        (revision 322461)
20 +++ lib/Mail/SpamAssassin/DnsResolver.pm        (working copy)
21 @@ -44,7 +44,7 @@
22  use IO::Socket::INET;
23  use Errno qw(EINVAL EADDRINUSE);
24  
25 -use constant HAS_SOCKET_INET6 => eval { require IO::Socket::INET6 };
26 +use constant HAS_SOCKET_INET6 => eval { require IO::Socket::INET6; defined AF_INET6 };
27  
28  our @ISA = qw();
29  
30 @@ -81,13 +81,26 @@
31  
32    if (defined $self->{res}) { return 1; }
33    $self->{no_resolver} = 1;
34 -
35 +  # force only ipv4 if no IO::Socket::INET6 or ipv6 doesn't work
36 +  my $force_ipv4 = (!HAS_SOCKET_INET6) || $self->{main}->{force_ipv4} ||
37 +    !eval {
38 +      my $sock6 = IO::Socket::INET6->new(
39 +                                         LocalAddr => "::",
40 +                                         Proto     => 'udp',
41 +                                         );
42 +      if ($sock6) {
43 +        $sock6->close();
44 +        1;
45 +      }
46 +    };
47 +  
48    eval {
49      require Net::DNS;
50      $self->{res} = Net::DNS::Resolver->new;
51      if (defined $self->{res}) {
52        $self->{no_resolver} = 0;
53 -      $self->{retry} = 1;               # retries for non-nackgrounded query
54 +      $self->{force_ipv4} = $force_ipv4;
55 +      $self->{retry} = 1;               # retries for non-backgrounded query
56        $self->{retrans} = 3;   # initial timeout for "non-backgrounded" query run in background
57        $self->{res}->retry(1);           # If it fails, it fails
58        $self->{res}->retrans(0);         # If it fails, it fails
59 @@ -97,10 +110,12 @@
60        $self->{res}->udp_timeout(3);     # timeout of 3 seconds only
61        $self->{res}->persistent_tcp(0);  # bug 3997
62        $self->{res}->persistent_udp(0);  # bug 3997
63 +      $self->{res}->force_v4($force_ipv4);
64      }
65      1;
66    };   #  or warn "dns: eval failed: $@ $!\n";
67  
68 +  dbg("dns: no ipv6") if $force_ipv4;
69    dbg("dns: is Net::DNS::Resolver available? " .
70         ($self->{no_resolver} ? "no" : "yes"));
71    if (!$self->{no_resolver} && defined $Net::DNS::VERSION) {
72 @@ -123,7 +138,7 @@
73  
74  =item $res->nameservers()
75  
76 -Wrapper for Net::DNS::Reslolver->nameservers to get or set list of nameservers
77 +Wrapper for Net::DNS::Resolver->nameservers to get or set list of nameservers
78  
79  =cut
80  
81 @@ -156,13 +171,14 @@
82    my $ip64 = IP_ADDRESS;
83    my $ip4 = IPV4_ADDRESS;
84    my $ns = $self->{res}->{nameservers}[0];
85 -  my $ipv6 = 0;
86 +  my $ipv6 = 0; # this will be set if we have an ipv6 nameserver
87 +  my $ipv6opt = !($self->{force_ipv4});
88  
89    # now, attempt to set the family to AF_INET6 if we can.  Some
90    # platforms don't have it (bug 4412 comment 29)...
91    # also, only set $ipv6 to true if that succeeds.
92    my $family;
93 -  if (HAS_SOCKET_INET6 && $ns=~/^${ip64}$/o && $ns!~/^${ip4}$/o) {
94 +  if ($ipv6opt && $ns=~/^${ip64}$/o && $ns!~/^${ip4}$/o) {
95      eval '$family = AF_INET6; $ipv6 = 1;';
96    }
97    if (!defined $family) {
98 @@ -186,7 +202,7 @@
99          Domain => $family,
100      );
101  
102 -    if (HAS_SOCKET_INET6) {
103 +    if ($ipv6opt) {
104        $sock = IO::Socket::INET6->new(%args);
105      } else {
106        $sock = IO::Socket::INET->new(%args);
107 Index: lib/spamassassin-run.pod
108 ===================================================================
109 --- lib/spamassassin-run.pod    (revision 322461)
110 +++ lib/spamassassin-run.pod    (working copy)
111 @@ -59,6 +59,7 @@
112   --add-addr-to-whitelist=addr      Add addr to persistent address whitelist
113   --add-addr-to-blacklist=addr      Add addr to persistent address blacklist
114   --remove-addr-from-whitelist=addr Remove addr from persistent address list
115 + --ipv4only, --ipv4-only, --ipv4   Disable attempted use of ipv6 for DNS
116   --progress                        Print progress bar
117   -D, --debug [area=n,...]          Print debugging messages
118   -V, --version                     Print version
119 @@ -198,6 +199,12 @@
120  you must be running C<spamassassin> or C<spamd> with a persistent address
121  list plugin enabled for this to work.
122  
123 +=item B< --ipv4only>, B<--ipv4-only>, B<--ipv4>
124 +
125 +Do not use IPv6 for DNS tests. Normally, SpamAssassin will try to detect if
126 +IPv6 is available, using only IPv4 if it is not. Use if the existing tests
127 +for IPv6 availablity produce incorrect results or crashes.
128 +
129  =item B<-L>, B<--local>
130  
131  Do only the ''local'' tests, ones that do not require an internet connection to
132 Index: spamassassin.raw
133 ===================================================================
134 --- spamassassin.raw    (revision 322461)
135 +++ spamassassin.raw    (working copy)
136 @@ -175,6 +175,7 @@
137    'debug|D:s'                               => \$opt{'debug'},
138    'error-code|exit-code|e:i'                => \$opt{'error-code'},
139    'help|h|?'                                => \$opt{'help'},
140 +  'ipv4only|ipv4-only|ipv4'                 => \$opt{'force_ipv4'},
141    'lint'                                    => \$opt{'lint'},
142    'local-only|local|L'                      => \$opt{'local'},
143    'mbox'                                    => sub { $opt{'format'} = 'mbox'; },
144 @@ -240,6 +241,7 @@
145      rules_filename      => $opt{'configpath'},
146      site_rules_filename => $opt{'siteconfigpath'},
147      userprefs_filename  => $opt{'prefspath'},
148 +    force_ipv4          => $opt{'force_ipv4'},
149      local_tests_only    => $opt{'local'},
150      debug               => $opt{'debug'},
151      dont_copy_prefs     => ( $opt{'create-prefs'} ? 0 : 1 ),
152 Index: spamd/spamd.raw
153 ===================================================================
154 --- spamd/spamd.raw     (revision 322461)
155 +++ spamd/spamd.raw     (working copy)
156 @@ -166,6 +166,7 @@
157    'helper-home-dir|H:s'      => \$opt{'home_dir_for_helpers'},
158    'help|h'                   => \$opt{'help'},
159    'ident-timeout=f'          => \$opt{'ident-timeout'},
160 +  'ipv4only|ipv4-only|ipv4'  => \$opt{'force_ipv4'},
161    'ldap-config!'             => \$opt{'ldap-config'},
162    'listen-ip|ip-address|i:s' => \$opt{'listen-ip'},
163    'local!'                   => \$opt{'local'},
164 @@ -685,6 +686,7 @@
165      dont_copy_prefs      => $dontcopy,
166      rules_filename       => ( $opt{'configpath'} || 0 ),
167      site_rules_filename  => ( $opt{'siteconfigpath'} || 0 ),
168 +    force_ipv4           => ( $opt{'force_ipv4'} || 0 ),
169      local_tests_only     => ( $opt{'local'} || 0 ),
170      debug                => ( $opt{'debug'} || 0 ),
171      paranoid             => ( $opt{'paranoid'} || 0 ),
172 @@ -2181,6 +2183,7 @@
173   -d, --daemonize                    Daemonize
174   -h, --help                         Print usage message.
175   -i [ipaddr], --listen-ip=ipaddr    Listen on the IP ipaddr
176 + --ipv4only, --ipv4-only, --ipv4    Disable attempted use of ipv6 for DNS
177   -p port, --port=port               Listen on specified port
178   -m num, --max-children=num         Allow maximum num children
179   --min-children=num                 Allow minimum num children
180 @@ -2499,6 +2502,11 @@
181  Higher priority informational messages that are suitable for logging in normal
182  circumstances are available with an area of "info".
183  
184 +=item B< --ipv4only>, B<--ipv4-only>, B<--ipv4>
185 +
186 +Do not use IPv6 for DNS tests. Use if the existing tests
187 +for IPv6 availablity produce incorrect results or crashes.
188 +
189  =item B<-L>, B<--local>
190  
191  Perform only local tests on all mail.  In other words, skip DNS and other
This page took 0.03291 seconds and 3 git commands to generate.