diff options
author | Gilles Chehade <gilles@poolp.org> | 2019-01-05 20:41:09 +0100 |
---|---|---|
committer | Gilles Chehade <gilles@poolp.org> | 2019-01-05 20:41:09 +0100 |
commit | ef2f368219152771ac32adaa05dc1aee4c2bfe29 (patch) | |
tree | cc57d171c3cb44eb00eab89a66e1af28b42255e8 | |
parent | Merge branch 'master' into portable (diff) | |
parent | sync (diff) | |
download | OpenSMTPD-ef2f368219152771ac32adaa05dc1aee4c2bfe29.tar.xz OpenSMTPD-ef2f368219152771ac32adaa05dc1aee4c2bfe29.zip |
Merge branch 'master' into portable
-rw-r--r-- | smtpd/lka.c | 11 | ||||
-rw-r--r-- | smtpd/lka_report.c | 12 | ||||
-rw-r--r-- | smtpd/mda.c | 12 | ||||
-rw-r--r-- | smtpd/report_smtp.c | 16 | ||||
-rw-r--r-- | smtpd/smtp_session.c | 30 | ||||
-rw-r--r-- | smtpd/smtpd.h | 5 |
6 files changed, 55 insertions, 31 deletions
diff --git a/smtpd/lka.c b/smtpd/lka.c index eb7b2cac..eff9cf71 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> @@ -533,6 +533,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 ddf7c7cf..cf43d51a 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> @@ -68,6 +68,8 @@ static struct smtp_events { { "protocol-server" }, { "filter-response" }, + + { "timeout" }, }; @@ -410,3 +412,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 d8e7e1f9..97b60631 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> @@ -55,6 +55,7 @@ struct mda_envelope { TAILQ_ENTRY(mda_envelope) entry; + uint64_t session_id; uint64_t id; time_t creation; char *sender; @@ -108,7 +109,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); @@ -193,7 +194,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); @@ -678,7 +679,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, @@ -798,12 +799,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 3f82e2cc..81e9584c 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> @@ -271,3 +271,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 917273b1..707e32cb 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> @@ -1089,6 +1089,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); @@ -1149,6 +1154,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; @@ -2559,13 +2565,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) { @@ -2672,25 +2671,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 11f7d321..eaf8a62b 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> @@ -345,6 +345,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, @@ -1382,6 +1383,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 */ @@ -1547,6 +1549,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 */ |