summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNigel Metheringham <nigel@exim.org>2008-02-12 12:52:51 +0000
committerNigel Metheringham <nigel@exim.org>2008-02-12 12:52:51 +0000
commit65a7d8c381dfb4788ecd5c40a28365acb1f377e1 (patch)
treeaf8ced6390c158bd4de8244e9904ec48fea4d23c /src
parent9befc1368218f1662fd3e876b514262a18bfb9a1 (diff)
Integrated SPF Best Guess. Fixes: bug #521
Diffstat (limited to 'src')
-rw-r--r--src/src/acl.c19
-rw-r--r--src/src/expand.c3
-rw-r--r--src/src/globals.c3
-rw-r--r--src/src/globals.h3
-rw-r--r--src/src/readconf.c5
-rw-r--r--src/src/spf.c13
-rw-r--r--src/src/spf.h8
7 files changed, 43 insertions, 11 deletions
diff --git a/src/src/acl.c b/src/src/acl.c
index e0f01694b..fcafc6b58 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/acl.c,v 1.81 2008/01/17 13:03:35 tom Exp $ */
+/* $Cambridge: exim/src/src/acl.c,v 1.82 2008/02/12 12:52:51 nm4 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -102,6 +102,7 @@ enum { ACLC_ACL,
#endif
#ifdef EXPERIMENTAL_SPF
ACLC_SPF,
+ ACLC_SPF_GUESS,
#endif
ACLC_VERIFY };
@@ -165,6 +166,7 @@ static uschar *conditions[] = {
#endif
#ifdef EXPERIMENTAL_SPF
US"spf",
+ US"spf_guess",
#endif
US"verify" };
@@ -300,6 +302,7 @@ static uschar cond_expand_at_top[] = {
#endif
#ifdef EXPERIMENTAL_SPF
TRUE, /* spf */
+ TRUE, /* spf_guess */
#endif
TRUE /* verify */
};
@@ -363,6 +366,7 @@ static uschar cond_modifiers[] = {
#endif
#ifdef EXPERIMENTAL_SPF
FALSE, /* spf */
+ FALSE, /* spf_guess */
#endif
FALSE /* verify */
};
@@ -547,6 +551,14 @@ static unsigned int cond_forbids[] = {
(1<<ACL_WHERE_STARTTLS)|(1<<ACL_WHERE_VRFY)|
(1<<ACL_WHERE_NOTSMTP)|
(1<<ACL_WHERE_NOTSMTP_START),
+
+ (1<<ACL_WHERE_AUTH)|(1<<ACL_WHERE_CONNECT)| /* spf_guess */
+ (1<<ACL_WHERE_HELO)|
+ (1<<ACL_WHERE_MAILAUTH)|
+ (1<<ACL_WHERE_ETRN)|(1<<ACL_WHERE_EXPN)|
+ (1<<ACL_WHERE_STARTTLS)|(1<<ACL_WHERE_VRFY)|
+ (1<<ACL_WHERE_NOTSMTP)|
+ (1<<ACL_WHERE_NOTSMTP_START),
#endif
/* Certain types of verify are always allowed, so we let it through
@@ -3134,7 +3146,10 @@ for (; cb != NULL; cb = cb->next)
#ifdef EXPERIMENTAL_SPF
case ACLC_SPF:
- rc = spf_process(&arg, sender_address);
+ rc = spf_process(&arg, sender_address, SPF_PROCESS_NORMAL);
+ break;
+ case ACLC_SPF_GUESS:
+ rc = spf_process(&arg, sender_address, SPF_PROCESS_GUESS);
break;
#endif
diff --git a/src/src/expand.c b/src/src/expand.c
index beb72aa67..b2d0fb4ae 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/expand.c,v 1.92 2008/01/17 13:03:35 tom Exp $ */
+/* $Cambridge: exim/src/src/expand.c,v 1.93 2008/02/12 12:52:51 nm4 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -575,6 +575,7 @@ static var_entry var_table[] = {
{ "spam_score_int", vtype_stringptr, &spam_score_int },
#endif
#ifdef EXPERIMENTAL_SPF
+ { "spf_guess", vtype_stringptr, &spf_guess },
{ "spf_header_comment", vtype_stringptr, &spf_header_comment },
{ "spf_received", vtype_stringptr, &spf_received },
{ "spf_result", vtype_stringptr, &spf_result },
diff --git a/src/src/globals.c b/src/src/globals.c
index e7efebffa..93f74910c 100644
--- a/src/src/globals.c
+++ b/src/src/globals.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.c,v 1.80 2008/01/17 13:03:35 tom Exp $ */
+/* $Cambridge: exim/src/src/globals.c,v 1.81 2008/02/12 12:52:51 nm4 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -1136,6 +1136,7 @@ uschar *spam_score = NULL;
uschar *spam_score_int = NULL;
#endif
#ifdef EXPERIMENTAL_SPF
+uschar *spf_guess = US"v=spf1 a/24 mx/24 ptr ?all";
uschar *spf_header_comment = NULL;
uschar *spf_received = NULL;
uschar *spf_result = NULL;
diff --git a/src/src/globals.h b/src/src/globals.h
index 4172c7355..ac425ed98 100644
--- a/src/src/globals.h
+++ b/src/src/globals.h
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.h,v 1.61 2008/01/17 13:03:35 tom Exp $ */
+/* $Cambridge: exim/src/src/globals.h,v 1.62 2008/02/12 12:52:51 nm4 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -705,6 +705,7 @@ extern uschar *spam_score; /* the spam score (float) */
extern uschar *spam_score_int; /* spam_score * 10 (int) */
#endif
#ifdef EXPERIMENTAL_SPF
+extern uschar *spf_guess; /* spf best-guess record */
extern uschar *spf_header_comment; /* spf header comment */
extern uschar *spf_received; /* Received-SPF: header */
extern uschar *spf_result; /* spf result in string form */
diff --git a/src/src/readconf.c b/src/src/readconf.c
index 0a577f7db..2e65cd970 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/readconf.c,v 1.34 2008/01/17 13:03:35 tom Exp $ */
+/* $Cambridge: exim/src/src/readconf.c,v 1.35 2008/02/12 12:52:51 nm4 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -357,6 +357,9 @@ static optionlist optionlist_config[] = {
#ifdef WITH_CONTENT_SCAN
{ "spamd_address", opt_stringptr, &spamd_address },
#endif
+#ifdef EXPERIMENTAL_SPF
+ { "spf_guess", opt_stringptr, &spf_guess },
+#endif
{ "split_spool_directory", opt_bool, &split_spool_directory },
{ "spool_directory", opt_stringptr, &spool_directory },
#ifdef LOOKUP_SQLITE
diff --git a/src/src/spf.c b/src/src/spf.c
index 0d2316e2e..532f81422 100644
--- a/src/src/spf.c
+++ b/src/src/spf.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/spf.c,v 1.7 2007/05/17 19:55:10 tom Exp $ */
+/* $Cambridge: exim/src/src/spf.c,v 1.8 2008/02/12 12:52:51 nm4 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -73,7 +73,7 @@ int spf_init(uschar *spf_helo_domain, uschar *spf_remote_addr) {
context (if any), retrieves the result, sets up expansion
strings and evaluates the condition outcome. */
-int spf_process(uschar **listptr, uschar *spf_envelope_sender) {
+int spf_process(uschar **listptr, uschar *spf_envelope_sender, int action) {
int sep = 0;
uschar *list = *listptr;
uschar *spf_result_id;
@@ -93,7 +93,10 @@ int spf_process(uschar **listptr, uschar *spf_envelope_sender) {
}
/* get SPF result */
- SPF_request_query_mailfrom(spf_request, &spf_response);
+ if (action == SPF_PROCESS_FALLBACK)
+ SPF_request_query_fallback(spf_request, &spf_response, spf_guess);
+ else
+ SPF_request_query_mailfrom(spf_request, &spf_response);
/* set up expansion items */
spf_header_comment = (uschar *)SPF_response_get_header_comment(spf_response);
@@ -106,6 +109,10 @@ int spf_process(uschar **listptr, uschar *spf_envelope_sender) {
/* We got a result. Now see if we should return OK or FAIL for it */
SPF_EVALUATE:
debug_printf("SPF result is %s (%d)\n", SPF_strresult(rc), rc);
+
+ if (action == SPF_PROCESS_GUESS && (!strcmp (SPF_strresult(rc), "none")))
+ return spf_process(listptr, spf_envelope_sender, SPF_PROCESS_FALLBACK);
+
while ((spf_result_id = string_nextinlist(&list, &sep,
spf_result_id_buffer,
sizeof(spf_result_id_buffer))) != NULL) {
diff --git a/src/src/spf.h b/src/src/spf.h
index 3e014bdaf..455fbbfd9 100644
--- a/src/src/spf.h
+++ b/src/src/spf.h
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/spf.h,v 1.6 2005/06/27 15:28:45 tom Exp $ */
+/* $Cambridge: exim/src/src/spf.h,v 1.7 2008/02/12 12:52:51 nm4 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -26,6 +26,10 @@ typedef struct spf_result_id {
/* prototypes */
int spf_init(uschar *,uschar *);
-int spf_process(uschar **, uschar *);
+int spf_process(uschar **, uschar *, int);
+
+#define SPF_PROCESS_NORMAL 0
+#define SPF_PROCESS_GUESS 1
+#define SPF_PROCESS_FALLBACK 2
#endif