View | Details | Raw Unified | Return to bug 239334 | Differences between
and this patch

Collapse All | Expand All

(-)milter-greylist/Makefile (-6 / +7 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	milter-greylist
4
PORTNAME=	milter-greylist
5
PORTVERSION=	4.6.2
5
PORTVERSION=	4.6.2
6
PORTREVISION=	4
6
PORTREVISION=	5
7
CATEGORIES=	mail
7
CATEGORIES=	mail
8
MASTER_SITES=	ftp://ftp.espci.fr/pub/milter-greylist/ \
8
MASTER_SITES=	ftp://ftp.espci.fr/pub/milter-greylist/ \
9
		http://fossies.org/unix/privat/
9
		http://fossies.org/unix/privat/
Lines 15-21 Link Here
15
15
16
MAKE_JOBS_UNSAFE=	yes
16
MAKE_JOBS_UNSAFE=	yes
17
17
18
USES=		tar:tgz
18
USES=		tar:tgz autoreconf
19
19
20
##
20
##
21
# Use the following quirks to choose which sendmail to use (ports or system):
21
# Use the following quirks to choose which sendmail to use (ports or system):
Lines 28-37 Link Here
28
# installed port preference over it.
28
# installed port preference over it.
29
##
29
##
30
30
31
OPTIONS_DEFINE=		DKIM SPF CURL LDAP P0F POSTFIX DOCS EXAMPLES
31
OPTIONS_DEFINE=		DKIM SPF MAXMINDDB CURL LDAP P0F POSTFIX DOCS EXAMPLES
32
OPTIONS_DEFAULT=	DKIM SPF CURL
32
OPTIONS_DEFAULT=	DKIM SPF MAXMINDDB
33
DKIM_DESC=		DKIM support
33
DKIM_DESC=		DKIM support
34
SPF_DESC=		SPF support
34
SPF_DESC=		SPF support
35
MAXMINDDB_DESC=		Enable GeoIP1 + GeoIP2 Support
35
CURL_DESC=		curl support
36
CURL_DESC=		curl support
36
P0F_DESC=		P0F support
37
P0F_DESC=		P0F support
37
POSTFIX_DESC=		Use Postfix instead of Sendmail
38
POSTFIX_DESC=		Use Postfix instead of Sendmail
Lines 39-55 Link Here
39
DKIM_LIB_DEPENDS=	libopendkim.so:mail/opendkim
40
DKIM_LIB_DEPENDS=	libopendkim.so:mail/opendkim
40
P0F_RUN_DEPENDS=	p0f:net-mgmt/p0f
41
P0F_RUN_DEPENDS=	p0f:net-mgmt/p0f
41
SPF_LIB_DEPENDS=	libspf2.so:mail/libspf2
42
SPF_LIB_DEPENDS=	libspf2.so:mail/libspf2
43
MAXMINDDB_LIB_DEPENDS=	libmaxminddb.so:net/libmaxminddb
42
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
44
CURL_LIB_DEPENDS=	libcurl.so:ftp/curl
43
45
44
POSTFIX_CONFIGURE_ENABLE=	postfix
46
POSTFIX_CONFIGURE_ENABLE=	postfix
45
POSTFIX_LDFLAGS_OFF=		${SENDMAIL_LDFLAGS}
46
POSTFIX_LIBS_OFF=		${SENDMAIL_LDADD}
47
47
48
P0F_CONFIGURE_ENABLE=		p0f306
48
P0F_CONFIGURE_ENABLE=		p0f306
49
49
50
DKIM_CONFIGURE_ON=		--with-libopendkim=${LOCALBASE}
50
DKIM_CONFIGURE_ON=		--with-libopendkim=${LOCALBASE}
51
DKIM_USES=			ssl
51
DKIM_USES=			ssl
52
SPF_CONFIGURE_ON=		--with-libspf2=${LOCALBASE}
52
SPF_CONFIGURE_ON=		--with-libspf2=${LOCALBASE}
53
MAXMINDDB_CONFIGURE_ON=		--with-libmaxminddb=${LOCALBASE}
53
CURL_CONFIGURE_ON=		--with-libcurl=${LOCALBASE}
54
CURL_CONFIGURE_ON=		--with-libcurl=${LOCALBASE}
54
LDAP_CONFIGURE_ON=		--with-openldap=${LOCALBASE}
55
LDAP_CONFIGURE_ON=		--with-openldap=${LOCALBASE}
55
LDAP_LDFLAGS=			-L${LOCALBASE}/lib
56
LDAP_LDFLAGS=			-L${LOCALBASE}/lib
(-)milter-greylist/files/patch-configure (-12 lines)
Lines 1-12 Link Here
1
Index: configure
2
--- configure.orig	2016-07-12 03:09:29 UTC
3
+++ configure
4
@@ -6083,7 +6083,7 @@ if test "${ac_cv_lib_pthread_pthread_cre
5
   $as_echo_n "(cached) " >&6
6
 else
7
   ac_check_lib_save_LIBS=$LIBS
8
-LIBS="-lpthread  $LIBS"
9
+true; #LIBS="-lpthread  $LIBS"
10
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11
 /* end confdefs.h.  */
12
 
(-)milter-greylist/files/patch-greylist.conf (-2 / +2 lines)
Lines 1-4 Link Here
1
--- greylist.conf.orig	2013-01-27 02:10:19 UTC
1
--- greylist.conf.orig	2013-08-13 12:45:08 UTC
2
+++ greylist.conf
2
+++ greylist.conf
3
@@ -9,7 +9,7 @@ pidfile "/var/run/milter-greylist.pid"
3
@@ -9,7 +9,7 @@ pidfile "/var/run/milter-greylist.pid"
4
 socket "/var/milter-greylist/milter-greylist.sock"
4
 socket "/var/milter-greylist/milter-greylist.sock"
Lines 7-11 Link Here
7
-user "smmsp"
7
-user "smmsp"
8
+user "mailnull:mailnull"
8
+user "mailnull:mailnull"
9
 
9
 
10
 
10
 # Log milter-greylist activity to a file
11
 # Log milter-greylist activity to a file
11
 #stat ">>/var/milter-greylist/greylist.log" \
(-)milter-greylist/files/patch-libmaxminddb-support_from_GH-geoip2-fork (+240 lines)
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 \

Return to bug 239334