diff options
author | Joerg Jung <jung@cvs.openbsd.org> | 2015-12-03 21:11:34 +0000 |
---|---|---|
committer | Joerg Jung <jung@cvs.openbsd.org> | 2015-12-03 21:11:34 +0000 |
commit | 3389f73d3859bdb82aa4f339dee4f72c34852e88 (patch) | |
tree | 03130587e33fbd5b03d07f084a6d12b14b94864e /usr.sbin/smtpd | |
parent | 17a87593ede0730e4147f4c4d0657206dd1182bb (diff) |
introduce limit session keyword replacing fixed values
original diff from Renaud Allard
ok gilles
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/parse.y | 29 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.conf.5 | 15 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 5 |
4 files changed, 47 insertions, 11 deletions
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index e70db4a4516..bbf1005bc61 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.163 2015/12/02 09:06:36 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.164 2015/12/03 21:11:33 jung Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -167,7 +167,7 @@ typedef struct { %} %token AS QUEUE COMPRESSION ENCRYPTION MAXMESSAGESIZE MAXMTADEFERRED LISTEN ON ANY PORT EXPIRE -%token TABLE SECURE SMTPS CERTIFICATE DOMAIN BOUNCEWARN LIMIT INET4 INET6 NODSN +%token TABLE SECURE SMTPS CERTIFICATE DOMAIN BOUNCEWARN LIMIT INET4 INET6 NODSN SESSION %token RELAY BACKUP VIA DELIVER TO LMTP MAILDIR MBOX RCPTTO HOSTNAME HOSTNAMES %token ACCEPT REJECT INCLUDE ERROR MDA FROM FOR SOURCE MTA PKI SCHEDULER %token ARROW AUTH TLS LOCAL VIRTUAL TAG TAGGED ALIAS FILTER KEY CA DHPARAMS @@ -307,6 +307,26 @@ opt_limit_mda : STRING NUMBER { } ; +limits_session : opt_limit_session limits_session + | /* empty */ + ; + +opt_limit_session : STRING NUMBER { + if (!strcmp($1, "max-rcpt")) { + conf->sc_session_max_rcpt = $2; + } + else if (!strcmp($1, "max-mails")) { + conf->sc_session_max_mails = $2; + } + else { + yyerror("invalid session limit keyword: %s", $1); + free($1); + YYERROR; + } + free($1); + } + ; + limits_mda : opt_limit_mda limits_mda | /* empty */ ; @@ -775,6 +795,7 @@ main : BOUNCEWARN { | MAXMTADEFERRED NUMBER { conf->sc_mta_max_deferred = $2; } + | LIMIT SESSION limits_session | LIMIT MDA limits_mda | LIMIT MTA FOR DOMAIN STRING { struct mta_limits *d; @@ -1404,6 +1425,7 @@ lookup(char *s) { "scheduler", SCHEDULER }, { "secure", SECURE }, { "sender", SENDER }, + { "session", SESSION }, { "smtps", SMTPS }, { "source", SOURCE }, { "table", TABLE }, @@ -1817,6 +1839,9 @@ parse_config(struct smtpd *x_conf, const char *filename, int opts) conf->sc_scheduler_max_schedule = 10; conf->sc_scheduler_max_evp_batch_size = 256; conf->sc_scheduler_max_msg_batch_size = 1024; + + conf->sc_session_max_rcpt = 1000; + conf->sc_session_max_mails = 100; conf->sc_mda_max_session = 50; conf->sc_mda_max_user_session = 7; diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index b54800f52f2..5a45a7e5031 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.241 2015/12/01 18:22:30 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.242 2015/12/03 21:11:33 jung Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -45,9 +45,6 @@ #include "log.h" #include "ssl.h" -#define SMTP_LIMIT_MAIL 100 -#define SMTP_LIMIT_RCPT 1000 - #define APPEND_DOMAIN_BUFFER_SIZE 4096 enum smtp_phase { @@ -1366,7 +1363,7 @@ smtp_command(struct smtp_session *s, char *line) break; } - if (s->mailcount >= SMTP_LIMIT_MAIL) { + if (s->mailcount >= env->sc_session_max_mails) { /* we can pretend we had too many recipients */ smtp_reply(s, "452 %s %s: Too many messages sent", esc_code(ESC_STATUS_TEMPFAIL, ESC_TOO_MANY_RECIPIENTS), @@ -1398,7 +1395,7 @@ smtp_command(struct smtp_session *s, char *line) break; } - if (s->rcptcount >= SMTP_LIMIT_RCPT) { + if (s->rcptcount >= env->sc_session_max_rcpt) { smtp_reply(s, "451 %s %s: Too many recipients", esc_code(ESC_STATUS_TEMPFAIL, ESC_TOO_MANY_RECIPIENTS), esc_description(ESC_TOO_MANY_RECIPIENTS)); diff --git a/usr.sbin/smtpd/smtpd.conf.5 b/usr.sbin/smtpd/smtpd.conf.5 index 1f2dd1e40e9..4efd57ce1b0 100644 --- a/usr.sbin/smtpd/smtpd.conf.5 +++ b/usr.sbin/smtpd/smtpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: smtpd.conf.5,v 1.133 2015/12/01 22:30:00 jmc Exp $ +.\" $OpenBSD: smtpd.conf.5,v 1.134 2015/12/03 21:11:33 jung Exp $ .\" .\" Copyright (c) 2008 Janne Johansson <jj@openbsd.org> .\" Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net> @@ -17,7 +17,7 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .\" -.Dd $Mdocdate: December 1 2015 $ +.Dd $Mdocdate: December 3 2015 $ .Dt SMTPD.CONF 5 .Os .Sh NAME @@ -573,6 +573,17 @@ expire 4d # expire after 4 days expire 10h # expire after 10 hours .Ed .It Xo +.Ic limit session +.Brq Cm max-rcpt | max-mails +.Ar num +.Xc +Instruct +.Xr smtpd 8 +to accept a maximum number of recipients or emails at once in the receiving queue. Defaults are 100 for +.Ic max-mails +and 1000 for +.Ic max-rcpt . +.It Xo .Ic limit mta .Op Ic for Ic domain Ar domain .Ar family diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 697447dfe0f..b37d44e623b 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.492 2015/12/01 18:22:30 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.493 2015/12/03 21:11:33 jung Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -581,6 +581,9 @@ struct smtpd { char *sc_queue_key; size_t sc_queue_evpcache_size; + size_t sc_session_max_rcpt; + size_t sc_session_max_mails; + size_t sc_mda_max_session; size_t sc_mda_max_user_session; size_t sc_mda_task_hiwat; |