[exim-cvs] DMARC: write history file even under testsuite

Inizio della pagina
Delete this message
Reply to this message
Autore: Exim Git Commits Mailing List
Data:  
To: exim-cvs
Oggetto: [exim-cvs] DMARC: write history file even under testsuite
Gitweb: https://git.exim.org/exim.git/commitdiff/8a2fd4b22738aa6cceaf2ddd7755f376cb8460a3
Commit:     8a2fd4b22738aa6cceaf2ddd7755f376cb8460a3
Parent:     7aecdeeba22cfe94a180d722dc3506cd6f2b83a2
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Aug 19 22:52:27 2023 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sun Aug 20 14:23:26 2023 +0100


    DMARC: write history file even under testsuite
---
 src/src/dmarc.c  | 40 ++++++++++++++++++++++------------------
 test/stdout/4650 |  4 +---
 2 files changed, 23 insertions(+), 21 deletions(-)


diff --git a/src/src/dmarc.c b/src/src/dmarc.c
index b2609b4fe..48a72541f 100644
--- a/src/src/dmarc.c
+++ b/src/src/dmarc.c
@@ -243,7 +243,7 @@ return NULL;
 static int
 dmarc_write_history_file()
 {
-int history_file_fd;
+int history_file_fd = 0;
 ssize_t written_len;
 int tmp_ans;
 u_char ** rua; /* aggregate report addressees */
@@ -254,14 +254,13 @@ if (!dmarc_history_file)
   DEBUG(D_receive) debug_printf("DMARC history file not set\n");
   return DMARC_HIST_DISABLED;
   }
-history_file_fd = log_open_as_exim(dmarc_history_file);
-
-if (history_file_fd < 0)
-  {
-  log_write(0, LOG_MAIN|LOG_PANIC, "failure to create DMARC history file: %s",
-               dmarc_history_file);
-  return DMARC_HIST_FILE_ERR;
-  }
+if (!host_checking)
+  if ((history_file_fd = log_open_as_exim(dmarc_history_file)) < 0)
+    {
+    log_write(0, LOG_MAIN|LOG_PANIC, "failure to create DMARC history file: %s",
+                 dmarc_history_file);
+    return DMARC_HIST_FILE_ERR;
+    }


/* Generate the contents of the history file */
g = string_fmt_append(NULL,
@@ -272,14 +271,17 @@ g = string_fmt_append(NULL,
if (spf_response)
g = string_fmt_append(g, "spf %d\n", dmarc_spf_ares_result);

-g = string_fmt_append(g, "%spdomain %s\npolicy %d\n",
- dkim_history_buffer, dmarc_used_domain, dmarc_policy);
+if (dkim_history_buffer)
+ g = string_fmt_append(g, "%s\n", dkim_history_buffer);
+
+g = string_fmt_append(g, "pdomain %s\npolicy %d\n",
+ dmarc_used_domain, dmarc_policy);

 if ((rua = opendmarc_policy_fetch_rua(dmarc_pctx, NULL, 0, 1)))
   for (tmp_ans = 0; rua[tmp_ans]; tmp_ans++)
     g = string_fmt_append(g, "rua %s\n", rua[tmp_ans]);
 else
-  g = string_fmt_append(g, "rua -\n");
+  g = string_catn(g, US"rua -\n", 6);


opendmarc_policy_fetch_pct(dmarc_pctx, &tmp_ans);
g = string_fmt_append(g, "pct %d\n", tmp_ans);
@@ -301,14 +303,16 @@ g = string_fmt_append(g, "align_dkim %d\nalign_spf %d\naction %d\n",

 /* Write the contents to the history file */
 DEBUG(D_receive)
-  debug_printf("DMARC logging history data for opendmarc reporting%s\n",
-         (host_checking || f.running_in_test_harness) ? " (not really)" : "");
-if (host_checking || f.running_in_test_harness)
   {
-  DEBUG(D_receive)
-    debug_printf("DMARC history data for debugging:\n%Y", g);
+  debug_printf("DMARC logging history data for opendmarc reporting%s\n",
+         host_checking ? " (not really)" : "");
+  debug_printf_indent("DMARC history data for debugging:\n");
+  expand_level++;
+    debug_printf_indent("%Y", g);
+  expand_level--;
   }
-else
+
+if (!host_checking)
   {
   written_len = write_to_fd_buf(history_file_fd,
                 g->s,
diff --git a/test/stdout/4650 b/test/stdout/4650
index 436f4bd41..3ee5a7782 100644
--- a/test/stdout/4650
+++ b/test/stdout/4650
@@ -28,7 +28,7 @@ received 1692480217
 ipaddr ip4.ip4.ip4.ip4
 from test.ex
 mfrom test.ex
-spf 7
+spf 6
 pdomain test.ex
 policy 18
 rua -
@@ -40,5 +40,3 @@ sp 0
 align_dkim 5
 align_spf 5
 action 2
-arc -
-arc_policy -


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-cvs.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-cvs-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/