|
Line 0
Link Here
|
|
|
1 |
--- README.orig 2016-01-31 05:37:00 UTC |
| 2 |
+++ README |
| 3 |
@@ -60,7 +60,7 @@ Build dependencies: |
| 4 |
Optional dependencies: |
| 5 |
- libspf2, libspf_alt or libspf, for SPF support |
| 6 |
- libcurl, for URL checks support |
| 7 |
-- libGeoIP, for GeoIP support |
| 8 |
+- libmaxminddb, for GeoIP2 support |
| 9 |
- libbind from BIND 9, for DNSRBL support, except if your system has a |
| 10 |
thread-safe DNS resolver built-in. |
| 11 |
|
| 12 |
--- conf_yacc.y.orig 2016-11-24 04:11:37 UTC |
| 13 |
+++ conf_yacc.y |
| 14 |
@@ -57,7 +57,7 @@ __RCSID("$Id: conf_yacc.y,v 1.129 2016/11/24 04:11:37 |
| 15 |
#endif |
| 16 |
#include "prop.h" |
| 17 |
#ifdef USE_GEOIP |
| 18 |
-#include "geoip.h" |
| 19 |
+#include "maxminddb.h" |
| 20 |
#endif |
| 21 |
#ifdef USE_P0F |
| 22 |
#include "p0f.h" |
| 23 |
@@ -149,7 +149,6 @@ lines : lines netblock '\n' |
| 24 |
| lines socket '\n' |
| 25 |
| lines user '\n' |
| 26 |
| lines geoipdb '\n' |
| 27 |
- | lines geoipv6db '\n' |
| 28 |
| lines nodetach '\n' |
| 29 |
| lines lazyaw '\n' |
| 30 |
| lines report '\n' |
| 31 |
@@ -764,19 +763,6 @@ geoipdb: GEOIPDB QSTRING { |
| 32 |
char path[QSTRLEN + 1]; |
| 33 |
|
| 34 |
geoip_set_db(quotepath(path, $2, QSTRLEN)); |
| 35 |
-#else |
| 36 |
- mg_log(LOG_INFO, |
| 37 |
- "GeoIP support not compiled in, " |
| 38 |
- "ignore line %d", |
| 39 |
- conf_line); |
| 40 |
-#endif |
| 41 |
- } |
| 42 |
- ; |
| 43 |
-geoipv6db: GEOIPV6DB QSTRING { |
| 44 |
-#ifdef USE_GEOIP |
| 45 |
- char path[QSTRLEN + 1]; |
| 46 |
- |
| 47 |
- geoip_set_db_v6(quotepath(path, $2, QSTRLEN)); |
| 48 |
#else |
| 49 |
mg_log(LOG_INFO, |
| 50 |
"GeoIP support not compiled in, " |
| 51 |
--- configure.ac.orig 2016-11-24 04:14:01 UTC |
| 52 |
+++ configure.ac |
| 53 |
@@ -455,10 +455,10 @@ LDFLAGS=$SAVEDLDFLAGS |
| 54 |
CFLAGS=$SAVEDCFLAGS |
| 55 |
LIBS=$SAVEDLIBS |
| 56 |
|
| 57 |
-AC_ARG_WITH(libGeoIP, |
| 58 |
- [ --with-libGeoIP=DIR Find libGeoIP in DIR], |
| 59 |
+AC_ARG_WITH(libmaxminddb, |
| 60 |
+ [ --with-libmaxminddb=DIR Find GeoIP2 libmaxminddb in DIR], |
| 61 |
[CFLAGS=$CFLAGS" -I$withval/include -DUSE_GEOIP" |
| 62 |
- LIBS="-lGeoIP $LIBS" |
| 63 |
+ LIBS="-lmaxminddb $LIBS" |
| 64 |
LDFLAGS=$LDFLAGS" -L$withval/lib -Wl,$rpath$withval/lib"]) |
| 65 |
AC_ARG_WITH(libdmalloc, |
| 66 |
[ --with-libdmalloc=DIR Find libdmalloc in DIR], |
| 67 |
--- geoip.c.orig 2016-11-24 04:11:37 UTC |
| 68 |
+++ geoip.c |
| 69 |
@@ -48,7 +48,7 @@ __RCSID("$Id"); |
| 70 |
#include <sysexits.h> |
| 71 |
#include <sys/param.h> |
| 72 |
|
| 73 |
-#include <GeoIP.h> |
| 74 |
+#include <maxminddb.h> |
| 75 |
|
| 76 |
#include "milter-greylist.h" |
| 77 |
#include "conf.h" |
| 78 |
@@ -58,10 +58,9 @@ __RCSID("$Id"); |
| 79 |
#include <dmalloc.h> |
| 80 |
#endif |
| 81 |
|
| 82 |
-static GeoIP *geoip_handle = NULL; |
| 83 |
-static GeoIP *geoip_handle_v6 = NULL; |
| 84 |
+static MMDB_s mmdb; |
| 85 |
+static MMDB_s *geoip_handle = &mmdb; |
| 86 |
static char geoip_database[MAXPATHLEN + 1]; |
| 87 |
-static char geoip_database_v6[MAXPATHLEN + 1]; |
| 88 |
static pthread_rwlock_t geoip_lock; |
| 89 |
|
| 90 |
void |
| 91 |
@@ -83,43 +82,21 @@ geoip_set_db(name) |
| 92 |
char *name; |
| 93 |
{ |
| 94 |
if (geoip_handle != NULL) { |
| 95 |
- GeoIP_delete(geoip_handle); |
| 96 |
- geoip_handle = NULL; |
| 97 |
+ MMDB_close(geoip_handle); |
| 98 |
} |
| 99 |
|
| 100 |
strncpy(geoip_database, name, MAXPATHLEN); |
| 101 |
geoip_database[MAXPATHLEN] = '\0'; |
| 102 |
|
| 103 |
- geoip_handle = GeoIP_open(geoip_database, GEOIP_STANDARD); |
| 104 |
- if (geoip_handle == NULL) { |
| 105 |
+ int status = MMDB_open(geoip_database, MMDB_MODE_MMAP, geoip_handle); |
| 106 |
+ if (status != MMDB_SUCCESS) { |
| 107 |
mg_log(LOG_WARNING, |
| 108 |
- "GeoIP databade \"%s\" cannot be used", |
| 109 |
+ "GeoIP database \"%s\" cannot be used", |
| 110 |
geoip_database); |
| 111 |
return; |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
-void |
| 116 |
-geoip_set_db_v6(name) |
| 117 |
- char *name; |
| 118 |
-{ |
| 119 |
- if (geoip_handle_v6 != NULL) { |
| 120 |
- GeoIP_delete(geoip_handle_v6); |
| 121 |
- geoip_handle_v6 = NULL; |
| 122 |
- } |
| 123 |
- |
| 124 |
- strncpy(geoip_database_v6, name, MAXPATHLEN); |
| 125 |
- geoip_database_v6[MAXPATHLEN] = '\0'; |
| 126 |
- |
| 127 |
- geoip_handle_v6 = GeoIP_open(geoip_database_v6, GEOIP_STANDARD); |
| 128 |
- if (geoip_handle_v6 == NULL) { |
| 129 |
- mg_log(LOG_WARNING, |
| 130 |
- "GeoIPv6 databade \"%s\" cannot be used", |
| 131 |
- geoip_database_v6); |
| 132 |
- return; |
| 133 |
- } |
| 134 |
-} |
| 135 |
- |
| 136 |
int |
| 137 |
geoip_filter(ad, stage, ap, priv) |
| 138 |
acl_data_t *ad; |
| 139 |
@@ -142,33 +119,9 @@ void |
| 140 |
geoip_set_ccode(priv) |
| 141 |
struct mlfi_priv *priv; |
| 142 |
{ |
| 143 |
- GEOIP_API const char *(*country_code_by_addr)(GeoIP *, const char *); |
| 144 |
- GeoIP *handle; |
| 145 |
char ipstr[IPADDRSTRLEN]; |
| 146 |
+ int gai_error, mmdb_error; |
| 147 |
|
| 148 |
- switch (SA(&priv->priv_addr)->sa_family) { |
| 149 |
- case AF_INET: |
| 150 |
- country_code_by_addr = GeoIP_country_code_by_addr; |
| 151 |
- handle = geoip_handle; |
| 152 |
- break; |
| 153 |
-#ifdef AF_INET6 |
| 154 |
- case AF_INET6: |
| 155 |
- country_code_by_addr = GeoIP_country_code_by_addr_v6; |
| 156 |
- handle = geoip_handle_v6; |
| 157 |
- break; |
| 158 |
-#endif |
| 159 |
- default: |
| 160 |
- mg_log(LOG_DEBUG, "GeoIP not supported address family"); |
| 161 |
- priv->priv_ccode = NULL; |
| 162 |
- return; |
| 163 |
- } |
| 164 |
- |
| 165 |
- if (geoip_handle == NULL) { |
| 166 |
- mg_log(LOG_DEBUG, "GeoIP is not available"); |
| 167 |
- priv->priv_ccode = NULL; |
| 168 |
- return; |
| 169 |
- } |
| 170 |
- |
| 171 |
if (iptostring(SA(&priv->priv_addr), |
| 172 |
priv->priv_addrlen, ipstr, sizeof(ipstr)) == NULL) { |
| 173 |
mg_log(LOG_DEBUG, "GeoIP iptostring failed"); |
| 174 |
@@ -177,7 +130,19 @@ geoip_set_ccode(priv) |
| 175 |
} |
| 176 |
|
| 177 |
WRLOCK(geoip_lock); |
| 178 |
- priv->priv_ccode = country_code_by_addr(handle, ipstr); |
| 179 |
+ MMDB_lookup_result_s result = MMDB_lookup_string(geoip_handle, ipstr, &gai_error, &mmdb_error); |
| 180 |
+ if (gai_error == 0) { |
| 181 |
+ if (mmdb_error == MMDB_SUCCESS) { |
| 182 |
+ MMDB_entry_data_s entry_data; |
| 183 |
+ int status = MMDB_get_value(&result.entry, &entry_data, "country", "iso_code", NULL); |
| 184 |
+ if (status == MMDB_SUCCESS) { |
| 185 |
+ if (entry_data.has_data) { |
| 186 |
+ priv->priv_ccode = strndup(entry_data.utf8_string, entry_data.data_size); |
| 187 |
+ } |
| 188 |
+ } |
| 189 |
+ } |
| 190 |
+ } |
| 191 |
+ |
| 192 |
UNLOCK(geoip_lock); |
| 193 |
|
| 194 |
if (priv->priv_ccode == NULL) |
| 195 |
--- greylist.conf.5.orig 2016-11-24 04:11:37 UTC |
| 196 |
+++ greylist.conf.5 |
| 197 |
@@ -198,8 +198,6 @@ is used when the country cannot be determined (this ha |
| 198 |
addresses, for instance). The |
| 199 |
.I geoipdb |
| 200 |
statement can be used to specify the location of GeoIP database. |
| 201 |
-.I geoipv6db |
| 202 |
-statement can be used to specify the location of GeoIPv6 database. |
| 203 |
.TP |
| 204 |
.I p0f |
| 205 |
This is used to match against the remote system OS fingerprint genre and |
| 206 |
--- milter-greylist.spec.orig 2016-11-24 04:14:01 UTC |
| 207 |
+++ milter-greylist.spec |
| 208 |
@@ -19,8 +19,8 @@ |
| 209 |
%define libspf2 0 |
| 210 |
%{?build_libspf2:%define libspf2 1} |
| 211 |
|
| 212 |
-%define libGeoIP 0 |
| 213 |
-%{?build_libGeoIP:%define libGeoIP 1} |
| 214 |
+%define libmaxminddb 0 |
| 215 |
+%{?build_libmaxminddb:%define libmaxminddb 1} |
| 216 |
|
| 217 |
%define libcurl 0 |
| 218 |
%{?build_libcurl:%define libcurl 1} |
| 219 |
@@ -66,8 +66,8 @@ BuildRequires: libspf2-devel |
| 220 |
%if %{libcurl} |
| 221 |
BuildRequires: curl-devel |
| 222 |
%endif |
| 223 |
-%if %{libGeoIP} |
| 224 |
-BuildRequires: GeoIP-devel |
| 225 |
+%if %{libmaxminddb} |
| 226 |
+BuildRequires: libmaxminddb-devel |
| 227 |
%endif |
| 228 |
|
| 229 |
%description |
| 230 |
@@ -111,8 +111,8 @@ before the second attempt. |
| 231 |
%if %{libcurl} |
| 232 |
--with-libcurl \ |
| 233 |
%endif |
| 234 |
-%if %{libGeoIP} |
| 235 |
- --with-libGeoIP \ |
| 236 |
+%if %{libmaxminddb} |
| 237 |
+ --with-libmaxminddb \ |
| 238 |
%endif |
| 239 |
%if %{libdkim} |
| 240 |
--with-libdkim=/usr/include \ |