summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2019-07-26 06:30:14 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2019-07-26 06:30:14 +0000
commit22b237ce91c29dfa51dfc31816bee991f9f18016 (patch)
treecf446ec23827e96d1e23f08a72da192b1c407e2d /usr.sbin
parente9954786025ee41e7cad4b7a90f5c1b17e21c54f (diff)
even though RSET can be issued outside a tx, RFC states it's noop outside a
transaction so rename link-reset to tx-reset and only issue the smtp report when a reset _actually_ has a side-effect. note that rset is implicit on a message commit or rollback, so tx-reset get issued even though there was no explicit RSET. the filters are MUCH simpler to write when you don't need to track every event that can reset a tx :-)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/lka.c15
-rw-r--r--usr.sbin/smtpd/lka_report.c18
-rw-r--r--usr.sbin/smtpd/report_smtp.c15
-rw-r--r--usr.sbin/smtpd/smtp_session.c6
-rw-r--r--usr.sbin/smtpd/smtpd.h8
5 files changed, 32 insertions, 30 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 0911b9c4751..07b93f62347 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.238 2019/07/11 21:40:03 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.239 2019/07/26 06:30:13 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -426,26 +426,27 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
lka_report_smtp_link_tls(direction, &tv, reqid, ciphers);
return;
- case IMSG_REPORT_SMTP_LINK_RESET:
+ case IMSG_REPORT_SMTP_LINK_AUTH:
m_msg(&m, imsg);
m_get_string(&m, &direction);
m_get_timeval(&m, &tv);
m_get_id(&m, &reqid);
+ m_get_string(&m, &username);
+ m_get_string(&m, &result);
m_end(&m);
- lka_report_smtp_link_reset(direction, &tv, reqid);
+ lka_report_smtp_link_auth(direction, &tv, reqid, username, result);
return;
- case IMSG_REPORT_SMTP_LINK_AUTH:
+ case IMSG_REPORT_SMTP_TX_RESET:
m_msg(&m, imsg);
m_get_string(&m, &direction);
m_get_timeval(&m, &tv);
m_get_id(&m, &reqid);
- m_get_string(&m, &username);
- m_get_string(&m, &result);
+ m_get_u32(&m, &msgid);
m_end(&m);
- lka_report_smtp_link_auth(direction, &tv, reqid, username, result);
+ lka_report_smtp_tx_reset(direction, &tv, reqid, msgid);
return;
case IMSG_REPORT_SMTP_TX_BEGIN:
diff --git a/usr.sbin/smtpd/lka_report.c b/usr.sbin/smtpd/lka_report.c
index 610e100a308..d081cb3578b 100644
--- a/usr.sbin/smtpd/lka_report.c
+++ b/usr.sbin/smtpd/lka_report.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_report.c,v 1.21 2019/07/11 21:40:03 gilles Exp $ */
+/* $OpenBSD: lka_report.c,v 1.22 2019/07/26 06:30:13 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -53,9 +53,9 @@ static struct smtp_events {
{ "link-disconnect" },
{ "link-identify" },
{ "link-tls" },
- { "link-reset" },
{ "link-auth" },
+ { "tx-reset" },
{ "tx-begin" },
{ "tx-mail" },
{ "tx-rcpt" },
@@ -219,13 +219,6 @@ lka_report_smtp_link_disconnect(const char *direction, struct timeval *tv, uint6
}
void
-lka_report_smtp_link_reset(const char *direction, struct timeval *tv, uint64_t reqid)
-{
- report_smtp_broadcast(reqid, direction, tv, "link-reset",
- "%016"PRIx64"\n", reqid);
-}
-
-void
lka_report_smtp_link_auth(const char *direction, struct timeval *tv, uint64_t reqid,
const char *username, const char *result)
{
@@ -249,6 +242,13 @@ lka_report_smtp_link_tls(const char *direction, struct timeval *tv, uint64_t req
}
void
+lka_report_smtp_tx_reset(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid)
+{
+ report_smtp_broadcast(reqid, direction, tv, "tx-reset",
+ "%016"PRIx64"|%08x\n", reqid, msgid);
+}
+
+void
lka_report_smtp_tx_begin(const char *direction, struct timeval *tv, uint64_t reqid, uint32_t msgid)
{
report_smtp_broadcast(reqid, direction, tv, "tx-begin",
diff --git a/usr.sbin/smtpd/report_smtp.c b/usr.sbin/smtpd/report_smtp.c
index bdfa3e65925..168cb9b8d4b 100644
--- a/usr.sbin/smtpd/report_smtp.c
+++ b/usr.sbin/smtpd/report_smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: report_smtp.c,v 1.7 2019/07/11 21:40:03 gilles Exp $ */
+/* $OpenBSD: report_smtp.c,v 1.8 2019/07/26 06:30:13 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -109,32 +109,33 @@ report_smtp_link_disconnect(const char *direction, uint64_t qid)
}
void
-report_smtp_link_reset(const char *direction, uint64_t qid)
+report_smtp_link_auth(const char *direction, uint64_t qid, const char *user, const char *result)
{
struct timeval tv;
gettimeofday(&tv, NULL);
- m_create(p_lka, IMSG_REPORT_SMTP_LINK_RESET, 0, 0, -1);
+ m_create(p_lka, IMSG_REPORT_SMTP_LINK_AUTH, 0, 0, -1);
m_add_string(p_lka, direction);
m_add_timeval(p_lka, &tv);
m_add_id(p_lka, qid);
+ m_add_string(p_lka, user);
+ m_add_string(p_lka, result);
m_close(p_lka);
}
void
-report_smtp_link_auth(const char *direction, uint64_t qid, const char *user, const char *result)
+report_smtp_tx_reset(const char *direction, uint64_t qid, uint32_t msgid)
{
struct timeval tv;
gettimeofday(&tv, NULL);
- m_create(p_lka, IMSG_REPORT_SMTP_LINK_AUTH, 0, 0, -1);
+ m_create(p_lka, IMSG_REPORT_SMTP_TX_RESET, 0, 0, -1);
m_add_string(p_lka, direction);
m_add_timeval(p_lka, &tv);
m_add_id(p_lka, qid);
- m_add_string(p_lka, user);
- m_add_string(p_lka, result);
+ m_add_u32(p_lka, msgid);
m_close(p_lka);
}
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index c70c46b0e0d..a618c1f0dd7 100644
--- a/usr.sbin/smtpd/smtp_session.c
+++ b/usr.sbin/smtpd/smtp_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_session.c,v 1.401 2019/07/24 19:50:10 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.402 2019/07/26 06:30:13 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1724,8 +1724,6 @@ smtp_proceed_rset(struct smtp_session *s, const char *args)
smtp_tx_free(s->tx);
}
- report_smtp_link_reset("smtp-in", s->id);
-
smtp_reply(s, "250 %s Reset state",
esc_code(ESC_STATUS_OK, ESC_OTHER_STATUS));
}
@@ -2558,6 +2556,7 @@ smtp_tx_commit(struct smtp_tx *tx)
m_close(p_queue);
tree_xset(&wait_queue_commit, tx->session->id, tx->session);
report_smtp_tx_commit("smtp-in", tx->session->id, tx->msgid, tx->odatalen);
+ report_smtp_tx_reset("smtp-in", tx->session->id, tx->msgid);
smtp_filter_data_end(tx->session);
}
@@ -2568,6 +2567,7 @@ smtp_tx_rollback(struct smtp_tx *tx)
m_add_msgid(p_queue, tx->msgid);
m_close(p_queue);
report_smtp_tx_rollback("smtp-in", tx->session->id, tx->msgid);
+ report_smtp_tx_reset("smtp-in", tx->session->id, tx->msgid);
smtp_filter_data_end(tx->session);
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 72f2f5c3770..18dc58007ba 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.628 2019/07/11 21:40:03 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.629 2019/07/26 06:30:13 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -311,8 +311,8 @@ enum imsg_type {
IMSG_REPORT_SMTP_LINK_DISCONNECT,
IMSG_REPORT_SMTP_LINK_IDENTIFY,
IMSG_REPORT_SMTP_LINK_TLS,
- IMSG_REPORT_SMTP_LINK_RESET,
IMSG_REPORT_SMTP_LINK_AUTH,
+ IMSG_REPORT_SMTP_TX_RESET,
IMSG_REPORT_SMTP_TX_BEGIN,
IMSG_REPORT_SMTP_TX_MAIL,
IMSG_REPORT_SMTP_TX_RCPT,
@@ -1333,8 +1333,8 @@ void lka_report_smtp_link_connect(const char *, struct timeval *, uint64_t, cons
void lka_report_smtp_link_disconnect(const char *, struct timeval *, uint64_t);
void lka_report_smtp_link_identify(const char *, struct timeval *, uint64_t, const char *, const char *);
void lka_report_smtp_link_tls(const char *, struct timeval *, uint64_t, const char *);
-void lka_report_smtp_link_reset(const char *, struct timeval *, uint64_t);
void lka_report_smtp_link_auth(const char *, struct timeval *, uint64_t, const char *, const char *);
+void lka_report_smtp_tx_reset(const char *, struct timeval *, uint64_t, uint32_t);
void lka_report_smtp_tx_begin(const char *, struct timeval *, uint64_t, uint32_t);
void lka_report_smtp_tx_mail(const char *, struct timeval *, uint64_t, uint32_t, const char *, int);
void lka_report_smtp_tx_rcpt(const char *, struct timeval *, uint64_t, uint32_t, const char *, int);
@@ -1502,8 +1502,8 @@ void report_smtp_link_connect(const char *, uint64_t, const char *, int,
void report_smtp_link_disconnect(const char *, uint64_t);
void report_smtp_link_identify(const char *, uint64_t, const char *, const char *);
void report_smtp_link_tls(const char *, uint64_t, const char *);
-void report_smtp_link_reset(const char *, uint64_t);
void report_smtp_link_auth(const char *, uint64_t, const char *, const char *);
+void report_smtp_tx_reset(const char *, uint64_t, uint32_t);
void report_smtp_tx_begin(const char *, uint64_t, uint32_t);
void report_smtp_tx_mail(const char *, uint64_t, uint32_t, const char *, int);
void report_smtp_tx_rcpt(const char *, uint64_t, uint32_t, const char *, int);