- /* 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));
- libdm_status = opendmarc_policy_fetch_utilized_domain(dmarc_pctx, dmarc_domain,
- DMARC_MAXHOSTNAMELEN-1);
- dmarc_used_domain = string_copy(dmarc_domain);
- free(dmarc_domain);
- if (libdm_status != DMARC_PARSE_OKAY)
- {
- log_write(0, LOG_MAIN|LOG_PANIC, "failure to read domainname used for DMARC lookup: %s",
- opendmarc_policy_status_to_str(libdm_status));
- }
- libdm_status = opendmarc_get_policy_to_enforce(dmarc_pctx);
- dmarc_policy = libdm_status;
- switch(libdm_status)
- {
- case DMARC_POLICY_ABSENT: /* No DMARC record found */
- dmarc_status = US"norecord";
- dmarc_pass_fail = US"none";
- dmarc_status_text = US"No DMARC record";
- action = DMARC_RESULT_ACCEPT;
- break;
- case DMARC_FROM_DOMAIN_ABSENT: /* No From: domain */
- dmarc_status = US"nofrom";
- dmarc_pass_fail = US"temperror";
- dmarc_status_text = US"No From: domain found";
- action = DMARC_RESULT_ACCEPT;
- break;
- case DMARC_POLICY_NONE: /* Accept and report */
- dmarc_status = US"none";
- dmarc_pass_fail = US"none";
- dmarc_status_text = US"None, Accept";
- action = DMARC_RESULT_ACCEPT;
- break;
- case DMARC_POLICY_PASS: /* Explicit accept */
- dmarc_status = US"accept";
- dmarc_pass_fail = US"pass";
- dmarc_status_text = US"Accept";
- action = DMARC_RESULT_ACCEPT;
- break;
- case DMARC_POLICY_REJECT: /* Explicit reject */
- dmarc_status = US"reject";
- dmarc_pass_fail = US"fail";
- dmarc_status_text = US"Reject";
- action = DMARC_RESULT_REJECT;
- break;
- case DMARC_POLICY_QUARANTINE: /* Explicit quarantine */
- dmarc_status = US"quarantine";
- dmarc_pass_fail = US"fail";
- dmarc_status_text = US"Quarantine";
- action = DMARC_RESULT_QUARANTINE;
- break;
- default:
- dmarc_status = US"temperror";
- dmarc_pass_fail = US"temperror";
- dmarc_status_text = US"Internal Policy Error";
- action = DMARC_RESULT_TEMPFAIL;
- break;
- }