aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2017-05-22 13:43:15 +0000
committergilles <gilles@openbsd.org>2017-05-22 13:43:15 +0000
commit507a6d672176ef0e309b4bbb15b2308123a461f4 (patch)
tree3eb18db5c7bce2445902b41bea627028d53a023f
parentstub for the smtp filter protocol, currently always returns -1 (diff)
downloadOpenSMTPD-507a6d672176ef0e309b4bbb15b2308123a461f4.tar.xz
OpenSMTPD-507a6d672176ef0e309b4bbb15b2308123a461f4.zip
- filters are currently broken, do not allow using them until we're done
-rw-r--r--parse.y114
-rw-r--r--smtp.c10
-rw-r--r--smtpd.h8
-rw-r--r--smtpd/Makefile3
4 files changed, 19 insertions, 116 deletions
diff --git a/parse.y b/parse.y
index e92a07b8..20736f65 100644
--- a/parse.y
+++ b/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.195 2017/02/13 12:43:43 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.196 2017/05/22 13:43:15 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -152,10 +152,6 @@ void set_localaddrs(struct table *);
int delaytonum(char *);
int is_if_in_group(const char *, const char *);
-static struct filter_conf *create_filter_proc(char *, char *);
-static struct filter_conf *create_filter_chain(char *);
-static int add_filter_arg(struct filter_conf *, char *);
-
static int config_lo_filter(struct listen_opts *, char *);
static int config_lo_mask_source(struct listen_opts *);
@@ -922,22 +918,6 @@ main : BOUNCEWARN {
listen_opts.family = AF_UNSPEC;
listen_opts.flags |= F_EXT_DSN;
} ON listener_type
- | FILTER STRING STRING {
- if (!strcmp($3, "chain")) {
- free($3);
- if ((filter = create_filter_chain($2)) == NULL) {
- free($2);
- YYERROR;
- }
- }
- else {
- if ((filter = create_filter_proc($2, $3)) == NULL) {
- free($2);
- free($3);
- YYERROR;
- }
- }
- } filter_args
| PKI STRING {
char buf[HOST_NAME_MAX+1];
@@ -983,15 +963,6 @@ main : BOUNCEWARN {
}
;
-filter_args :
- | STRING {
- if (!add_filter_arg(filter, $1)) {
- free($1);
- YYERROR;
- }
- } filter_args
- ;
-
table : TABLE STRING STRING {
char *p, *backend, *config;
@@ -2182,13 +2153,8 @@ config_listener(struct listener *h, struct listen_opts *lo)
if (lo->hostname == NULL)
lo->hostname = conf->sc_hostname;
- if (lo->filtername) {
- if (dict_get(&conf->sc_filters, lo->filtername) == NULL) {
- log_warnx("undefined filter: %s", lo->filtername);
- fatalx(NULL);
- }
+ if (lo->filtername)
(void)strlcpy(h->filter, lo->filtername, sizeof(h->filter));
- }
h->pki_name[0] = '\0';
@@ -2559,82 +2525,6 @@ end:
return ret;
}
-static struct filter_conf *
-create_filter_proc(char *name, char *prog)
-{
- struct filter_conf *f;
- char *path;
-
- if (dict_get(&conf->sc_filters, name)) {
- yyerror("filter \"%s\" already defined", name);
- return (NULL);
- }
-
- if (asprintf(&path, "%s/filter-%s", PATH_LIBEXEC, prog) == -1) {
- yyerror("filter \"%s\" asprintf failed", name);
- return (0);
- }
-
- f = xcalloc(1, sizeof(*f), "create_filter");
- f->path = path;
- f->name = name;
- f->argv[f->argc++] = name;
-
- dict_xset(&conf->sc_filters, name, f);
-
- return (f);
-}
-
-static struct filter_conf *
-create_filter_chain(char *name)
-{
- struct filter_conf *f;
-
- if (dict_get(&conf->sc_filters, name)) {
- yyerror("filter \"%s\" already defined", name);
- return (NULL);
- }
-
- f = xcalloc(1, sizeof(*f), "create_filter_chain");
- f->chain = 1;
- f->name = name;
-
- dict_xset(&conf->sc_filters, name, f);
-
- return (f);
-}
-
-static int
-add_filter_arg(struct filter_conf *f, char *arg)
-{
- int i;
-
- if (f->argc == MAX_FILTER_ARGS) {
- yyerror("filter \"%s\" is full", f->name);
- return (0);
- }
-
- if (f->chain) {
- if (dict_get(&conf->sc_filters, arg) == NULL) {
- yyerror("undefined filter \"%s\"", arg);
- return (0);
- }
- if (dict_get(&conf->sc_filters, arg) == f) {
- yyerror("filter chain cannot contain itself");
- return (0);
- }
- for (i = 0; i < f->argc; ++i)
- if (strcasecmp(f->argv[i], arg) == 0) {
- yyerror("filter chain cannot contain twice the same filter instance");
- return (0);
- }
- }
-
- f->argv[f->argc++] = arg;
-
- return (1);
-}
-
static int
config_lo_filter(struct listen_opts *lo, char *filter_name) {
if (lo->options & LO_FILTER) {
diff --git a/smtp.c b/smtp.c
index 685afcca..52316189 100644
--- a/smtp.c
+++ b/smtp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtp.c,v 1.155 2016/03/25 15:06:58 krw Exp $ */
+/* $OpenBSD: smtp.c,v 1.156 2017/05/22 13:43:15 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -253,6 +253,7 @@ smtp_accept(int fd, short event, void *p)
struct sockaddr_storage ss;
socklen_t len;
int sock;
+ int ret;
if (env->sc_flags & SMTPD_SMTP_PAUSED)
fatalx("smtp_session: unexpected client");
@@ -275,7 +276,12 @@ smtp_accept(int fd, short event, void *p)
fatal("smtp_accept");
}
- if (smtp_session(listener, sock, &ss, NULL) == -1) {
+ if (listener->filter[0])
+ ret = smtpf_session(listener, sock, &ss, NULL);
+ else
+ ret = smtp_session(listener, sock, &ss, NULL);
+
+ if (ret == -1) {
log_warn("warn: Failed to create SMTP session");
close(sock);
return;
diff --git a/smtpd.h b/smtpd.h
index 069c20a4..a4895156 100644
--- a/smtpd.h
+++ b/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.530 2017/02/13 12:23:47 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.531 2017/05/22 13:43:15 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -1391,6 +1391,12 @@ void smtp_filter_response(uint64_t, int, int, uint32_t, const char *);
void smtp_filter_fd(uint64_t, int);
+/* smtpf_session.c */
+int smtpf_session(struct listener *, int, const struct sockaddr_storage *,
+ const char *);
+void smtpf_session_imsg(struct mproc *, struct imsg *);
+
+
/* smtpd.c */
void imsg_dispatch(struct mproc *, struct imsg *);
const char *proc_name(enum smtp_proc_type);
diff --git a/smtpd/Makefile b/smtpd/Makefile
index f5a0914b..314fe2a5 100644
--- a/smtpd/Makefile
+++ b/smtpd/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.85 2016/01/09 09:48:03 jung Exp $
+# $OpenBSD: Makefile,v 1.86 2017/05/22 13:43:15 gilles Exp $
.PATH: ${.CURDIR}/..
@@ -40,6 +40,7 @@ SRCS+= scheduler.c
SRCS+= scheduler_backend.c
SRCS+= smtp.c
SRCS+= smtp_session.c
+SRCS+= smtpf_session.c
SRCS+= smtpd.c
SRCS+= ssl.c
SRCS+= ssl_smtpd.c