bug-mailfromd
Re: [Bug-mailfromd] spam getting through in 9.0 on custom module
Marc <Marc@xxxxxxxxxxxxxxxxx> ha escrit:
> I have this code/module[1]. It looks like this is not working any more
> since upgrading to 9.0 I have. Nothing is being matched. Any idea what
> this can be? Or maybe there is a new solution for this?
The NEWS file for version 8.17 (sic) states that:
** primitive_resolve and resolve functions
string primitive_resolve (string HOST; string DOMAIN, number FAMILY)
string resolve (string HOST; string DOMAIN, number FAMILY)
The use of DOMAIN argument is deprecated.
...
Then, the documentation for primitive_resolve[1] says:
string primitive_resolve (string host, [string domain, number family])
...
If a non-empty string is given as domain, the function works as
follows:
...
[if] host is a string representation of an IPv4 address the address
is reversed, then a dot and domainâare appended to it. Finally, the
DNS is queried for an Aârecord of the resulting name.
Thus,
primitive_resolve("192.0.2.1", "rev.example.com")
is equivalent to
primitive_resolve("1.2.0.192.rev.example.com")
This all boils down to the following: replace the following line in
match_dnsbl_range:
string res resolve ("\4.\3.\2.\1", zone)
with
string res resolve (address, zone)
and it will work as expected. Notice, however, that each call to
match_dnsbl_ret can result in up to N calls to resolve, where N is
number of variadic arguments. Obviously this slows down your program.
Besides, as noticed above, the use of domain argument is deprecated.
The proper solution therefore would be to rewrite match_dnsbl_range as
follows:
func match_dnsbl_range(string address, string zone, string ...)
returns number
do
set res dns_query(DNS_TYPE_A, reverse_ipstr(address).".".zone)
if res >= 0
loop for set i 0,
while i < dns_reply_count(res),
set i i + 1
do
set a dns_reply_string(res, i)
loop for number j 1,
while j < $# - @zone,
set j j + 1
do
set iprange $(j)
if iprange = 'ANY'
set iprange '127.0.0.0/8'
fi
if match_cidr(a, iprange)
set dnsbl_result a
dns_reply_release(res)
return 1
fi
done
done
dns_reply_release(res)
fi
return 0
done
Then you can use it instead of match_dnsbl_ret
Kind regards,
Sergey
[1] https://www.gnu.org.ua/software/mailfromd/manual/Simplified-DNS-functions.html#index-primitive_005fresolve