DMARC: add ARC info to history records
[exim.git] / src / src / spf.c
index a94bc96772b40df94c935ded900b1b237266c023..3d83f07ba43a6d43482ce83203f4a9eaf991c0ec 100644 (file)
@@ -6,7 +6,7 @@
    Copyright (c) The Exim Maintainers 2015 - 2022
    Copyright (c) Tom Kistner <tom@duncanthrax.net> 2004 - 2014
    License: GPL
-   SPDX-License-Identifier: GPL-2.0-only
+   SPDX-License-Identifier: GPL-2.0-or-later
 */
 
 /* Code for calling spf checks via libspf-alt. Called from acl.c. */
@@ -401,20 +401,31 @@ gstring *
 authres_spf(gstring * g)
 {
 uschar * s;
-if (!spf_result) return g;
-
-g = string_append(g, 2, US";\n\tspf=", spf_result);
-if (spf_result_guessed)
-  g = string_cat(g, US" (best guess record for domain)");
+if (spf_result)
+  {
+  int start = 0;               /* Compiler quietening */
+  DEBUG(D_acl) start = gstring_length(g);
 
-s = expand_string(US"$sender_address_domain");
-if (s && *s)
-  return string_append(g, 2, US" smtp.mailfrom=", s);
+  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 = sender_helo_name;
-return s && *s
-  ? string_append(g, 2, US" smtp.helo=", s)
-  : string_cat(g, US" smtp.mailfrom=<>");
+  s = expand_string(US"$sender_address_domain");
+  if (s && *s)
+    g = string_append(g, 2, US" smtp.mailfrom=", s);
+  else
+    {
+    s = sender_helo_name;
+    g = s && *s
+      ? string_append(g, 2, US" smtp.helo=", s)
+      : string_cat(g, US" smtp.mailfrom=<>");
+    }
+  DEBUG(D_acl) debug_printf("SPF:\tauthres '%.*s'\n",
+                 gstring_length(g) - start - 3, g->s + start + 3);
+  }
+else
+  DEBUG(D_acl) debug_printf("SPF:\tno authres\n");
+return g;
 }