diff options
author | Todd Lyons <tlyons@exim.org> | 2014-04-12 10:42:52 -0700 |
---|---|---|
committer | Todd Lyons <tlyons@exim.org> | 2014-04-15 12:58:55 -0700 |
commit | 8c8b8274fc537766da72eab2f79a62d1603d6638 (patch) | |
tree | 74e9efc0cfbdc085e777ae00cad922ae9a16cdf3 /src | |
parent | 364e49ab87bf81774f12f8b0e21509eb51c88b71 (diff) |
Add expansion for DMARC policy
New variable is $dmarc_domain_policy
Diffstat (limited to 'src')
-rw-r--r-- | src/src/dmarc.c | 23 | ||||
-rw-r--r-- | src/src/expand.c | 1 | ||||
-rw-r--r-- | src/src/globals.c | 1 | ||||
-rw-r--r-- | src/src/globals.h | 1 |
4 files changed, 26 insertions, 0 deletions
diff --git a/src/src/dmarc.c b/src/src/dmarc.c index 22a051582..32a1b9678 100644 --- a/src/src/dmarc.c +++ b/src/src/dmarc.c @@ -38,6 +38,18 @@ u_char *header_from_sender = NULL; int history_file_status = DMARC_HIST_OK; uschar *dkim_history_buffer= NULL; +typedef struct dmarc_exim_p { + uschar *name; + int value; +} dmarc_exim_p; + +static dmarc_exim_p dmarc_policy_description[] = { + { US"", DMARC_RECORD_P_UNSPECIFIED }, + { US"none", DMARC_RECORD_P_NONE }, + { US"quarantine", DMARC_RECORD_P_QUARANTINE }, + { US"reject", DMARC_RECORD_P_REJECT }, + { NULL, 0 } +}; /* Accept an error_block struct, initialize if empty, parse to the * end, and append the two strings passed to it. Used for adding * variable amounts of value:pair data to the forensic emails. */ @@ -147,6 +159,7 @@ int dmarc_store_data(header_line *hdr) { int dmarc_process() { int sr, origin; /* used in SPF section */ int dmarc_spf_result = 0; /* stores spf into dmarc conn ctx */ + int tmp_ans, c; pdkim_signature *sig = NULL; BOOL has_dmarc_record = TRUE; u_char **ruf; /* forensic report addressees, if called for */ @@ -308,6 +321,16 @@ int dmarc_process() { has_dmarc_record = FALSE; break; } + + /* Store the policy string in an expandable variable. */ + libdm_status = opendmarc_policy_fetch_p(dmarc_pctx, &tmp_ans); + for (c=0; dmarc_policy_description[c].name != NULL; c++) { + if (tmp_ans == dmarc_policy_description[c].value) { + dmarc_domain_policy = string_sprintf("%s",dmarc_policy_description[c].name); + break; + } + } + /* Can't use exim's string manipulation functions so allocate memory * for libopendmarc using its max hostname length definition. */ uschar *dmarc_domain = (uschar *)calloc(DMARC_MAXHOSTNAMELEN, sizeof(uschar)); diff --git a/src/src/expand.c b/src/src/expand.c index 7a3252eaa..d2ac8ca79 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -468,6 +468,7 @@ static var_entry var_table[] = { #endif #ifdef EXPERIMENTAL_DMARC { "dmarc_ar_header", vtype_stringptr, &dmarc_ar_header }, + { "dmarc_domain_policy", vtype_stringptr, &dmarc_domain_policy }, { "dmarc_status", vtype_stringptr, &dmarc_status }, { "dmarc_status_text", vtype_stringptr, &dmarc_status_text }, { "dmarc_used_domain", vtype_stringptr, &dmarc_used_domain }, diff --git a/src/src/globals.c b/src/src/globals.c index 62f653b23..839b91dcc 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -598,6 +598,7 @@ BOOL dkim_disable_verify = FALSE; #ifdef EXPERIMENTAL_DMARC BOOL dmarc_has_been_checked = FALSE; uschar *dmarc_ar_header = NULL; +uschar *dmarc_domain_policy = NULL; uschar *dmarc_forensic_sender = NULL; uschar *dmarc_history_file = NULL; uschar *dmarc_status = NULL; diff --git a/src/src/globals.h b/src/src/globals.h index 088c267f2..1cc39fc09 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -354,6 +354,7 @@ extern BOOL dkim_disable_verify; /* Set via ACL control statement. When se #ifdef EXPERIMENTAL_DMARC extern BOOL dmarc_has_been_checked; /* Global variable to check if test has been called yet */ extern uschar *dmarc_ar_header; /* Expansion variable, suggested header for dmarc auth results */ +extern uschar *dmarc_domain_policy; /* Expansion for declared policy of used domain */ extern uschar *dmarc_forensic_sender; /* Set sender address for forensic reports */ extern uschar *dmarc_history_file; /* Expansion variable, file to store dmarc results */ extern uschar *dmarc_status; /* Expansion variable, one word value */ |