summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorOmar Polo <op@cvs.openbsd.org>2024-08-12 09:32:45 +0000
committerOmar Polo <op@cvs.openbsd.org>2024-08-12 09:32:45 +0000
commitb22873e261d9908008e68e9a10c74ae93173ef62 (patch)
tree2bd5c3f397cc74279f92fbc8c36402e87cdec6ef /usr.sbin
parent6d3741051db979e55d5280d927765e4ef3b7a53c (diff)
implement the report response for proc-filters too
Reported by renegm on GitHub: <https://github.com/OpenSMTPD/OpenSMTPD/issues/1257> ok gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/lka_filter.c18
-rw-r--r--usr.sbin/smtpd/smtp_session.c3
-rw-r--r--usr.sbin/smtpd/smtpd.h3
3 files changed, 21 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/lka_filter.c b/usr.sbin/smtpd/lka_filter.c
index 08db127c4c0..b9c5d55c15f 100644
--- a/usr.sbin/smtpd/lka_filter.c
+++ b/usr.sbin/smtpd/lka_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_filter.c,v 1.77 2024/05/14 13:38:54 op Exp $ */
+/* $OpenBSD: lka_filter.c,v 1.78 2024/08/12 09:32:44 op Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -47,6 +47,7 @@ static int filter_builtins_data(struct filter_session *, struct filter *, uint64
static int filter_builtins_commit(struct filter_session *, struct filter *, uint64_t, const char *);
static void filter_result_proceed(uint64_t);
+static void filter_result_report(uint64_t, const char *);
static void filter_result_junk(uint64_t);
static void filter_result_rewrite(uint64_t, const char *);
static void filter_result_reject(uint64_t, const char *);
@@ -657,6 +658,8 @@ lka_filter_process_response(const char *name, const char *line)
filter_result_reject(reqid, parameter);
else if (strncmp(response, "disconnect|", 11) == 0)
filter_result_disconnect(reqid, parameter);
+ else if (strncmp(response, "report|", 7) == 0)
+ filter_result_report(reqid, parameter);
else
fatalx("Invalid directive: %s", line);
}
@@ -957,6 +960,16 @@ filter_result_proceed(uint64_t reqid)
}
static void
+filter_result_report(uint64_t reqid, const char *param)
+{
+ m_create(p_dispatcher, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
+ m_add_id(p_dispatcher, reqid);
+ m_add_int(p_dispatcher, FILTER_REPORT);
+ m_add_string(p_dispatcher, param);
+ m_close(p_dispatcher);
+}
+
+static void
filter_result_junk(uint64_t reqid)
{
m_create(p_dispatcher, IMSG_FILTER_SMTP_PROTOCOL, 0, 0, -1);
@@ -1633,6 +1646,9 @@ lka_report_smtp_filter_response(const char *direction, struct timeval *tv, uint6
case FILTER_PROCEED:
response_name = "proceed";
break;
+ case FILTER_REPORT:
+ response_name = "report";
+ break;
case FILTER_JUNK:
response_name = "junk";
break;
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index b72d2959182..85659829f54 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.442 2024/03/20 17:52:43 op Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.443 2024/08/12 09:32:44 op Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1026,6 +1026,7 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg)
filter_param = s->filter_param;
/* fallthrough */
+ case FILTER_REPORT:
case FILTER_REWRITE:
smtp_report_filter_response(s, s->filter_phase,
filter_response,
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 6eddff3c725..2be11bf2b53 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.686 2024/06/02 23:26:39 jsg Exp $ */
+/* $OpenBSD: smtpd.h,v 1.687 2024/08/12 09:32:44 op Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1125,6 +1125,7 @@ struct filter_config {
enum filter_status {
FILTER_PROCEED,
+ FILTER_REPORT,
FILTER_REWRITE,
FILTER_REJECT,
FILTER_DISCONNECT,