summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2011-09-12 20:47:16 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2011-09-12 20:47:16 +0000
commitf08fc97c4874b50e4e253344604bd7728be4698a (patch)
treed67e5e3a1b4c259aabf3d1e5f4bc38ea512fa58e
parentc903dba584a1bf805485236c727a87eac6208170 (diff)
- introduce filtermask in struct smtpd
- do not forward lines to mfa when FILTER_DATALINE is not set in filtermask prevents smtpd from handling mails slowly while I'm hacking on filters support
-rw-r--r--usr.sbin/smtpd/filter.h12
-rw-r--r--usr.sbin/smtpd/smtp_session.c14
-rw-r--r--usr.sbin/smtpd/smtpd.h3
3 files changed, 17 insertions, 12 deletions
diff --git a/usr.sbin/smtpd/filter.h b/usr.sbin/smtpd/filter.h
index 4a83d4f724d..8ce989c319f 100644
--- a/usr.sbin/smtpd/filter.h
+++ b/usr.sbin/smtpd/filter.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: filter.h,v 1.2 2011/08/31 18:56:30 gilles Exp $ */
+/* $OpenBSD: filter.h,v 1.3 2011/09/12 20:47:15 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -32,11 +32,11 @@
#endif
enum filter_type {
- FILTER_HELO,
- FILTER_EHLO,
- FILTER_MAIL,
- FILTER_RCPT,
- FILTER_DATALINE,
+ FILTER_HELO = 0x01,
+ FILTER_EHLO = 0x02,
+ FILTER_MAIL = 0x04,
+ FILTER_RCPT = 0x08,
+ FILTER_DATALINE = 0x10,
};
struct filter_helo {
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 32ba1db59ac..4790e625df0 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.146 2011/09/01 19:56:49 eric Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.147 2011/09/12 20:47:15 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -820,12 +820,16 @@ session_read(struct bufferevent *bev, void *p)
if (strlcpy(ss.u.dataline, line,
sizeof(ss.u.dataline)) >= sizeof(ss.u.dataline))
fatal("session_read: data truncation");
-
- session_imsg(s, PROC_MFA, IMSG_MFA_DATALINE,
- 0, 0, -1, &ss, sizeof(ss));
-
free(line);
+ if (env->filtermask & FILTER_DATALINE)
+ session_imsg(s, PROC_MFA, IMSG_MFA_DATALINE,
+ 0, 0, -1, &ss, sizeof(ss));
+ else {
+ log_debug("no filter");
+ ss.code = 250;
+ session_pickup(s, &ss);
+ }
return;
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index bf5ea9d062f..e8a67239006 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.237 2011/09/01 19:56:49 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.238 2011/09/12 20:47:15 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -648,6 +648,7 @@ struct smtpd {
LIST_HEAD(mdalist, mda_session) mda_sessions;
struct stats *stats;
+ u_int64_t filtermask;
};
enum {