Index: opendmarc-1.2.0.beta1/opendmarc/opendmarc.c =================================================================== --- opendmarc-1.2.0.beta1.orig/opendmarc/opendmarc.c 2014-01-12 22:58:54.000000000 +0100 +++ opendmarc-1.2.0.beta1/opendmarc/opendmarc.c 2014-01-12 23:02:49.000000000 +0100 @@ -1996,59 +1996,56 @@ /* if requested, verify RFC5322-required headers (RFC5322 3.6) */ if (conf->conf_reqhdrs) { - _Bool ok = TRUE; + unsigned char* reqhdrs_error = NULL; /* no error */ - /* exactly one From: */ if (dmarcf_findheader(dfc, "From", 0) == NULL || dmarcf_findheader(dfc, "From", 1) != NULL) - ok = FALSE; + reqhdrs_error = "not exactly one From:"; - /* exactly one Date: */ if (dmarcf_findheader(dfc, "Date", 0) == NULL || dmarcf_findheader(dfc, "Date", 1) != NULL) - ok = FALSE; + reqhdrs_error = "not exactly one Date:"; - /* no more than one Reply-To: */ if (dmarcf_findheader(dfc, "Reply-To", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one Reply-To:"; - /* no more than one To: */ if (dmarcf_findheader(dfc, "To", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one To:"; - /* no more than one Cc: */ if (dmarcf_findheader(dfc, "Cc", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one Cc:"; - /* no more than one Bcc: */ if (dmarcf_findheader(dfc, "Bcc", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one Bcc:"; - /* no more than one Message-Id: */ if (dmarcf_findheader(dfc, "Message-Id", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one Message-Id:"; - /* no more than one In-Reply-To: */ if (dmarcf_findheader(dfc, "In-Reply-To", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one In-Reply-To:"; - /* no more than one References: */ if (dmarcf_findheader(dfc, "References", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one References:"; - /* no more than one Subject: */ if (dmarcf_findheader(dfc, "Subject", 1) != NULL) - ok = FALSE; + reqhdrs_error = "more than one Subject:"; - if (!ok) + if (reqhdrs_error) { + unsigned char replybuf[BUFRSZ + 1]; + if (conf->conf_dolog) { syslog(LOG_INFO, - "%s: RFC5322 header requirement error", - dfc->mctx_jobid); + "%s: RFC5322 requirement error: %s header", + dfc->mctx_jobid, reqhdrs_error); } + /* TODO: handle setreply failures */ + snprintf(replybuf, sizeof replybuf, + "RFC5322 requirement error: %s header", reqhdrs_error); + dmarcf_setreply(ctx, DMARC_REJECT_SMTP, + DMARC_REJECT_ESC, replybuf); return SMFIS_REJECT; } }