FreeBSD Bugzilla – Attachment 206837 Details for
Bug 239334
mail/milter-greylist: Restore GeoIP support, utilizing libmaxminddb
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
milter-greylist.txt (text/plain), 9.89 KB, created by
m.tsatsenko
on 2019-08-24 01:25:30 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
m.tsatsenko
Created:
2019-08-24 01:25:30 UTC
Size:
9.89 KB
patch
obsolete
>diff -urN /usr/ports/mail/milter-greylist/Makefile milter-greylist/Makefile >--- /usr/ports/mail/milter-greylist/Makefile 2019-01-13 23:58:36.000000000 +0300 >+++ milter-greylist/Makefile 2019-08-24 07:23:18.030437000 +0300 >@@ -3,7 +3,7 @@ > > PORTNAME= milter-greylist > PORTVERSION= 4.6.2 >-PORTREVISION= 4 >+PORTREVISION= 5 > CATEGORIES= mail > MASTER_SITES= ftp://ftp.espci.fr/pub/milter-greylist/ \ > http://fossies.org/unix/privat/ >@@ -15,7 +15,7 @@ > > MAKE_JOBS_UNSAFE= yes > >-USES= tar:tgz >+USES= tar:tgz autoreconf > > ## > # Use the following quirks to choose which sendmail to use (ports or system): >@@ -28,10 +28,11 @@ > # installed port preference over it. > ## > >-OPTIONS_DEFINE= DKIM SPF CURL LDAP P0F POSTFIX DOCS EXAMPLES >-OPTIONS_DEFAULT= DKIM SPF CURL >+OPTIONS_DEFINE= DKIM SPF MAXMINDDB CURL LDAP P0F POSTFIX DOCS EXAMPLES >+OPTIONS_DEFAULT= DKIM SPF MAXMINDDB > DKIM_DESC= DKIM support > SPF_DESC= SPF support >+MAXMINDDB_DESC= Enable GeoIP1 + GeoIP2 Support > CURL_DESC= curl support > P0F_DESC= P0F support > POSTFIX_DESC= Use Postfix instead of Sendmail >@@ -39,17 +40,17 @@ > DKIM_LIB_DEPENDS= libopendkim.so:mail/opendkim > P0F_RUN_DEPENDS= p0f:net-mgmt/p0f > SPF_LIB_DEPENDS= libspf2.so:mail/libspf2 >+MAXMINDDB_LIB_DEPENDS= libmaxminddb.so:net/libmaxminddb > CURL_LIB_DEPENDS= libcurl.so:ftp/curl > > POSTFIX_CONFIGURE_ENABLE= postfix >-POSTFIX_LDFLAGS_OFF= ${SENDMAIL_LDFLAGS} >-POSTFIX_LIBS_OFF= ${SENDMAIL_LDADD} > > P0F_CONFIGURE_ENABLE= p0f306 > > DKIM_CONFIGURE_ON= --with-libopendkim=${LOCALBASE} > DKIM_USES= ssl > SPF_CONFIGURE_ON= --with-libspf2=${LOCALBASE} >+MAXMINDDB_CONFIGURE_ON= --with-libmaxminddb=${LOCALBASE} > CURL_CONFIGURE_ON= --with-libcurl=${LOCALBASE} > LDAP_CONFIGURE_ON= --with-openldap=${LOCALBASE} > LDAP_LDFLAGS= -L${LOCALBASE}/lib >diff -urN /usr/ports/mail/milter-greylist/files/patch-configure milter-greylist/files/patch-configure >--- /usr/ports/mail/milter-greylist/files/patch-configure 2016-11-07 15:39:41.000000000 +0300 >+++ milter-greylist/files/patch-configure 1970-01-01 03:00:00.000000000 +0300 >@@ -1,12 +0,0 @@ >-Index: configure >---- configure.orig 2016-07-12 03:09:29 UTC >-+++ configure >-@@ -6083,7 +6083,7 @@ if test "${ac_cv_lib_pthread_pthread_cre >- $as_echo_n "(cached) " >&6 >- else >- ac_check_lib_save_LIBS=$LIBS >--LIBS="-lpthread $LIBS" >-+true; #LIBS="-lpthread $LIBS" >- cat confdefs.h - <<_ACEOF >conftest.$ac_ext >- /* end confdefs.h. */ >- >diff -urN /usr/ports/mail/milter-greylist/files/patch-greylist.conf milter-greylist/files/patch-greylist.conf >--- /usr/ports/mail/milter-greylist/files/patch-greylist.conf 2016-03-22 16:07:56.000000000 +0300 >+++ milter-greylist/files/patch-greylist.conf 2019-08-24 07:08:36.308655000 +0300 >@@ -1,4 +1,4 @@ >---- greylist.conf.orig 2013-01-27 02:10:19 UTC >+--- greylist.conf.orig 2013-08-13 12:45:08 UTC > +++ greylist.conf > @@ -9,7 +9,7 @@ pidfile "/var/run/milter-greylist.pid" > socket "/var/milter-greylist/milter-greylist.sock" >@@ -7,5 +7,5 @@ > -user "smmsp" > +user "mailnull:mailnull" > >+ > # Log milter-greylist activity to a file >- #stat ">>/var/milter-greylist/greylist.log" \ >diff -urN /usr/ports/mail/milter-greylist/files/patch-libmaxminddb-support_from_GH-geoip2-fork milter-greylist/files/patch-libmaxminddb-support_from_GH-geoip2-fork >--- /usr/ports/mail/milter-greylist/files/patch-libmaxminddb-support_from_GH-geoip2-fork 1970-01-01 03:00:00.000000000 +0300 >+++ milter-greylist/files/patch-libmaxminddb-support_from_GH-geoip2-fork 2019-08-24 07:08:36.317655000 +0300 >@@ -0,0 +1,240 @@ >+--- README.orig 2016-01-31 05:37:00 UTC >++++ README >+@@ -60,7 +60,7 @@ Build dependencies: >+ Optional dependencies: >+ - libspf2, libspf_alt or libspf, for SPF support >+ - libcurl, for URL checks support >+-- libGeoIP, for GeoIP support >++- libmaxminddb, for GeoIP2 support >+ - libbind from BIND 9, for DNSRBL support, except if your system has a >+ thread-safe DNS resolver built-in. >+ >+--- conf_yacc.y.orig 2016-11-24 04:11:37 UTC >++++ conf_yacc.y >+@@ -57,7 +57,7 @@ __RCSID("$Id: conf_yacc.y,v 1.129 2016/11/24 04:11:37 >+ #endif >+ #include "prop.h" >+ #ifdef USE_GEOIP >+-#include "geoip.h" >++#include "maxminddb.h" >+ #endif >+ #ifdef USE_P0F >+ #include "p0f.h" >+@@ -149,7 +149,6 @@ lines : lines netblock '\n' >+ | lines socket '\n' >+ | lines user '\n' >+ | lines geoipdb '\n' >+- | lines geoipv6db '\n' >+ | lines nodetach '\n' >+ | lines lazyaw '\n' >+ | lines report '\n' >+@@ -764,19 +763,6 @@ geoipdb: GEOIPDB QSTRING { >+ char path[QSTRLEN + 1]; >+ >+ geoip_set_db(quotepath(path, $2, QSTRLEN)); >+-#else >+- mg_log(LOG_INFO, >+- "GeoIP support not compiled in, " >+- "ignore line %d", >+- conf_line); >+-#endif >+- } >+- ; >+-geoipv6db: GEOIPV6DB QSTRING { >+-#ifdef USE_GEOIP >+- char path[QSTRLEN + 1]; >+- >+- geoip_set_db_v6(quotepath(path, $2, QSTRLEN)); >+ #else >+ mg_log(LOG_INFO, >+ "GeoIP support not compiled in, " >+--- configure.ac.orig 2016-11-24 04:14:01 UTC >++++ configure.ac >+@@ -455,10 +455,10 @@ LDFLAGS=$SAVEDLDFLAGS >+ CFLAGS=$SAVEDCFLAGS >+ LIBS=$SAVEDLIBS >+ >+-AC_ARG_WITH(libGeoIP, >+- [ --with-libGeoIP=DIR Find libGeoIP in DIR], >++AC_ARG_WITH(libmaxminddb, >++ [ --with-libmaxminddb=DIR Find GeoIP2 libmaxminddb in DIR], >+ [CFLAGS=$CFLAGS" -I$withval/include -DUSE_GEOIP" >+- LIBS="-lGeoIP $LIBS" >++ LIBS="-lmaxminddb $LIBS" >+ LDFLAGS=$LDFLAGS" -L$withval/lib -Wl,$rpath$withval/lib"]) >+ AC_ARG_WITH(libdmalloc, >+ [ --with-libdmalloc=DIR Find libdmalloc in DIR], >+--- geoip.c.orig 2016-11-24 04:11:37 UTC >++++ geoip.c >+@@ -48,7 +48,7 @@ __RCSID("$Id"); >+ #include <sysexits.h> >+ #include <sys/param.h> >+ >+-#include <GeoIP.h> >++#include <maxminddb.h> >+ >+ #include "milter-greylist.h" >+ #include "conf.h" >+@@ -58,10 +58,9 @@ __RCSID("$Id"); >+ #include <dmalloc.h> >+ #endif >+ >+-static GeoIP *geoip_handle = NULL; >+-static GeoIP *geoip_handle_v6 = NULL; >++static MMDB_s mmdb; >++static MMDB_s *geoip_handle = &mmdb; >+ static char geoip_database[MAXPATHLEN + 1]; >+-static char geoip_database_v6[MAXPATHLEN + 1]; >+ static pthread_rwlock_t geoip_lock; >+ >+ void >+@@ -83,43 +82,21 @@ geoip_set_db(name) >+ char *name; >+ { >+ if (geoip_handle != NULL) { >+- GeoIP_delete(geoip_handle); >+- geoip_handle = NULL; >++ MMDB_close(geoip_handle); >+ } >+ >+ strncpy(geoip_database, name, MAXPATHLEN); >+ geoip_database[MAXPATHLEN] = '\0'; >+ >+- geoip_handle = GeoIP_open(geoip_database, GEOIP_STANDARD); >+- if (geoip_handle == NULL) { >++ int status = MMDB_open(geoip_database, MMDB_MODE_MMAP, geoip_handle); >++ if (status != MMDB_SUCCESS) { >+ mg_log(LOG_WARNING, >+- "GeoIP databade \"%s\" cannot be used", >++ "GeoIP database \"%s\" cannot be used", >+ geoip_database); >+ return; >+ } >+ } >+ >+-void >+-geoip_set_db_v6(name) >+- char *name; >+-{ >+- if (geoip_handle_v6 != NULL) { >+- GeoIP_delete(geoip_handle_v6); >+- geoip_handle_v6 = NULL; >+- } >+- >+- strncpy(geoip_database_v6, name, MAXPATHLEN); >+- geoip_database_v6[MAXPATHLEN] = '\0'; >+- >+- geoip_handle_v6 = GeoIP_open(geoip_database_v6, GEOIP_STANDARD); >+- if (geoip_handle_v6 == NULL) { >+- mg_log(LOG_WARNING, >+- "GeoIPv6 databade \"%s\" cannot be used", >+- geoip_database_v6); >+- return; >+- } >+-} >+- >+ int >+ geoip_filter(ad, stage, ap, priv) >+ acl_data_t *ad; >+@@ -142,33 +119,9 @@ void >+ geoip_set_ccode(priv) >+ struct mlfi_priv *priv; >+ { >+- GEOIP_API const char *(*country_code_by_addr)(GeoIP *, const char *); >+- GeoIP *handle; >+ char ipstr[IPADDRSTRLEN]; >++ int gai_error, mmdb_error; >+ >+- switch (SA(&priv->priv_addr)->sa_family) { >+- case AF_INET: >+- country_code_by_addr = GeoIP_country_code_by_addr; >+- handle = geoip_handle; >+- break; >+-#ifdef AF_INET6 >+- case AF_INET6: >+- country_code_by_addr = GeoIP_country_code_by_addr_v6; >+- handle = geoip_handle_v6; >+- break; >+-#endif >+- default: >+- mg_log(LOG_DEBUG, "GeoIP not supported address family"); >+- priv->priv_ccode = NULL; >+- return; >+- } >+- >+- if (geoip_handle == NULL) { >+- mg_log(LOG_DEBUG, "GeoIP is not available"); >+- priv->priv_ccode = NULL; >+- return; >+- } >+- >+ if (iptostring(SA(&priv->priv_addr), >+ priv->priv_addrlen, ipstr, sizeof(ipstr)) == NULL) { >+ mg_log(LOG_DEBUG, "GeoIP iptostring failed"); >+@@ -177,7 +130,19 @@ geoip_set_ccode(priv) >+ } >+ >+ WRLOCK(geoip_lock); >+- priv->priv_ccode = country_code_by_addr(handle, ipstr); >++ MMDB_lookup_result_s result = MMDB_lookup_string(geoip_handle, ipstr, &gai_error, &mmdb_error); >++ if (gai_error == 0) { >++ if (mmdb_error == MMDB_SUCCESS) { >++ MMDB_entry_data_s entry_data; >++ int status = MMDB_get_value(&result.entry, &entry_data, "country", "iso_code", NULL); >++ if (status == MMDB_SUCCESS) { >++ if (entry_data.has_data) { >++ priv->priv_ccode = strndup(entry_data.utf8_string, entry_data.data_size); >++ } >++ } >++ } >++ } >++ >+ UNLOCK(geoip_lock); >+ >+ if (priv->priv_ccode == NULL) >+--- greylist.conf.5.orig 2016-11-24 04:11:37 UTC >++++ greylist.conf.5 >+@@ -198,8 +198,6 @@ is used when the country cannot be determined (this ha >+ addresses, for instance). The >+ .I geoipdb >+ statement can be used to specify the location of GeoIP database. >+-.I geoipv6db >+-statement can be used to specify the location of GeoIPv6 database. >+ .TP >+ .I p0f >+ This is used to match against the remote system OS fingerprint genre and >+--- milter-greylist.spec.orig 2016-11-24 04:14:01 UTC >++++ milter-greylist.spec >+@@ -19,8 +19,8 @@ >+ %define libspf2 0 >+ %{?build_libspf2:%define libspf2 1} >+ >+-%define libGeoIP 0 >+-%{?build_libGeoIP:%define libGeoIP 1} >++%define libmaxminddb 0 >++%{?build_libmaxminddb:%define libmaxminddb 1} >+ >+ %define libcurl 0 >+ %{?build_libcurl:%define libcurl 1} >+@@ -66,8 +66,8 @@ BuildRequires: libspf2-devel >+ %if %{libcurl} >+ BuildRequires: curl-devel >+ %endif >+-%if %{libGeoIP} >+-BuildRequires: GeoIP-devel >++%if %{libmaxminddb} >++BuildRequires: libmaxminddb-devel >+ %endif >+ >+ %description >+@@ -111,8 +111,8 @@ before the second attempt. >+ %if %{libcurl} >+ --with-libcurl \ >+ %endif >+-%if %{libGeoIP} >+- --with-libGeoIP \ >++%if %{libmaxminddb} >++ --with-libmaxminddb \ >+ %endif >+ %if %{libdkim} >+ --with-libdkim=/usr/include \
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 239334
:
205923
|
205993
|
206837
|
208287
|
212437
|
216919