void cleanup_addr_sender(CLEANUP_STATE *state, const char *buf) { VSTRING *clean_addr = vstring_alloc(100); const char *bcc; /* * Note: an unqualified envelope address is for all practical purposes * equivalent to a fully qualified local address, both for delivery and * for replying. Having to support both forms is error prone, therefore * an incomplete envelope address is rewritten to fully qualified form in * the local domain context. * * 20000520: Replace mailer-daemon@$myorigin by the null address, to handle * bounced mail traffic more robustly. */ cleanup_rewrite_internal(MAIL_ATTR_RWR_LOCAL, clean_addr, buf); if (strncasecmp(STR(clean_addr), MAIL_ADDR_MAIL_DAEMON "@", sizeof(MAIL_ADDR_MAIL_DAEMON)) == 0) { canon_addr_internal(state->temp1, MAIL_ADDR_MAIL_DAEMON); if (strcasecmp(STR(clean_addr), STR(state->temp1)) == 0) vstring_strcpy(clean_addr, ""); } if (state->flags & CLEANUP_FLAG_MAP_OK) { if (cleanup_send_canon_maps && (cleanup_send_canon_flags & CLEANUP_CANON_FLAG_ENV_FROM)) cleanup_map11_internal(state, clean_addr, cleanup_send_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_comm_canon_maps && (cleanup_comm_canon_flags & CLEANUP_CANON_FLAG_ENV_FROM)) cleanup_map11_internal(state, clean_addr, cleanup_comm_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_masq_domains && (cleanup_masq_flags & CLEANUP_MASQ_FLAG_ENV_FROM)) cleanup_masquerade_internal(state, clean_addr, cleanup_masq_domains); } CLEANUP_OUT_BUF(state, REC_TYPE_FROM, clean_addr); if (state->sender) /* XXX Can't happen */ myfree(state->sender); state->sender = mystrdup(STR(clean_addr)); /* Used by Milter client */ if ((state->flags & CLEANUP_FLAG_BCC_OK) && *STR(clean_addr) && cleanup_send_bcc_maps) { if ((bcc = mail_addr_find(cleanup_send_bcc_maps, STR(clean_addr), IGNORE_EXTENSION)) != 0) { cleanup_addr_bcc(state, bcc); } else if (cleanup_send_bcc_maps->error) { msg_warn("%s: %s map lookup problem -- " "message not accepted, try again later", state->queue_id, cleanup_send_bcc_maps->title); state->errs |= CLEANUP_STAT_WRITE; } } vstring_free(clean_addr); }
void cleanup_extracted_finish(CLEANUP_STATE *state) { /* * On the way out, add the optional automatic BCC recipient. */ if ((state->flags & CLEANUP_FLAG_BCC_OK) && state->recip != 0 && *var_always_bcc) cleanup_addr_bcc(state, var_always_bcc); /* * Terminate the extracted segment. */ cleanup_out_string(state, REC_TYPE_END, ""); }
void cleanup_addr_recipient(CLEANUP_STATE *state, const char *buf) { VSTRING *clean_addr = vstring_alloc(100); const char *bcc; /* * Note: an unqualified envelope address is for all practical purposes * equivalent to a fully qualified local address, both for delivery and * for replying. Having to support both forms is error prone, therefore * an incomplete envelope address is rewritten to fully qualified form in * the local domain context. */ cleanup_rewrite_internal(MAIL_ATTR_RWR_LOCAL, clean_addr, *buf ? buf : var_empty_addr); if (state->flags & CLEANUP_FLAG_MAP_OK) { if (cleanup_rcpt_canon_maps && (cleanup_rcpt_canon_flags & CLEANUP_CANON_FLAG_ENV_RCPT)) cleanup_map11_internal(state, clean_addr, cleanup_rcpt_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_comm_canon_maps && (cleanup_comm_canon_flags & CLEANUP_CANON_FLAG_ENV_RCPT)) cleanup_map11_internal(state, clean_addr, cleanup_comm_canon_maps, cleanup_ext_prop_mask & EXT_PROP_CANONICAL); if (cleanup_masq_domains && (cleanup_masq_flags & CLEANUP_MASQ_FLAG_ENV_RCPT)) cleanup_masquerade_internal(state, clean_addr, cleanup_masq_domains); } cleanup_out_recipient(state, state->dsn_orcpt, state->dsn_notify, state->orig_rcpt, STR(clean_addr)); if (state->recip) /* This can happen */ myfree(state->recip); state->recip = mystrdup(STR(clean_addr)); /* Used by Milter client */ if ((state->flags & CLEANUP_FLAG_BCC_OK) && *STR(clean_addr) && cleanup_rcpt_bcc_maps) { if ((bcc = mail_addr_find(cleanup_rcpt_bcc_maps, STR(clean_addr), IGNORE_EXTENSION)) != 0) { cleanup_addr_bcc(state, bcc); } else if (cleanup_rcpt_bcc_maps->error) { msg_warn("%s: %s map lookup problem -- " "message not accepted, try again later", state->queue_id, cleanup_rcpt_bcc_maps->title); state->errs |= CLEANUP_STAT_WRITE; } } vstring_free(clean_addr); }
void cleanup_extracted_finish(CLEANUP_STATE *state) { const char myname[] = "cleanup_extracted_finish"; /* * On the way out, add the optional automatic BCC recipient. */ if ((state->flags & CLEANUP_FLAG_BCC_OK) && state->recip != 0 && *var_always_bcc) cleanup_addr_bcc(state, var_always_bcc); /* * Terminate the extracted segment. */ cleanup_out_string(state, REC_TYPE_END, ""); /* * vstream_fseek() would flush the buffer anyway, but the code just reads * better if we flush first, because it makes seek error handling more * straightforward. */ if (vstream_fflush(state->dst)) { if (errno == EFBIG) { msg_warn("%s: queue file size limit exceeded", state->queue_id); state->errs |= CLEANUP_STAT_SIZE; } else { msg_warn("%s: write queue file: %m", state->queue_id); state->errs |= CLEANUP_STAT_WRITE; } return; } /* * Update the preliminary message size and count fields with the actual * values. */ if (vstream_fseek(state->dst, 0L, SEEK_SET) < 0) msg_fatal("%s: vstream_fseek %s: %m", myname, cleanup_path); cleanup_out_format(state, REC_TYPE_SIZE, REC_TYPE_SIZE_FORMAT, (REC_TYPE_SIZE_CAST1) (state->xtra_offset - state->data_offset), (REC_TYPE_SIZE_CAST2) state->data_offset, (REC_TYPE_SIZE_CAST3) state->rcpt_count, (REC_TYPE_SIZE_CAST4) state->qmgr_opts); }