summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/config.c6
-rw-r--r--usr.sbin/smtpd/lka.c115
-rw-r--r--usr.sbin/smtpd/lka_report.c86
-rw-r--r--usr.sbin/smtpd/mta_report.c139
-rw-r--r--usr.sbin/smtpd/parse.y20
-rw-r--r--usr.sbin/smtpd/smtp_report.c5
-rw-r--r--usr.sbin/smtpd/smtp_session.c4
-rw-r--r--usr.sbin/smtpd/smtpd.h47
-rw-r--r--usr.sbin/smtpd/smtpd/Makefile3
9 files changed, 352 insertions, 73 deletions
diff --git a/usr.sbin/smtpd/config.c b/usr.sbin/smtpd/config.c
index 00da2891252..22f367190a8 100644
--- a/usr.sbin/smtpd/config.c
+++ b/usr.sbin/smtpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.45 2018/11/03 13:42:24 gilles Exp $ */
+/* $OpenBSD: config.c,v 1.46 2018/11/30 15:33:40 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -91,6 +91,7 @@ config_default(void)
conf->sc_mda_wrappers = calloc(1, sizeof(*conf->sc_mda_wrappers));
conf->sc_processors_dict = calloc(1, sizeof(*conf->sc_processors_dict));
conf->sc_smtp_reporters_dict = calloc(1, sizeof(*conf->sc_smtp_reporters_dict));
+ conf->sc_mta_reporters_dict = calloc(1, sizeof(*conf->sc_mta_reporters_dict));
conf->sc_dispatcher_bounce = calloc(1, sizeof(*conf->sc_dispatcher_bounce));
limits = calloc(1, sizeof(*limits));
@@ -105,6 +106,7 @@ config_default(void)
conf->sc_mda_wrappers == NULL ||
conf->sc_processors_dict == NULL ||
conf->sc_smtp_reporters_dict == NULL||
+ conf->sc_mta_reporters_dict == NULL ||
conf->sc_dispatcher_bounce == NULL ||
limits == NULL)
goto error;
@@ -118,6 +120,7 @@ config_default(void)
dict_init(conf->sc_limits_dict);
dict_init(conf->sc_processors_dict);
dict_init(conf->sc_smtp_reporters_dict);
+ dict_init(conf->sc_mta_reporters_dict);
limit_mta_set_defaults(limits);
@@ -162,6 +165,7 @@ error:
free(conf->sc_processors_dict);
free(conf->sc_dispatcher_bounce);
free(conf->sc_smtp_reporters_dict);
+ free(conf->sc_mta_reporters_dict);
free(limits);
free(conf);
return NULL;
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 6d6124884a7..be9182b635f 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.214 2018/11/08 13:21:00 gilles Exp $ */
+/* $OpenBSD: lka.c,v 1.215 2018/11/30 15:33:40 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -419,7 +419,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_sockaddr(&m, (struct sockaddr *)&ss_dest);
m_end(&m);
- lka_report_smtp_link_connect(tm, reqid, rdns, &ss_src, &ss_dest);
+ lka_report_smtp_link_connect("smtp-in", tm, reqid, rdns, &ss_src, &ss_dest);
return;
case IMSG_SMTP_REPORT_LINK_DISCONNECT:
@@ -428,7 +428,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_id(&m, &reqid);
m_end(&m);
- lka_report_smtp_link_disconnect(tm, reqid);
+ lka_report_smtp_link_disconnect("smtp-in", tm, reqid);
return;
case IMSG_SMTP_REPORT_LINK_TLS:
@@ -438,7 +438,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_string(&m, &ciphers);
m_end(&m);
- lka_report_smtp_link_tls(tm, reqid, ciphers);
+ lka_report_smtp_link_tls("smtp-in", tm, reqid, ciphers);
return;
case IMSG_SMTP_REPORT_TX_BEGIN:
@@ -448,7 +448,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_u32(&m, &msgid);
m_end(&m);
- lka_report_smtp_tx_begin(tm, reqid, msgid);
+ lka_report_smtp_tx_begin("smtp-in", tm, reqid, msgid);
return;
case IMSG_SMTP_REPORT_TX_ENVELOPE:
@@ -459,7 +459,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_id(&m, &evpid);
m_end(&m);
- lka_report_smtp_tx_envelope(tm, reqid, msgid, evpid);
+ lka_report_smtp_tx_envelope("smtp-in", tm, reqid, msgid, evpid);
return;
case IMSG_SMTP_REPORT_TX_COMMIT:
@@ -470,16 +470,17 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_size(&m, &msgsz);
m_end(&m);
- lka_report_smtp_tx_commit(tm, reqid, msgid, msgsz);
+ lka_report_smtp_tx_commit("smtp-in", tm, reqid, msgid, msgsz);
return;
case IMSG_SMTP_REPORT_TX_ROLLBACK:
m_msg(&m, imsg);
m_get_time(&m, &tm);
m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
m_end(&m);
- lka_report_smtp_tx_rollback(tm, reqid);
+ lka_report_smtp_tx_rollback("smtp-in", tm, reqid, msgid);
return;
case IMSG_SMTP_REPORT_PROTOCOL_CLIENT:
@@ -489,7 +490,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_string(&m, &command);
m_end(&m);
- lka_report_smtp_protocol_client(tm, reqid, command);
+ lka_report_smtp_protocol_client("smtp-in", tm, reqid, command);
return;
case IMSG_SMTP_REPORT_PROTOCOL_SERVER:
@@ -499,9 +500,103 @@ lka_imsg(struct mproc *p, struct imsg *imsg)
m_get_string(&m, &response);
m_end(&m);
- lka_report_smtp_protocol_server(tm, reqid, response);
+ lka_report_smtp_protocol_server("smtp-in", tm, reqid, response);
+ return;
+
+ case IMSG_MTA_REPORT_LINK_CONNECT:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_string(&m, &rdns);
+ m_get_sockaddr(&m, (struct sockaddr *)&ss_src);
+ m_get_sockaddr(&m, (struct sockaddr *)&ss_dest);
+ m_end(&m);
+
+ lka_report_smtp_link_connect("smtp-out", tm, reqid, rdns, &ss_src, &ss_dest);
+ return;
+
+ case IMSG_MTA_REPORT_LINK_DISCONNECT:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_end(&m);
+
+ lka_report_smtp_link_disconnect("smtp-out", tm, reqid);
return;
+ case IMSG_MTA_REPORT_LINK_TLS:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_string(&m, &ciphers);
+ m_end(&m);
+
+ lka_report_smtp_link_tls("smtp-out", tm, reqid, ciphers);
+ return;
+
+ case IMSG_MTA_REPORT_TX_BEGIN:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
+ m_end(&m);
+
+ lka_report_smtp_tx_begin("smtp-out", tm, reqid, msgid);
+ return;
+
+ case IMSG_MTA_REPORT_TX_ENVELOPE:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
+ m_get_id(&m, &evpid);
+ m_end(&m);
+
+ lka_report_smtp_tx_envelope("smtp-out", tm, reqid, msgid, evpid);
+ return;
+
+ case IMSG_MTA_REPORT_TX_COMMIT:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
+ m_get_size(&m, &msgsz);
+ m_end(&m);
+
+ lka_report_smtp_tx_commit("smtp-out", tm, reqid, msgid, msgsz);
+ return;
+
+ case IMSG_MTA_REPORT_TX_ROLLBACK:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_u32(&m, &msgid);
+ m_end(&m);
+
+ lka_report_smtp_tx_rollback("smtp-out", tm, reqid, msgid);
+ return;
+
+ case IMSG_MTA_REPORT_PROTOCOL_CLIENT:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_string(&m, &command);
+ m_end(&m);
+
+ lka_report_smtp_protocol_client("smtp-out", tm, reqid, command);
+ return;
+
+ case IMSG_MTA_REPORT_PROTOCOL_SERVER:
+ m_msg(&m, imsg);
+ m_get_time(&m, &tm);
+ m_get_id(&m, &reqid);
+ m_get_string(&m, &response);
+ m_end(&m);
+
+ lka_report_smtp_protocol_server("smtp-out", tm, reqid, response);
+ return;
+
+
case IMSG_SMTP_FILTER:
m_msg(&m, imsg);
m_get_id(&m, &reqid);
diff --git a/usr.sbin/smtpd/lka_report.c b/usr.sbin/smtpd/lka_report.c
index ac1a53aa88a..964d52658e0 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.7 2018/11/08 13:21:00 gilles Exp $ */
+/* $OpenBSD: lka_report.c,v 1.8 2018/11/30 15:33:40 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -38,22 +38,30 @@
#define PROTOCOL_VERSION 1
static void
-report_smtp_broadcast(const char *format, ...)
+report_smtp_broadcast(const char *direction, time_t tm, const char *format, ...)
{
va_list ap;
void *hdl = NULL;
const char *reporter;
+ struct dict *d;
+
+ if (strcmp("smtp-in", direction) == 0)
+ d = env->sc_smtp_reporters_dict;
+ if (strcmp("smtp-out", direction) == 0)
+ d = env->sc_mta_reporters_dict;
va_start(ap, format);
- while (dict_iter(env->sc_smtp_reporters_dict, &hdl, &reporter, NULL)) {
- if (io_vprintf(lka_proc_get_io(reporter), format, ap) == -1)
+ while (dict_iter(d, &hdl, &reporter, NULL)) {
+ if (io_printf(lka_proc_get_io(reporter), "report|%d|%zd|%s|",
+ PROTOCOL_VERSION, tm, direction) == -1 ||
+ io_vprintf(lka_proc_get_io(reporter), format, ap) == -1)
fatalx("failed to write to processor");
}
va_end(ap);
}
void
-lka_report_smtp_link_connect(time_t tm, uint64_t reqid, const char *rdns,
+lka_report_smtp_link_connect(const char *direction, time_t tm, uint64_t reqid, const char *rdns,
const struct sockaddr_storage *ss_src,
const struct sockaddr_storage *ss_dest)
{
@@ -75,72 +83,68 @@ lka_report_smtp_link_connect(time_t tm, uint64_t reqid, const char *rdns,
(void)strlcpy(src, ss_to_text(ss_src), sizeof src);
(void)strlcpy(dest, ss_to_text(ss_dest), sizeof dest);
- report_smtp_broadcast("report|%d|%zd|smtp-in|link-connect|"
- "%016"PRIx64"|%s|%s:%d|%s:%d\n",
- PROTOCOL_VERSION,
- tm, reqid, rdns, src, src_port, dest, dest_port);
+ report_smtp_broadcast(direction, tm,
+ "link-connect|%016"PRIx64"|%s|%s:%d|%s:%d\n",
+ reqid, rdns, src, src_port, dest, dest_port);
}
void
-lka_report_smtp_link_disconnect(time_t tm, uint64_t reqid)
+lka_report_smtp_link_disconnect(const char *direction, time_t tm, uint64_t reqid)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|link-disconnect|"
- "%016"PRIx64"\n",
- PROTOCOL_VERSION, tm, reqid);
+ report_smtp_broadcast(direction, tm,
+ "link-disconnect|%016"PRIx64"\n", reqid);
}
void
-lka_report_smtp_link_tls(time_t tm, uint64_t reqid, const char *ciphers)
+lka_report_smtp_link_tls(const char *direction, time_t tm, uint64_t reqid, const char *ciphers)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|link-tls|"
- "%016"PRIx64"|%s\n",
- PROTOCOL_VERSION, tm, reqid, ciphers);
+ report_smtp_broadcast(direction, tm,
+ "link-tls|%016"PRIx64"|%s\n", reqid, ciphers);
}
void
-lka_report_smtp_tx_begin(time_t tm, uint64_t reqid, uint32_t msgid)
+lka_report_smtp_tx_begin(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|tx-begin|"
- "%016"PRIx64"|%08x\n",
- PROTOCOL_VERSION, tm, reqid, msgid);
+ report_smtp_broadcast(direction, tm,
+ "tx-begin|%016"PRIx64"|%08x\n", reqid, msgid);
}
void
-lka_report_smtp_tx_envelope(time_t tm, uint64_t reqid, uint32_t msgid, uint64_t evpid)
+lka_report_smtp_tx_envelope(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid, uint64_t evpid)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|tx-envelope|"
- "%016"PRIx64"|%08x|%016"PRIx64"\n",
- PROTOCOL_VERSION, tm, reqid, msgid, evpid);
+ report_smtp_broadcast(direction, tm,
+ "tx-envelope|%016"PRIx64"|%08x|%016"PRIx64"\n",
+ reqid, msgid, evpid);
}
void
-lka_report_smtp_tx_commit(time_t tm, uint64_t reqid, uint32_t msgid, size_t msgsz)
+lka_report_smtp_tx_commit(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid, size_t msgsz)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|tx-commit|"
- "%016"PRIx64"|%08x|%zd\n",
- PROTOCOL_VERSION, tm, reqid, msgid, msgsz);
+ report_smtp_broadcast(direction, tm,
+ "tx-commit|%016"PRIx64"|%08x|%zd\n",
+ reqid, msgid, msgsz);
}
void
-lka_report_smtp_tx_rollback(time_t tm, uint64_t reqid)
+lka_report_smtp_tx_rollback(const char *direction, time_t tm, uint64_t reqid, uint32_t msgid)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|tx-rollback|"
- "%016"PRIx64"\n",
- PROTOCOL_VERSION, tm, reqid);
+ report_smtp_broadcast(direction, tm,
+ "tx-rollback|%016"PRIx64"|%08x\n",
+ reqid, msgid);
}
void
-lka_report_smtp_protocol_client(time_t tm, uint64_t reqid, const char *command)
+lka_report_smtp_protocol_client(const char *direction, time_t tm, uint64_t reqid, const char *command)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|protocol-client|"
- "%016"PRIx64"|%s\n",
- PROTOCOL_VERSION, tm, reqid, command);
+ report_smtp_broadcast(direction, tm,
+ "protocol-client|%016"PRIx64"|%s\n",
+ reqid, command);
}
void
-lka_report_smtp_protocol_server(time_t tm, uint64_t reqid, const char *response)
+lka_report_smtp_protocol_server(const char *direction, time_t tm, uint64_t reqid, const char *response)
{
- report_smtp_broadcast("report|%d|%zd|smtp-in|protocol-server|"
- "%016"PRIx64"|%s\n",
- PROTOCOL_VERSION, tm, reqid, response);
+ report_smtp_broadcast(direction, tm,
+ "protocol-server|%016"PRIx64"|%s\n",
+ reqid, response);
}
diff --git a/usr.sbin/smtpd/mta_report.c b/usr.sbin/smtpd/mta_report.c
new file mode 100644
index 00000000000..6e53151333a
--- /dev/null
+++ b/usr.sbin/smtpd/mta_report.c
@@ -0,0 +1,139 @@
+/* $OpenBSD: mta_report.c,v 1.1 2018/11/30 15:33:40 gilles Exp $ */
+
+/*
+ * Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/tree.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <event.h>
+#include <imsg.h>
+#include <limits.h>
+#include <inttypes.h>
+#include <openssl/ssl.h>
+#include <resolv.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <vis.h>
+
+#include "smtpd.h"
+#include "log.h"
+#include "ssl.h"
+#include "rfc5322.h"
+
+void
+mta_report_link_connect(uint64_t qid, const char *rdns,
+ const struct sockaddr_storage *ss_src,
+ const struct sockaddr_storage *ss_dest)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_LINK_CONNECT, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_string(p_lka, rdns);
+ m_add_sockaddr(p_lka, (const struct sockaddr *)ss_src);
+ m_add_sockaddr(p_lka, (const struct sockaddr *)ss_dest);
+ m_close(p_lka);
+}
+
+void
+mta_report_link_tls(uint64_t qid, const char *ssl)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_LINK_TLS, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_string(p_lka, ssl);
+ m_close(p_lka);
+}
+
+void
+mta_report_link_disconnect(uint64_t qid)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_LINK_DISCONNECT, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_close(p_lka);
+}
+
+void
+mta_report_tx_begin(uint64_t qid, uint32_t msgid)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_TX_BEGIN, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_u32(p_lka, msgid);
+ m_close(p_lka);
+}
+
+void
+mta_report_tx_envelope(uint64_t qid, uint32_t msgid, uint64_t evpid)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_TX_ENVELOPE, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_u32(p_lka, msgid);
+ m_add_id(p_lka, evpid);
+ m_close(p_lka);
+}
+
+void
+mta_report_tx_commit(uint64_t qid, uint32_t msgid, size_t msgsz)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_TX_COMMIT, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_u32(p_lka, msgid);
+ m_add_size(p_lka, msgsz);
+ m_close(p_lka);
+}
+
+void
+mta_report_tx_rollback(uint64_t qid, uint32_t msgid)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_TX_ROLLBACK, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_u32(p_lka, msgid);
+ m_close(p_lka);
+}
+
+void
+mta_report_protocol_client(uint64_t qid, const char *command)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_PROTOCOL_CLIENT, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_string(p_lka, command);
+ m_close(p_lka);
+}
+
+void
+mta_report_protocol_server(uint64_t qid, const char *response)
+{
+ m_create(p_lka, IMSG_MTA_REPORT_PROTOCOL_SERVER, 0, 0, -1);
+ m_add_time(p_lka, time(NULL));
+ m_add_id(p_lka, qid);
+ m_add_string(p_lka, response);
+ m_close(p_lka);
+}
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index 98772c8a464..fcc2490c939 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.231 2018/11/29 12:48:16 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.232 2018/11/30 15:33:40 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -190,7 +190,7 @@ typedef struct {
%token PKI PORT PROC
%token QUEUE QUIT
%token RCPT_TO RECIPIENT RECEIVEDAUTH RELAY REJECT REPORT REWRITE RSET
-%token SCHEDULER SENDER SENDERS SMTP SMTP_IN SMTPS SOCKET SRC SUB_ADDR_DELIM
+%token SCHEDULER SENDER SENDERS SMTP SMTP_IN SMTP_OUT SMTPS SOCKET SRC SUB_ADDR_DELIM
%token TABLE TAG TAGGED TLS TLS_REQUIRE TTL
%token USER USERBASE
%token VERIFY VIRTUAL
@@ -491,12 +491,25 @@ REPORT SMTP_IN ON STRING {
YYERROR;
}
if (dict_get(conf->sc_smtp_reporters_dict, $4)) {
- yyerror("processor already registered for smtp reporting: %s", $4);
+ yyerror("processor already registered for smtp-in reporting: %s", $4);
free($4);
YYERROR;
}
dict_set(conf->sc_smtp_reporters_dict, $4, (void *)~0);
}
+| REPORT SMTP_OUT ON STRING {
+ if (! dict_get(conf->sc_processors_dict, $4)) {
+ yyerror("no processor exist with that name: %s", $4);
+ free($4);
+ YYERROR;
+ }
+ if (dict_get(conf->sc_mta_reporters_dict, $4)) {
+ yyerror("processor already registered for smtp-out reporting: %s", $4);
+ free($4);
+ YYERROR;
+ }
+ dict_set(conf->sc_mta_reporters_dict, $4, (void *)~0);
+}
;
@@ -1915,6 +1928,7 @@ lookup(char *s)
{ "senders", SENDERS },
{ "smtp", SMTP },
{ "smtp-in", SMTP_IN },
+ { "smtp-out", SMTP_OUT },
{ "smtps", SMTPS },
{ "socket", SOCKET },
{ "src", SRC },
diff --git a/usr.sbin/smtpd/smtp_report.c b/usr.sbin/smtpd/smtp_report.c
index ea70ee138da..44152742c67 100644
--- a/usr.sbin/smtpd/smtp_report.c
+++ b/usr.sbin/smtpd/smtp_report.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp_report.c,v 1.4 2018/11/08 13:21:00 gilles Exp $ */
+/* $OpenBSD: smtp_report.c,v 1.5 2018/11/30 15:33:40 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -109,11 +109,12 @@ smtp_report_tx_commit(uint64_t qid, uint32_t msgid, size_t msgsz)
}
void
-smtp_report_tx_rollback(uint64_t qid)
+smtp_report_tx_rollback(uint64_t qid, uint32_t msgid)
{
m_create(p_lka, IMSG_SMTP_REPORT_TX_ROLLBACK, 0, 0, -1);
m_add_time(p_lka, time(NULL));
m_add_id(p_lka, qid);
+ 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 de7836b7a8b..6c8aab4db2a 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.355 2018/11/29 12:48:16 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.356 2018/11/30 15:33:40 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -2393,7 +2393,7 @@ smtp_tx_rollback(struct smtp_tx *tx)
m_create(p_queue, IMSG_SMTP_MESSAGE_ROLLBACK, 0, 0, -1);
m_add_msgid(p_queue, tx->msgid);
m_close(p_queue);
- smtp_report_tx_rollback(tx->session->id);
+ smtp_report_tx_rollback(tx->session->id, tx->msgid);
}
static int
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index fcb29730a81..8dce4578043 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.574 2018/11/29 12:48:16 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.575 2018/11/30 15:33:40 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -308,15 +308,23 @@ enum imsg_type {
IMSG_SMTP_REPORT_LINK_CONNECT,
IMSG_SMTP_REPORT_LINK_DISCONNECT,
IMSG_SMTP_REPORT_LINK_TLS,
-
IMSG_SMTP_REPORT_TX_BEGIN,
IMSG_SMTP_REPORT_TX_ENVELOPE,
IMSG_SMTP_REPORT_TX_COMMIT,
IMSG_SMTP_REPORT_TX_ROLLBACK,
-
IMSG_SMTP_REPORT_PROTOCOL_CLIENT,
IMSG_SMTP_REPORT_PROTOCOL_SERVER,
+ IMSG_MTA_REPORT_LINK_CONNECT,
+ IMSG_MTA_REPORT_LINK_DISCONNECT,
+ IMSG_MTA_REPORT_LINK_TLS,
+ IMSG_MTA_REPORT_TX_BEGIN,
+ IMSG_MTA_REPORT_TX_ENVELOPE,
+ IMSG_MTA_REPORT_TX_COMMIT,
+ IMSG_MTA_REPORT_TX_ROLLBACK,
+ IMSG_MTA_REPORT_PROTOCOL_CLIENT,
+ IMSG_MTA_REPORT_PROTOCOL_SERVER,
+
IMSG_SMTP_FILTER,
IMSG_CA_PRIVENC,
@@ -567,6 +575,7 @@ struct smtpd {
struct dict *sc_processors_dict;
struct dict *sc_smtp_reporters_dict;
+ struct dict *sc_mta_reporters_dict;
int sc_ttl;
#define MAX_BOUNCE_WARN 4
@@ -1298,15 +1307,15 @@ struct io *lka_proc_get_io(const char *);
/* lka_report.c */
-void lka_report_smtp_link_connect(time_t, uint64_t, const char *, const struct sockaddr_storage *, const struct sockaddr_storage *);
-void lka_report_smtp_link_disconnect(time_t, uint64_t);
-void lka_report_smtp_link_tls(time_t, uint64_t, const char *);
-void lka_report_smtp_tx_begin(time_t, uint64_t, uint32_t);
-void lka_report_smtp_tx_envelope(time_t, uint64_t, uint32_t, uint64_t);
-void lka_report_smtp_tx_commit(time_t, uint64_t, uint32_t, size_t);
-void lka_report_smtp_tx_rollback(time_t, uint64_t);
-void lka_report_smtp_protocol_client(time_t, uint64_t, const char *);
-void lka_report_smtp_protocol_server(time_t, uint64_t, const char *);
+void lka_report_smtp_link_connect(const char *, time_t, uint64_t, const char *, const struct sockaddr_storage *, const struct sockaddr_storage *);
+void lka_report_smtp_link_disconnect(const char *, time_t, uint64_t);
+void lka_report_smtp_link_tls(const char *, time_t, uint64_t, const char *);
+void lka_report_smtp_tx_begin(const char *, time_t, uint64_t, uint32_t);
+void lka_report_smtp_tx_envelope(const char *, time_t, uint64_t, uint32_t, uint64_t);
+void lka_report_smtp_tx_commit(const char *, time_t, uint64_t, uint32_t, size_t);
+void lka_report_smtp_tx_rollback(const char *, time_t, uint64_t, uint32_t);
+void lka_report_smtp_protocol_client(const char *, time_t, uint64_t, const char *);
+void lka_report_smtp_protocol_server(const char *, time_t, uint64_t, const char *);
/* lka_filter.c */
@@ -1414,6 +1423,18 @@ const char *mta_host_to_text(struct mta_host *);
const char *mta_relay_to_text(struct mta_relay *);
+/* mta_report.c */
+void mta_report_link_connect(uint64_t, const char *, const struct sockaddr_storage *, const struct sockaddr_storage *);
+void mta_report_link_disconnect(uint64_t);
+void mta_report_link_tls(uint64_t, const char *);
+void mta_report_tx_begin(uint64_t, uint32_t);
+void mta_report_tx_envelope(uint64_t, uint32_t, uint64_t);
+void mta_report_tx_commit(uint64_t, uint32_t, size_t);
+void mta_report_tx_rollback(uint64_t, uint32_t);
+void mta_report_protocol_client(uint64_t, const char *);
+void mta_report_protocol_server(uint64_t, const char *);
+
+
/* mta_session.c */
void mta_session(struct mta_relay *, struct mta_route *);
void mta_session_imsg(struct mproc *, struct imsg *);
@@ -1488,7 +1509,7 @@ void smtp_report_link_tls(uint64_t, const char *);
void smtp_report_tx_begin(uint64_t, uint32_t);
void smtp_report_tx_envelope(uint64_t, uint32_t, uint64_t);
void smtp_report_tx_commit(uint64_t, uint32_t, size_t);
-void smtp_report_tx_rollback(uint64_t);
+void smtp_report_tx_rollback(uint64_t, uint32_t);
void smtp_report_protocol_client(uint64_t, const char *);
void smtp_report_protocol_server(uint64_t, const char *);
diff --git a/usr.sbin/smtpd/smtpd/Makefile b/usr.sbin/smtpd/smtpd/Makefile
index 1a17e1c7223..568e908d4df 100644
--- a/usr.sbin/smtpd/smtpd/Makefile
+++ b/usr.sbin/smtpd/smtpd/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.97 2018/11/03 15:41:47 gilles Exp $
+# $OpenBSD: Makefile,v 1.98 2018/11/30 15:33:40 gilles Exp $
.PATH: ${.CURDIR}/..
@@ -33,6 +33,7 @@ SRCS+= mda_unpriv.c
SRCS+= mda_variables.c
SRCS+= mproc.c
SRCS+= mta.c
+SRCS+= mta_report.c
SRCS+= mta_session.c
SRCS+= parse.y
SRCS+= pony.c