From a83a23cbf8a464d34ac2a9b720ec05c388aeeeef Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Thu, 5 Nov 2009 12:05:48 +0000 Subject: Introduce a 6yz status code, used internally to report permanent errors. The 1yz and 6yz status codes are now removed prior to reporting the status message in bounce messages, which provides an easy way to distinguish between local and remote status messages. Initial diff from jacekm@ ok gilles@ jacekm@ --- usr.sbin/smtpd/bounce.c | 10 ++++++++-- usr.sbin/smtpd/dns.c | 2 +- usr.sbin/smtpd/mta.c | 9 ++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index 91c3d67749f..56f8d78d3da 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.9 2009/09/16 15:33:06 jacekm Exp $ */ +/* $OpenBSD: bounce.c,v 1.10 2009/11/05 12:05:47 jsing Exp $ */ /* * Copyright (c) 2009 Gilles Chehade @@ -55,6 +55,7 @@ bounce_session(struct smtpd *env, int fd, struct message *messagep) { struct client_ctx *cc = NULL; int msgfd = -1; + char *reason; /* init smtp session */ if ((cc = calloc(1, sizeof(*cc))) == NULL) @@ -71,6 +72,11 @@ bounce_session(struct smtpd *env, int fd, struct message *messagep) messagep->sender.domain) < 0) goto fail; + /* Construct an appropriate reason line. */ + reason = messagep->session_errorline; + if (strlen(reason) > 4 && (*reason == '1' || *reason == '6')) + reason += 4; + /* create message header */ if (client_data_printf(cc->sp, "Subject: Delivery status notification\n" @@ -91,7 +97,7 @@ bounce_session(struct smtpd *env, int fd, struct message *messagep) env->sc_hostname, messagep->sender.user, messagep->sender.domain, messagep->recipient.user, messagep->recipient.domain, - messagep->session_errorline) < 0) + reason) < 0) goto fail; /* append original message */ diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c index b61346789d6..300b7aa3eb1 100644 --- a/usr.sbin/smtpd/dns.c +++ b/usr.sbin/smtpd/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.16 2009/09/03 08:19:13 jacekm Exp $ */ +/* $OpenBSD: dns.c,v 1.17 2009/11/05 12:05:47 jsing Exp $ */ /* * Copyright (c) 2008 Gilles Chehade diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 11297a869ab..4eb65020a53 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.72 2009/09/15 16:50:06 jacekm Exp $ */ +/* $OpenBSD: mta.c,v 1.73 2009/11/05 12:05:47 jsing Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -659,7 +659,8 @@ mta_enter_state(struct mta_session *s, int newstate, void *p) /* set envelope recipients */ TAILQ_FOREACH(m, &s->recipients, entry) { if (m->session_errorline[0] == '2' || - m->session_errorline[0] == '5') + m->session_errorline[0] == '5' || + m->session_errorline[0] == '6') continue; if (client_rcpt(s->smtp_state, "%s@%s", m->recipient.user, m->recipient.domain) < 0) @@ -683,6 +684,7 @@ mta_enter_state(struct mta_session *s, int newstate, void *p) /* update queue status */ while ((m = TAILQ_FIRST(&s->recipients))) { switch (m->session_errorline[0]) { + case '6': case '5': m->status = S_MESSAGE_PERMFAILURE; break; @@ -902,7 +904,8 @@ mta_todo(struct mta_session *s) TAILQ_FOREACH(m, &s->recipients, entry) if (m->session_errorline[0] != '2' && - m->session_errorline[0] != '5') + m->session_errorline[0] != '5' && + m->session_errorline[0] != '6') n++; return (n); } -- cgit v1.2.3