diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-03-10 16:15:14 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2008-03-10 16:15:14 +0000 |
commit | 3ab46568c7db5b4305a9f376b724e648a065e4ee (patch) | |
tree | ebee567982000d252350c54624edbd68acd97cdb /mflib | |
parent | d7149c558e4caa5625b4b57b4df1b463e945b973 (diff) | |
download | mailfromd-3ab46568c7db5b4305a9f376b724e648a065e4ee.tar.gz mailfromd-3ab46568c7db5b4305a9f376b724e648a065e4ee.tar.bz2 |
Port r1632 of branches/release_4_3_patches.
git-svn-id: file:///svnroot/mailfromd/trunk@1634 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'mflib')
-rw-r--r-- | mflib/match_cidr.mf | 4 | ||||
-rw-r--r-- | mflib/match_dnsbl.mf | 22 | ||||
-rw-r--r-- | mflib/match_rhsbl.mf | 12 | ||||
-rw-r--r-- | mflib/safedb.mf4 | 6 |
4 files changed, 25 insertions, 19 deletions
diff --git a/mflib/match_cidr.mf b/mflib/match_cidr.mf index bb3470ad..24220ab4 100644 --- a/mflib/match_cidr.mf +++ b/mflib/match_cidr.mf @@ -1,5 +1,5 @@ /* Implementation of match_cidr call - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ do if %cidr matches '^(([0-9]{1,3}\.){3}[0-9]{1,3})/([0-9][0-9]?)' return inet_aton(%ipstr) & len_to_netmask(\3) = inet_aton(\1) else - throw invcidr "invalid CIDR (%cidr)" + throw e_invcidr "invalid CIDR (%cidr)" fi return 0 done diff --git a/mflib/match_dnsbl.mf b/mflib/match_dnsbl.mf index 0621a98c..46795a86 100644 --- a/mflib/match_dnsbl.mf +++ b/mflib/match_dnsbl.mf @@ -1,5 +1,6 @@ /* DNSBL checker. Copyright (C) 2006, 2007 Jan Rafaj + Copyright (C) 2008 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,31 +20,32 @@ #pragma regex push +extended -func match_dnsbl(string address, string zone, string range) +func match_dnsbl(string address, string zone, string iprange) returns number do - string rbl_ip - if %range = 'ANY' - set rbl_ip '127.0.0.0/8' + if %iprange = 'ANY' + set iprange '127.0.0.0/8' + m4_ifdef(`LAZY_MATCH_RBL',` else - set rbl_ip %range - if not %range matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$' + if not %iprange matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$`'''` return 0 fi fi - if not (%address matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$' - and %address != %range) - return 0 + if not (%address matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}$`'''` + and %address != %iprange) + return 0') fi if %address matches '^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$' - if match_cidr (resolve ("\4.\3.\2.\1", %zone), %rbl_ip) + if match_cidr (resolve ("\4.\3.\2.\1", %zone), %iprange) return 1 else return 0 fi + else + throw e_invip "%address: invalid IP address" fi # never reached done diff --git a/mflib/match_rhsbl.mf b/mflib/match_rhsbl.mf index 9b2a492a..6e011967 100644 --- a/mflib/match_rhsbl.mf +++ b/mflib/match_rhsbl.mf @@ -1,5 +1,6 @@ /* RHSBL checker. Copyright (C) 2006, 2007 Jan Rafaj + Copyright (C) 2008 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,14 +19,17 @@ #require match_cidr #pragma regex push +extended -func match_rhsbl(string email, string zone, string range) +func match_rhsbl(string email, string zone, string iprange) returns number do - if not (%email matches '@.+$' - and %range matches '^([0-9]{1,3}\.){3}[0-9]{1,3}$') + if %iprange = 'ANY' + set iprange '127.0.0.0/8' + fi + if not (%email matches '@.+$'m4_ifdef(`LAZY_MATCH_RBL',` + and %iprange matches `'''`^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}$'`'')) return 0 fi - return match_cidr (resolve ((domainpart %email), %zone), %range) + return match_cidr (resolve ((domainpart %email), %zone), %iprange) done #pragma regex pop diff --git a/mflib/safedb.mf4 b/mflib/safedb.mf4 index f1d98b8a..822d3c7a 100644 --- a/mflib/safedb.mf4 +++ b/mflib/safedb.mf4 @@ -1,5 +1,5 @@ /* Safe DB I/O - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2008 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ func safedbget(string name, string key ; string defval, number null) returns string do - catch dbfailure + catch e_dbfailure do return "" done @@ -34,7 +34,7 @@ done func safedbput(string name, string key, string value ; number null) do - catch dbfailure + catch e_dbfailure do return done |