5
/* process envelope addresses
7
/* #include <cleanup.h>
9
/* void cleanup_addr_sender(state, addr)
10
/* CLEANUP_STATE *state;
13
/* void cleanup_addr_recipient(state, addr)
14
/* CLEANUP_STATE *state;
17
/* void cleanup_addr_bcc(state, addr)
18
/* CLEANUP_STATE *state;
21
/* This module processes envelope address records and writes the result
22
/* to the queue file. Processing includes address rewriting and
23
/* sender/recipient auto bcc address generation.
25
/* cleanup_addr_sender() processes sender envelope information and updates
28
/* cleanup_addr_recipient() processes recipient envelope information
29
/* and updates state->recip.
31
/* cleanup_addr_bcc() processes recipient envelope information. This
32
/* is a separate function to avoid invoking cleanup_addr_recipient()
37
/* Queue file and message processing state. This state is updated
38
/* as records are processed and as errors happen.
44
/* The Secure Mailer license must be distributed with this software.
47
/* IBM T.J. Watson Research
49
/* Yorktown Heights, NY 10598, USA
58
#ifdef STRCASECMP_IN_STRINGS_H
62
/* Utility library. */
68
#include <stringops.h>
73
#include <cleanup_user.h>
74
#include <mail_params.h>
76
#include <mail_addr.h>
77
#include <canon_addr.h>
78
#include <mail_addr_find.h>
80
/* Application-specific. */
84
#define STR vstring_str
85
#define IGNORE_EXTENSION (char **) 0
87
/* cleanup_addr_sender - process envelope sender record */
89
void cleanup_addr_sender(CLEANUP_STATE *state, const char *buf)
91
VSTRING *clean_addr = vstring_alloc(100);
94
cleanup_rewrite_internal(clean_addr, buf);
95
if (strncasecmp(STR(clean_addr), MAIL_ADDR_MAIL_DAEMON "@",
96
sizeof(MAIL_ADDR_MAIL_DAEMON)) == 0) {
97
canon_addr_internal(state->temp1, MAIL_ADDR_MAIL_DAEMON);
98
if (strcasecmp(STR(clean_addr), STR(state->temp1)) == 0)
99
vstring_strcpy(clean_addr, "");
101
if (state->flags & CLEANUP_FLAG_MAP_OK) {
102
if (cleanup_send_canon_maps)
103
cleanup_map11_internal(state, clean_addr, cleanup_send_canon_maps,
104
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
105
if (cleanup_comm_canon_maps)
106
cleanup_map11_internal(state, clean_addr, cleanup_comm_canon_maps,
107
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
108
if (cleanup_masq_domains
109
&& (cleanup_masq_flags & CLEANUP_MASQ_FLAG_ENV_FROM))
110
cleanup_masquerade_internal(clean_addr, cleanup_masq_domains);
112
CLEANUP_OUT_BUF(state, REC_TYPE_FROM, clean_addr);
113
if (state->sender == 0)
114
state->sender = mystrdup(STR(clean_addr));
115
if ((state->flags & CLEANUP_FLAG_BCC_OK)
117
&& cleanup_send_bcc_maps
118
&& (bcc = mail_addr_find(cleanup_send_bcc_maps, STR(clean_addr),
119
IGNORE_EXTENSION)) != 0)
120
cleanup_addr_bcc(state, bcc);
121
vstring_free(clean_addr);
124
/* cleanup_addr_recipient - process envelope recipient */
126
void cleanup_addr_recipient(CLEANUP_STATE *state, const char *buf)
128
VSTRING *clean_addr = vstring_alloc(100);
131
cleanup_rewrite_internal(clean_addr, *buf ? buf : var_empty_addr);
132
if (state->flags & CLEANUP_FLAG_MAP_OK) {
133
if (cleanup_rcpt_canon_maps)
134
cleanup_map11_internal(state, clean_addr, cleanup_rcpt_canon_maps,
135
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
136
if (cleanup_comm_canon_maps)
137
cleanup_map11_internal(state, clean_addr, cleanup_comm_canon_maps,
138
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
139
if (cleanup_masq_domains
140
&& (cleanup_masq_flags & CLEANUP_MASQ_FLAG_ENV_RCPT))
141
cleanup_masquerade_internal(clean_addr, cleanup_masq_domains);
143
cleanup_out_recipient(state, state->orig_rcpt, STR(clean_addr));
144
if (state->recip == 0)
145
state->recip = mystrdup(STR(clean_addr));
146
if ((state->flags & CLEANUP_FLAG_BCC_OK)
148
&& cleanup_rcpt_bcc_maps
149
&& (bcc = mail_addr_find(cleanup_rcpt_bcc_maps, STR(clean_addr),
150
IGNORE_EXTENSION)) != 0)
151
cleanup_addr_bcc(state, bcc);
152
vstring_free(clean_addr);
155
/* cleanup_addr_bcc - process automatic BCC recipient */
157
void cleanup_addr_bcc(CLEANUP_STATE *state, const char *bcc)
159
VSTRING *clean_addr = vstring_alloc(100);
161
cleanup_rewrite_internal(clean_addr, bcc);
162
if (state->flags & CLEANUP_FLAG_MAP_OK) {
163
if (cleanup_rcpt_canon_maps)
164
cleanup_map11_internal(state, clean_addr, cleanup_rcpt_canon_maps,
165
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
166
if (cleanup_comm_canon_maps)
167
cleanup_map11_internal(state, clean_addr, cleanup_comm_canon_maps,
168
cleanup_ext_prop_mask & EXT_PROP_CANONICAL);
169
if (cleanup_masq_domains
170
&& (cleanup_masq_flags & CLEANUP_MASQ_FLAG_ENV_RCPT))
171
cleanup_masquerade_internal(clean_addr, cleanup_masq_domains);
173
cleanup_out_recipient(state, STR(clean_addr), STR(clean_addr));
174
vstring_free(clean_addr);