SPF: additional variable $spf_result_guessed; tweak authresults string indicating...
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 22 Mar 2018 13:26:58 +0000 (13:26 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 22 Mar 2018 13:26:58 +0000 (13:26 +0000)
12 files changed:
doc/doc-docbook/spec.xfpt
src/src/dmarc.c
src/src/expand.c
src/src/globals.c
src/src/globals.h
src/src/smtp_in.c
src/src/spf.c
test/confs/4600
test/log/4600
test/rejectlog/4600
test/scripts/4600-SPF/4600
test/stdout/4600

index 295cb15c19c5a4d856292f4cb2adca61bf87f635..a439a7b5e3e0eb9c5a60fde82d72252bd0660726 100644 (file)
@@ -12891,6 +12891,7 @@ is compiled with the content-scanning extension. For details, see section
 .vitem &$spf_header_comment$& &&&
        &$spf_received$& &&&
        &$spf_result$& &&&
+       &$spf_result_guessed$& &&&
        &$spf_smtp_comment$&
 These variables are only available if Exim is built with SPF support.
 For details see section &<<SECSPF>>&.
@@ -39348,6 +39349,11 @@ variables:
   one of pass, fail, softfail, none, neutral, permerror or
   temperror.
 
+.vitem &$spf_result_guessed$&
+.vindex &$spf_result_guessed$&
+  This boolean is trus only if a best-guess operation was used
+  and required in order to obtain a result.
+
 .vitem &$spf_smtp_comment$&
 .vindex &$spf_smtp_comment$&
   This contains a string that can be used in a SMTP response
index ba9aa66959b02964a92f0f8fe5ddffed345b6d6c..1c917aa15623e8c47e23d8eafe777154f356aebd 100644 (file)
@@ -605,7 +605,7 @@ if (dmarc_has_been_checked)
   {
   g = string_append(g, 2, US";\n\tdmarc=", dmarc_pass_fail);
   if (header_from_sender)
-    g = string_append(g, 2, US"header.from=", header_from_sender);
+    g = string_append(g, 2, US" header.from=", header_from_sender);
   }
 return g;
 }
index f1c8544c98a27deec67951e0919b1de5afa20935..a1ac7d1983372323cb6a3523f22a7f1df7215c3d 100644 (file)
@@ -710,6 +710,7 @@ static var_entry var_table[] = {
   { "spf_header_comment",  vtype_stringptr,   &spf_header_comment },
   { "spf_received",        vtype_stringptr,   &spf_received },
   { "spf_result",          vtype_stringptr,   &spf_result },
+  { "spf_result_guessed",  vtype_bool,        &spf_result_guessed },
   { "spf_smtp_comment",    vtype_stringptr,   &spf_smtp_comment },
 #endif
   { "spool_directory",     vtype_stringptr,   &spool_directory },
index 55154646c4691acf15fbeeb486a3e84f7bab473c..aed695066016f5f1288195924e3a1e4f1096154a 100644 (file)
@@ -1382,6 +1382,7 @@ 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;
+BOOL    spf_result_guessed     = FALSE;
 uschar *spf_smtp_comment       = NULL;
 #endif
 
index 7bd681fe9981b41bcb0c16583128de7c1d747ccb..66d6c26be8b9a0c0f2d09f728ddeeb7dce257a4d 100644 (file)
@@ -881,6 +881,7 @@ 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 */
+extern BOOL    spf_result_guessed;     /* spf result is of best-guess operation */
 extern uschar *spf_smtp_comment;       /* spf comment to include in SMTP reply */
 #endif
 extern BOOL    split_spool_directory;  /* TRUE to use multiple subdirs */
index c7eedf34651969376af54b37576f50ccd6f4aa50..7d629816034ff5154f2d704f1f5851298dc9a86c 100644 (file)
@@ -2006,6 +2006,7 @@ prdr_requested = FALSE;
 #endif
 #ifdef SUPPORT_SPF
 spf_header_comment = spf_received = spf_result = spf_smtp_comment = NULL;
+spf_result_guessed = FALSE;
 #endif
 #ifdef EXPERIMENTAL_DMARC
 dmarc_has_been_checked = dmarc_disable_verify = dmarc_enable_forensic = FALSE;
index 12994a690d226b363d1b7a4282cb889925b6b1fa..0f0a05d4dcddd40a2994290052fc0e969d3a9682 100644 (file)
@@ -112,7 +112,10 @@ else
   {
   /* get SPF result */
   if (action == SPF_PROCESS_FALLBACK)
+    {
     SPF_request_query_fallback(spf_request, &spf_response, CS spf_guess);
+    spf_result_guessed = TRUE;
+    }
   else
     SPF_request_query_mailfrom(spf_request, &spf_response);
 
@@ -151,10 +154,17 @@ return FAIL;
 gstring *
 authres_spf(gstring * g)
 {
+uschar * s;
 if (!spf_result) return g;
 
-return string_append(g, 4, US";\n\tspf=", spf_result,
-         US" smtp.mailfrom=", expand_string(US"$sender_address_domain"));
+g = string_append(g, 2, US";\n\tspf=", spf_result);
+if (spf_result_guessed)
+  g = string_cat(g, US" (best guess record for domain)");
+
+s = expand_string(US"$sender_address_domain");
+return s && *s
+  ? string_append(g, 2, US" smtp.mailfrom=", s)
+  : string_cat(g, US" smtp.mailfrom=<>");
 }
 
 
index 2934bf160386330c703974e87842ca9f961a785e..cce583909e5248e42cf70b5586bb24802ffa18a6 100644 (file)
@@ -13,7 +13,7 @@ begin acl
 check_rcpt:
   accept       hosts =         HOSTIPV4
                spf_guess =     pass
-               logwrite =      spf_result         $spf_result
+               logwrite =      spf_result         $spf_result (guess <$spf_result_guessed>)
                logwrite =      spf_header_comment $spf_header_comment
                logwrite =      spf_smtp_comment   $spf_smtp_comment
                logwrite =      spf_received       $spf_received
@@ -28,7 +28,7 @@ check_rcpt:
                logwrite =      ${authresults {$primary_hostname}}
 
   deny
-               logwrite =      spf_result         $spf_result
+               logwrite =      spf_result         $spf_result (guess <$spf_result_guessed>)
                logwrite =      spf_header_comment $spf_header_comment
                logwrite =      spf_smtp_comment   $spf_smtp_comment
                logwrite =      spf_received       $spf_received
index 4a5e6e3e3987d4d932f69a2dc5fd5ba16f825753..c59607edb53ceb00b592d7af7d4b023ce181b2a2 100644 (file)
@@ -1,14 +1,20 @@
 
 ******** SERVER ********
 1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225
-1999-03-02 09:44:33 spf_result         fail
+1999-03-02 09:44:33 spf_result         fail (guess <no>)
 1999-03-02 09:44:33 spf_header_comment myhost.test.ex: domain of example.com does not designate ip4.ip4.ip4.ip4 as permitted sender
 1999-03-02 09:44:33 spf_smtp_comment   Please see http://www.openspf.org/Why?id=a%40example.com&ip=ip4.ip4.ip4.ip4&receiver=myhost.test.ex : Reason: mechanism
 1999-03-02 09:44:33 spf_received       Received-SPF: fail (myhost.test.ex: domain of example.com does not designate ip4.ip4.ip4.ip4 as permitted sender) client-ip=ip4.ip4.ip4.ip4; envelope-from=a@example.com; helo=testclient;
 1999-03-02 09:44:33 Authentication-Results: myhost.test.ex;\n  spf=fail smtp.mailfrom=example.com
 1999-03-02 09:44:33 H=(testclient) [ip4.ip4.ip4.ip4] F=<a@example.com> rejected RCPT <fred@test.ex>
+1999-03-02 09:44:33 spf_result         neutral (guess <yes>)
+1999-03-02 09:44:33 spf_header_comment myhost.test.ex: ip4.ip4.ip4.ip4 is neither permitted nor denied by domain of test.example.com
+1999-03-02 09:44:33 spf_smtp_comment   Please see http://www.openspf.org/Why?id=b%40test.example.com&ip=ip4.ip4.ip4.ip4&receiver=myhost.test.ex : Reason: mechanism
+1999-03-02 09:44:33 spf_received       Received-SPF: neutral (myhost.test.ex: ip4.ip4.ip4.ip4 is neither permitted nor denied by domain of test.example.com) client-ip=ip4.ip4.ip4.ip4; envelope-from=b@test.example.com; helo=testclient;
+1999-03-02 09:44:33 Authentication-Results: myhost.test.ex;\n  spf=neutral (best guess record for domain) smtp.mailfrom=test.example.com
+1999-03-02 09:44:33 H=(testclient) [ip4.ip4.ip4.ip4] F=<b@test.example.com> rejected RCPT <fred@test.ex>
 1999-03-02 09:44:33 spf_result         pass
 1999-03-02 09:44:33 spf_header_comment myhost.test.ex: localhost is always allowed.
 1999-03-02 09:44:33 spf_smtp_comment   
-1999-03-02 09:44:33 spf_received       Received-SPF: pass (myhost.test.ex: localhost is always allowed.) client-ip=127.0.0.1; envelope-from=b@example.com; helo=testclient;
+1999-03-02 09:44:33 spf_received       Received-SPF: pass (myhost.test.ex: localhost is always allowed.) client-ip=127.0.0.1; envelope-from=c@example.com; helo=testclient;
 1999-03-02 09:44:33 Authentication-Results: myhost.test.ex;\n  spf=pass smtp.mailfrom=example.com
index 6eeab86c552143540a400fb7779ea09f55891385..abd86c8748722189c6e66982ff744d14a52acc1e 100644 (file)
@@ -1,3 +1,4 @@
 
 ******** SERVER ********
 1999-03-02 09:44:33 H=(testclient) [ip4.ip4.ip4.ip4] F=<a@example.com> rejected RCPT <fred@test.ex>
+1999-03-02 09:44:33 H=(testclient) [ip4.ip4.ip4.ip4] F=<b@test.example.com> rejected RCPT <fred@test.ex>
index 3907f6861466ab09336caba7d6bd5f30f2dc2afb..825efb9595490bd79a1108edf440bd126635e432 100644 (file)
@@ -19,11 +19,21 @@ rcpt to:<fred@test.ex>
 ??? 550
 quit
 ****
+client HOSTIPV4 PORT_D
+??? 220
+helo testclient
+??? 250
+mail from:<b@test.example.com>
+??? 250
+rcpt to:<fred@test.ex>
+??? 550
+quit
+****
 client 127.0.0.1 PORT_D
 ??? 220
 helo testclient
 ??? 250
-mail from:<b@example.com>
+mail from:<c@example.com>
 ??? 250
 rcpt to:<fred@test.ex>
 ??? 250
index c33a531c2ebf2f34c57b04eb457e590c778686fc..3b75a04e33143de928839bc6e5691276bc78ab98 100644 (file)
@@ -12,13 +12,27 @@ Connecting to ip4.ip4.ip4.ip4 port 1225 ... connected
 <<< 550 Administrative prohibition
 >>> quit
 End of script
+Connecting to ip4.ip4.ip4.ip4 port 1225 ... connected
+??? 220
+<<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> helo testclient
+??? 250
+<<< 250 myhost.test.ex Hello testclient [ip4.ip4.ip4.ip4]
+>>> mail from:<b@test.example.com>
+??? 250
+<<< 250 OK
+>>> rcpt to:<fred@test.ex>
+??? 550
+<<< 550 Administrative prohibition
+>>> quit
+End of script
 Connecting to 127.0.0.1 port 1225 ... connected
 ??? 220
 <<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
 >>> helo testclient
 ??? 250
 <<< 250 myhost.test.ex Hello testclient [127.0.0.1]
->>> mail from:<b@example.com>
+>>> mail from:<c@example.com>
 ??? 250
 <<< 250 OK
 >>> rcpt to:<fred@test.ex>