summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2018-12-21 19:07:48 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2018-12-21 19:07:48 +0000
commita9719bce28a24760f1fd6d8c2d2c11e18448dbea (patch)
tree3cb72b56c403ad69e332d930c3bdadf087648b4b /usr.sbin/smtpd
parent2141ce5f7d2334c64c6767179cf0a1ebc10cd757 (diff)
- make the proc filter fd non-blocking
- client sessions may disappear while filter is streaming data, dont panic
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/lka_filter.c7
-rw-r--r--usr.sbin/smtpd/lka_proc.c5
-rw-r--r--usr.sbin/smtpd/parse.y6
3 files changed, 11 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/lka_filter.c b/usr.sbin/smtpd/lka_filter.c
index a33046504cc..a2b8b446204 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.19 2018/12/21 17:31:57 gilles Exp $ */
+/* $OpenBSD: lka_filter.c,v 1.20 2018/12/21 19:07:47 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -591,7 +591,10 @@ filter_data_next(uint64_t token, uint64_t reqid, const char *line)
struct filter_entry *filter_entry;
struct filter *filter;
- fs = tree_xget(&sessions, reqid);
+ /* client session may have disappeared since we started streaming data */
+ if ((fs = tree_get(&sessions, reqid)) == NULL)
+ return;
+
filter_chain = dict_get(&filter_chains, fs->filter_name);
TAILQ_FOREACH(filter_entry, &filter_chain->chain[fs->phase], entries)
diff --git a/usr.sbin/smtpd/lka_proc.c b/usr.sbin/smtpd/lka_proc.c
index 90fe9dbb441..fb3a4137628 100644
--- a/usr.sbin/smtpd/lka_proc.c
+++ b/usr.sbin/smtpd/lka_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_proc.c,v 1.5 2018/12/21 14:33:52 gilles Exp $ */
+/* $OpenBSD: lka_proc.c,v 1.6 2018/12/21 19:07:47 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -73,6 +73,9 @@ lka_proc_forked(const char *name, int fd)
processor = xcalloc(1, sizeof *processor);
processor->name = xstrdup(name);
processor->io = io_new();
+
+ io_set_nonblocking(fd);
+
io_set_fd(processor->io, fd);
io_set_callback(processor->io, processor_io, processor->name);
dict_xset(&processors, name, processor);
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index 8b4461e8e7d..aba2252fc25 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.239 2018/12/21 17:04:46 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.240 2018/12/21 19:07:47 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -107,7 +107,7 @@ struct dispatcher *dispatcher;
struct rule *rule;
struct processor *processor;
struct filter_config *filter_config;
-/*static uint64_t last_dynproc_id = 1;*/
+static uint64_t last_dynproc_id = 1;
enum listen_options {
LO_FAMILY = 0x000001,
@@ -1333,7 +1333,6 @@ filterel
;
filter:
-/*
FILTER STRING PROC STRING {
if (dict_get(conf->sc_filters_dict, $2)) {
yyerror("filter already exists with that name: %s", $2);
@@ -1383,7 +1382,6 @@ FILTER STRING PROC_EXEC STRING {
filter_config = NULL;
}
|
-*/
FILTER STRING BUILTIN {
if (dict_get(conf->sc_filters_dict, $2)) {
yyerror("filter already exists with that name: %s", $2);