aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@rentabiliweb.com>2014-03-25 11:09:29 +0100
committerGilles Chehade <gilles@rentabiliweb.com>2014-03-25 11:09:29 +0100
commitd2ee696cc2b600c59f9f6b41b93b846382791c47 (patch)
treebd285ed58510026fccf33a462dbb91477a989071
parentdo not call purge_task every 10 secs, it is only needed once at startup and (diff)
downloadOpenSMTPD-d2ee696cc2b600c59f9f6b41b93b846382791c47.tar.xz
OpenSMTPD-d2ee696cc2b600c59f9f6b41b93b846382791c47.zip
enqueuer should update domain in headers accordingly
-rw-r--r--smtpd/enqueue.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/smtpd/enqueue.c b/smtpd/enqueue.c
index cfdc9e27..8841c344 100644
--- a/smtpd/enqueue.c
+++ b/smtpd/enqueue.c
@@ -159,6 +159,42 @@ qp_encoded_write(FILE *fp, char *buf, size_t len)
}
}
+static void
+send_header(FILE *fout, const char *line, size_t len)
+{
+ int i;
+
+ if (strncasecmp("To:", line, 3) != 0 &&
+ strncasecmp("Cc:", line, 3) != 0 &&
+ strncasecmp("Bcc:", line, 4) != 0 &&
+ strncasecmp("From:", line, 5) != 0) {
+ send_line(fout, 0, "%.*s", (int)len, line);
+ return;
+ }
+ if (len >= sizeof pstate.buf) {
+ send_line(fout, 0, "%.*s", (int)len, line);
+ return;
+ }
+
+ /* XXX
+ * To, Cc and Bcc may need rewrite, we can reuse the
+ * msg recipients field since former content has already
+ * been used at this point.
+ */
+ memset(&pstate, 0, sizeof(pstate));
+ memcpy(pstate.buf, line, len);
+ pstate.buf[len] = 0;
+ pstate.wpos = len - 1;
+ msg.rcpts = NULL;
+ msg.rcpt_cnt = 0;
+ if (strncasecmp("From:", line, 5) == 0)
+ parse_addr_terminal(1);
+ else
+ parse_addr_terminal(0);
+ for (i = 0; i < msg.rcpt_cnt; ++i)
+ send_line(fout, 0, "%s%s\n", msg.rcpts[i], i < msg.rcpt_cnt - 1 ? "," : "");
+}
+
int
enqueue(int argc, char *argv[])
{
@@ -363,7 +399,10 @@ enqueue(int argc, char *argv[])
if (msg.saw_content_transfer_encoding || noheader ||
inheaders || !msg.need_linesplit) {
- send_line(fout, 0, "%.*s", (int)len, line);
+ if (inheaders)
+ send_header(fout, line, len);
+ else
+ send_line(fout, 0, "%.*s", (int)len, line);
if (inheaders && buf[0] == '\n')
inheaders = 0;
continue;