- Add IPv6 AAAA Lookups for MtaHostChk

PR:		196756
Submitted by:	jvp@lateapex.net
This commit is contained in:
Dirk Meyer 2018-01-15 10:55:01 +00:00
parent 8ed156eb79
commit 84e6522e8a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=459031
4 changed files with 87 additions and 1 deletions

View file

@ -2,7 +2,7 @@
PORTNAME= spamilter
PORTVERSION= 0.60
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= mail
MASTER_SITES= http://www.wanlink.com/spamilter/download/

View file

@ -0,0 +1,60 @@
--- dns.c.orig 2005-07-17 19:55:13.000000000 -0500
+++ dns.c 2015-01-21 13:58:59.000000000 -0600
@@ -58,25 +58,48 @@
int dns_query_rr_a(const res_state statp, char *fmt, ...)
{ va_list vl;
- int x,rc = 0;
- char *hn = NULL;
+ int x, haveRR = 0;
+ char *hostName = NULL;
va_start(vl,fmt);
if(fmt != NULL && *fmt)
{
- x = vasprintf(&hn,fmt,vl);
- if(hn != NULL && x > 0)
- { u_char packet[NS_PACKETSZ];
+ x = vasprintf(&hostName,fmt,vl);
+ if(hostName != NULL && x > 0)
+ { u_char ns_packet[NS_PACKETSZ];
- rc = (res_nquery(statp, hn,ns_c_in,ns_t_a,packet,sizeof(packet)) == -1 ? 0 : 1);
+ haveRR = (res_nquery(statp, hostName, ns_c_in, ns_t_a, ns_packet, sizeof(ns_packet)) == -1 ? 0 : 1);
}
- if(hn != NULL)
- free(hn);
+ if(hostName != NULL)
+ free(hostName);
}
va_end(vl);
- return(rc);
+ return haveRR;
+}
+
+int dns_query_rr_aaaa(const res_state statp, char *fmt, ...)
+{ va_list vl;
+ int x, haveRR = 0;
+ char *hostName = NULL;
+
+ va_start(vl,fmt);
+ if(fmt != NULL && *fmt)
+ {
+ x = vasprintf(&hostName,fmt,vl);
+ if(hostName != NULL && x > 0)
+ { u_char ns_packet[NS_PACKETSZ];
+
+ haveRR = (res_nquery(statp, hostName, ns_c_in, ns_t_aaaa, ns_packet, sizeof(ns_packet)) == -1 ? 0 : 1);
+ }
+
+ if(hostName != NULL)
+ free(hostName);
+ }
+ va_end(vl);
+
+ return haveRR;
}
int dns_rdnsbl_has_rr_a(const res_state statp, long ip, char *domain)

View file

@ -0,0 +1,11 @@
--- dns.h.orig 2004-11-25 18:13:49.000000000 -0600
+++ dns.h 2015-01-21 14:06:33.000000000 -0600
@@ -47,6 +47,8 @@
#define mkip(a,b,c,d) ((((a)&0xff)<<24)|(((b)&0xff)<<16)|(((c)&0xff)<<8)|((d)&0xff))
+ int dns_query_rr_aaaa(const res_state statp, char *fmt, ...);
+
int dns_query_rr_a(const res_state statp, char *fmt, ...);
int dns_rdnsbl_has_rr_a(const res_state statp, long ip, char *domain);

View file

@ -0,0 +1,15 @@
--- hndlrs.c.orig 2005-07-17 19:55:13.000000000 -0500
+++ hndlrs.c 2015-01-21 14:47:27.000000000 -0600
@@ -466,7 +466,11 @@
if(gMtaHostIpfw)
mlfi_MtaHostIpfwAction(priv->ipstr,"add");
}
- else if(gMtaHostChk && !priv->islocalnethost && !dns_query_rr_a(priv->statp,priv->helo))
+ else if(gMtaHostChk
+ && !priv->islocalnethost
+ && !dns_query_rr_a(priv->statp,priv->helo)
+ && !dns_query_rr_aaaa(priv->statp,priv->helo)
+ )
{
mlfi_setreply(ctx,550,"5.7.1","Rejecting due to security policy - Invalid hostname '%s', Please see: %s#invalidhostname",priv->helo,gPolicyUrl);
mlfi_debug("envrcpt: Invalid MTA hostname '%s'\n",priv->helo);