aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2019-01-05 20:40:33 +0100
committerGilles Chehade <gilles@poolp.org>2019-01-05 20:40:33 +0100
commit5c9e31ef9cc0d77d1aa82c35cd132d3b93fac996 (patch)
tree2d613057392c726dde8d9e6b131a796283491fd7
parentsync (diff)
downloadOpenSMTPD-5c9e31ef9cc0d77d1aa82c35cd132d3b93fac996.tar.xz
OpenSMTPD-5c9e31ef9cc0d77d1aa82c35cd132d3b93fac996.zip
sync
-rw-r--r--smtpd/lka.c11
-rw-r--r--smtpd/lka_report.c12
-rw-r--r--smtpd/mda.c12
-rw-r--r--smtpd/report_smtp.c16
-rw-r--r--smtpd/smtp_session.c30
-rw-r--r--smtpd/smtpd.h5
6 files changed, 55 insertions, 31 deletions
diff --git a/smtpd/lka.c b/smtpd/lka.c
index 9e4d8dc0..fcb4ad6b 100644
--- a/smtpd/lka.c
+++ b/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.232 2018/12/28 11:40:29 eric Exp $ */
+/* $OpenBSD: lka.c,v 1.233 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -529,6 +529,15 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
filter_phase, filter_response, filter_param);
return;
+ case IMSG_REPORT_SMTP_TIMEOUT:
+ m_msg(&m, imsg);
+ m_get_string(&m, &direction);
+ m_get_timeval(&m, &tv);
+ m_get_id(&m, &reqid);
+ m_end(&m);
+
+ lka_report_smtp_timeout(direction, &tv, reqid);
+ return;
case IMSG_FILTER_SMTP_PROTOCOL:
m_msg(&m, imsg);
diff --git a/smtpd/lka_report.c b/smtpd/lka_report.c
index e8eb3348..aff14ad3 100644
--- a/smtpd/lka_report.c
+++ b/smtpd/lka_report.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_report.c,v 1.16 2018/12/21 14:33:52 gilles Exp $ */
+/* $OpenBSD: lka_report.c,v 1.17 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -66,6 +66,8 @@ static struct smtp_events {
{ "protocol-server" },
{ "filter-response" },
+
+ { "timeout" },
};
@@ -408,3 +410,11 @@ lka_report_smtp_filter_response(const char *direction, struct timeval *tv, uint6
"%016"PRIx64"|%s|%s%s%s\n",
reqid, phase_name, response_name, param ? "|" : "", param ? param : "");
}
+
+void
+lka_report_smtp_timeout(const char *direction, struct timeval *tv, uint64_t reqid)
+{
+ report_smtp_broadcast(reqid, direction, tv, "timeout",
+ "%016"PRIx64"\n",
+ reqid);
+}
diff --git a/smtpd/mda.c b/smtpd/mda.c
index 06b88907..348192fc 100644
--- a/smtpd/mda.c
+++ b/smtpd/mda.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mda.c,v 1.136 2018/12/27 15:41:50 gilles Exp $ */
+/* $OpenBSD: mda.c,v 1.137 2019/01/05 10:20:21 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -48,6 +48,7 @@
struct mda_envelope {
TAILQ_ENTRY(mda_envelope) entry;
+ uint64_t session_id;
uint64_t id;
time_t creation;
char *sender;
@@ -101,7 +102,7 @@ static void mda_queue_loop(uint64_t);
static struct mda_user *mda_user(const struct envelope *);
static void mda_user_free(struct mda_user *);
static const char *mda_user_to_text(const struct mda_user *);
-static struct mda_envelope *mda_envelope(const struct envelope *);
+static struct mda_envelope *mda_envelope(uint64_t, const struct envelope *);
static void mda_envelope_free(struct mda_envelope *);
static struct mda_session * mda_session(struct mda_user *);
static const char *mda_sysexit_to_str(int);
@@ -186,7 +187,7 @@ mda_imsg(struct mproc *p, struct imsg *imsg)
return;
}
- e = mda_envelope(&evp);
+ e = mda_envelope(u->id, &evp);
TAILQ_INSERT_TAIL(&u->envelopes, e, entry);
u->evpcount += 1;
stat_increment("mda.pending", 1);
@@ -671,7 +672,7 @@ mda_log(const struct mda_envelope *evp, const char *prefix, const char *status)
log_info("%016"PRIx64" mda delivery evpid=%016" PRIx64 " from=<%s> to=<%s> "
"%suser=%s delay=%s result=%s stat=%s",
- (uint64_t)0,
+ evp->session_id,
evp->id,
evp->sender ? evp->sender : "",
evp->dest,
@@ -791,12 +792,13 @@ mda_user_to_text(const struct mda_user *u)
}
static struct mda_envelope *
-mda_envelope(const struct envelope *evp)
+mda_envelope(uint64_t session_id, const struct envelope *evp)
{
struct mda_envelope *e;
char buf[LINE_MAX];
e = xcalloc(1, sizeof *e);
+ e->session_id = session_id;
e->id = evp->id;
e->creation = evp->creation;
buf[0] = '\0';
diff --git a/smtpd/report_smtp.c b/smtpd/report_smtp.c
index d2d8b27d..a4268909 100644
--- a/smtpd/report_smtp.c
+++ b/smtpd/report_smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: report_smtp.c,v 1.3 2018/12/13 17:08:10 gilles Exp $ */
+/* $OpenBSD: report_smtp.c,v 1.4 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -265,3 +265,17 @@ report_smtp_filter_response(const char *direction, uint64_t qid, int phase, int
m_add_string(p_lka, param);
m_close(p_lka);
}
+
+void
+report_smtp_timeout(const char *direction, uint64_t qid)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ m_create(p_lka, IMSG_REPORT_SMTP_TIMEOUT, 0, 0, -1);
+ m_add_string(p_lka, direction);
+ m_add_timeval(p_lka, &tv);
+ m_add_id(p_lka, qid);
+ m_close(p_lka);
+}
diff --git a/smtpd/smtp_session.c b/smtpd/smtp_session.c
index e2a21de1..d9f2dd56 100644
--- a/smtpd/smtp_session.c
+++ b/smtpd/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.385 2019/01/03 15:46:07 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.387 2019/01/05 09:43:39 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1083,6 +1083,11 @@ smtp_io(struct io *io, int evt, void *arg)
/* Message body */
eom = 0;
if (s->state == STATE_BODY) {
+ if (strcmp(line, ".")) {
+ s->tx->datain += strlen(line) + 1;
+ if (s->tx->datain > env->sc_maxsize)
+ s->tx->error = TX_ERROR_SIZE;
+ }
eom = (s->tx->filter == NULL) ?
smtp_tx_dataline(s->tx, line) :
smtp_tx_filtered_dataline(s->tx, line);
@@ -1143,6 +1148,7 @@ smtp_io(struct io *io, int evt, void *arg)
log_info("%016"PRIx64" smtp disconnected "
"reason=timeout",
s->id);
+ report_smtp_timeout("smtp-in", s->id);
smtp_free(s, "timeout");
break;
@@ -2553,13 +2559,6 @@ smtp_tx_dataline(struct smtp_tx *tx, const char *line)
/* escape lines starting with a '.' */
if (line[0] == '.')
line += 1;
-
- /* account for newline */
- tx->datain += strlen(line) + 1;
- if (tx->datain > env->sc_maxsize) {
- tx->error = TX_ERROR_SIZE;
- return 0;
- }
}
if (rfc5322_push(tx->parser, line) == -1) {
@@ -2666,25 +2665,12 @@ smtp_tx_dataline(struct smtp_tx *tx, const char *line)
static int
smtp_tx_filtered_dataline(struct smtp_tx *tx, const char *line)
{
- if (!strcmp(line, ".")) {
- /* XXX - this needs to be handled properly */
- /*
- * if (tx->error)
- * return 1;
- */
+ if (!strcmp(line, "."))
line = NULL;
- }
else {
/* ignore data line if an error is set */
if (tx->error)
return 0;
-
- /* account for newline */
- tx->datain += strlen(line) + 1;
- if (tx->datain > env->sc_maxsize) {
- tx->error = TX_ERROR_SIZE;
- return 0;
- }
}
io_printf(tx->filter, "%s\r\n", line ? line : ".");
return line ? 0 : 1;
diff --git a/smtpd/smtpd.h b/smtpd/smtpd.h
index 71af6b19..019d402a 100644
--- a/smtpd/smtpd.h
+++ b/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.615 2018/12/28 15:09:28 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.617 2019/01/05 09:48:32 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -319,6 +319,7 @@ enum imsg_type {
IMSG_REPORT_SMTP_PROTOCOL_CLIENT,
IMSG_REPORT_SMTP_PROTOCOL_SERVER,
IMSG_REPORT_SMTP_FILTER_RESPONSE,
+ IMSG_REPORT_SMTP_TIMEOUT,
IMSG_FILTER_SMTP_BEGIN,
IMSG_FILTER_SMTP_END,
@@ -1356,6 +1357,7 @@ void lka_report_smtp_protocol_client(const char *, struct timeval *, uint64_t, c
void lka_report_smtp_protocol_server(const char *, struct timeval *, uint64_t, const char *);
void lka_report_smtp_filter_response(const char *, struct timeval *, uint64_t,
int, int, const char *);
+void lka_report_smtp_timeout(const char *, struct timeval *, uint64_t);
/* lka_filter.c */
@@ -1521,6 +1523,7 @@ void report_smtp_tx_rollback(const char *, uint64_t, uint32_t);
void report_smtp_protocol_client(const char *, uint64_t, const char *);
void report_smtp_protocol_server(const char *, uint64_t, const char *);
void report_smtp_filter_response(const char *, uint64_t, int, int, const char *);
+void report_smtp_timeout(const char *, uint64_t);
/* ruleset.c */