diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2010-10-28 21:15:51 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2010-10-28 21:15:51 +0000 |
commit | 312478c402d1c5266d32265b73443a7b981fd641 (patch) | |
tree | 0c489eed3399dbf601e18fddf8818fe154e181ad /usr.sbin | |
parent | 5e30fca37df71f1d578eade942af05b34dbdb781 (diff) |
teach smtpd how to handle per-rule delays for message expiry, this allows
some rules to have a longer expiry delay than the default:
accept for [...] relay expire 8d # will stay 8 days in queue
I added the man page bits so I don't forget but I need to reword it a bit
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/mfa.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/parse.y | 19 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue_shared.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.conf.5 | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 4 |
6 files changed, 34 insertions, 13 deletions
diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c index 984229ddaa1..5b7f1677d21 100644 --- a/usr.sbin/smtpd/mfa.c +++ b/usr.sbin/smtpd/mfa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfa.c,v 1.50 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: mfa.c,v 1.51 2010/10/28 21:15:50 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -274,6 +274,8 @@ mfa_test_rcpt_resume(struct smtpd *env, struct submit_status *ss) { } ss->msg.recipient = ss->u.path; + ss->msg.expire = ss->msg.recipient.rule.r_qexpire; + log_debug("EXPIRE IN %d", ss->msg.expire); imsg_compose_event(env->sc_ievs[PROC_LKA], IMSG_LKA_RCPT, 0, 0, -1, ss, sizeof(*ss)); } diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index c5c6748f8b7..eebf471f02a 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.68 2010/10/18 13:28:00 sthen Exp $ */ +/* $OpenBSD: parse.y,v 1.69 2010/10/28 21:15:50 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -126,7 +126,7 @@ typedef struct { %token <v.string> STRING %token <v.number> NUMBER %type <v.map> map -%type <v.number> quantifier decision port from auth ssl size +%type <v.number> quantifier decision port from auth ssl size expire %type <v.cond> condition %type <v.tv> interval %type <v.object> mapref @@ -269,6 +269,17 @@ tag : TAG STRING { | /* empty */ { $$ = NULL; } ; +expire : EXPIRE STRING { + $$ = delaytonum($2); + if ($$ == -1) { + yyerror("invalid expire delay: %s", $2); + YYERROR; + } + free($2); + } + | /* empty */ { $$ = conf->sc_qexpire; } + ; + main : QUEUE INTERVAL interval { conf->sc_qintval = $3; } @@ -997,7 +1008,7 @@ rule : decision on from { TAILQ_INIT(conditions); - } FOR conditions action tag { + } FOR conditions action tag expire { struct rule *subr; struct cond *cond; @@ -1005,6 +1016,8 @@ rule : decision on from { (void)strlcpy(rule->r_tag, $8, sizeof(rule->r_tag)); free($8); + rule->r_qexpire = $9; + while ((cond = TAILQ_FIRST(conditions)) != NULL) { if ((subr = calloc(1, sizeof(*subr))) == NULL) diff --git a/usr.sbin/smtpd/queue_shared.c b/usr.sbin/smtpd/queue_shared.c index 6f2f6dae9c4..98848bfdaab 100644 --- a/usr.sbin/smtpd/queue_shared.c +++ b/usr.sbin/smtpd/queue_shared.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_shared.c,v 1.31 2010/10/09 22:12:26 gilles Exp $ */ +/* $OpenBSD: queue_shared.c,v 1.32 2010/10/28 21:15:50 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -792,12 +792,13 @@ display_envelope(struct message *envelope, int flags) printf("UNKNOWN"); } - printf("|%s|%s|%s@%s|%s@%s|%d|%u", + printf("|%s|%s|%s@%s|%s@%s|%d|%d|%u", envelope->message_uid, status, envelope->sender.user, envelope->sender.domain, envelope->recipient.user, envelope->recipient.domain, envelope->lasttry, + envelope->expire, envelope->retry); if (envelope->session_errorline[0] != '\0') diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index d66a6c45a05..f02a249b904 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.91 2010/10/09 22:12:26 gilles Exp $ */ +/* $OpenBSD: runner.c,v 1.92 2010/10/28 21:15:50 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -514,9 +514,10 @@ runner_message_schedule(struct message *messagep, time_t tm) return 1; /* Batch has been in the queue for too long and expired */ - if (tm - messagep->creation >= SMTPD_QUEUE_EXPIRY) { - message_set_errormsg(messagep, "message expired after sitting in queue for %d days", - SMTPD_QUEUE_EXPIRY / 60 / 60 / 24); + if (tm - messagep->creation >= messagep->expire) { + message_set_errormsg(messagep, + "message expired after sitting in queue for %d days", + messagep->expire / 60 / 60 / 24); bounce_record_message(messagep); queue_remove_envelope(messagep); return 0; diff --git a/usr.sbin/smtpd/smtpd.conf.5 b/usr.sbin/smtpd/smtpd.conf.5 index 51966105925..adcb3b61821 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.34 2010/09/08 21:40:43 gilles Exp $ +.\" $OpenBSD: smtpd.conf.5,v 1.35 2010/10/28 21:15:50 gilles Exp $ .\" .\" Copyright (c) 2008 Janne Johansson <jj@openbsd.org> .\" Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net> @@ -16,7 +16,7 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .\" -.Dd $Mdocdate: September 8 2010 $ +.Dd $Mdocdate: October 28 2010 $ .Dt SMTPD.CONF 5 .Os .Sh NAME @@ -202,6 +202,8 @@ If an SMTPAUTH session with is desired, use the .Ic enable auth parameter. +.It Ic expire Ar n {s|m|h|d} +Specify how long a message that matched this rule can stay in the queue. .El .It Ic expire Ar n {s|m|h|d} Specify how long a message can stay in the queue. diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index d5bb09e4cd0..3387f927d47 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.195 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.196 2010/10/28 21:15:50 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -340,6 +340,7 @@ struct rule { char *r_user; objid_t r_amap; + time_t r_qexpire; }; enum path_flags { @@ -452,6 +453,7 @@ struct message { time_t creation; time_t lasttry; + time_t expire; u_int8_t retry; enum message_flags flags; enum message_status status; |