Re: [exim-dev] [PATCH] Add support for SPF records in dnsdb …

Top Page
Delete this message
Reply to this message
Author: Janne Snabb
Date:  
To: Phil Pennock
CC: exim-dev
Subject: Re: [exim-dev] [PATCH] Add support for SPF records in dnsdb lookups
On Fri, 18 May 2012, Janne Snabb wrote:

> Yes, thank you! How about something like this additional patch?


Oops, the previous patch was incorrect. It was checking for "type ==
T_SPF" before the type was defined. This should be better. Sorry about
the noise.

---
 doc/doc-docbook/spec.xfpt |    7 ++++---
 src/src/lookups/dnsdb.c   |    8 ++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)


diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index b650fc3..2a81042 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -6790,10 +6790,11 @@ white space is ignored.
 .cindex "TXT record" "in &(dnsdb)& lookup"
 .cindex "SPF record" "in &(dnsdb)& lookup"
 .new
-For TXT and SPF records with multiple items of data, only the first item is returned,
+For TXT records with multiple items of data, only the first item is returned,
 unless a separator for them is specified using a comma after the separator
-character followed immediately by the TXT/SPF record item separator. To concatenate
-items without a separator, use a semicolon instead.
+character followed immediately by the TXT record item separator. To concatenate
+items without a separator, use a semicolon instead. For SPF records the
+default behaviour is to concatenate multiple items without using a separator.
 .wen
 .code
 ${lookup dnsdb{>\n,: txt=a.b.example}}
diff --git a/src/src/lookups/dnsdb.c b/src/src/lookups/dnsdb.c
index 3fd9f98..6181355 100644
--- a/src/src/lookups/dnsdb.c
+++ b/src/src/lookups/dnsdb.c
@@ -246,6 +246,14 @@ if (type == T_PTR && keystring[0] != '<' &&
     string_is_ip_address(keystring, NULL) != 0)
   sep = -1;


+/* SPF strings should be concatenated without a separator, thus make
+ it the default if not defined (see RFC 4408 section 3.1.3).
+ Multiple SPF records are forbidden (section 3.1.2) but are currently
+ not handled specially, thus they are concatenated with \n by default. */
+
+if (type == T_SPF && outsep2 == NULL)
+ outsep2 = US"";
+
/* Now scan the list and do a lookup for each item */

while ((domain = string_nextinlist(&keystring, &sep, buffer, sizeof(buffer)))
--
1.7.9.5