summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsunil <sunil@openbsd.org>2018-12-08 08:01:15 +0000
committersunil <sunil@openbsd.org>2018-12-08 08:01:15 +0000
commit5ed42fc8f61a038edcc3d40e291097db35deea4f (patch)
treece52119f7f508f816baec740df423368bec011a3
parentformat a pair of dashes as "\(em" rather than "--", (diff)
downloadwireguard-openbsd-5ed42fc8f61a038edcc3d40e291097db35deea4f.tar.xz
wireguard-openbsd-5ed42fc8f61a038edcc3d40e291097db35deea4f.zip
Use correct RFC 3464 specified values for Action field in a DSN.
error -> failed success -> delivered This fixes DSN parsing for Mailman. Issue reported by Cristiano Costa on misc@opensmtpd.org. While here, rename enums to reflect the intent and properly handle envelope ascii load/dump to understand change in the values. Suggestions and ok gilles@
Diffstat (limited to '')
-rw-r--r--usr.sbin/smtpd/bounce.c28
-rw-r--r--usr.sbin/smtpd/envelope.c32
-rw-r--r--usr.sbin/smtpd/queue.c10
-rw-r--r--usr.sbin/smtpd/scheduler.c4
-rw-r--r--usr.sbin/smtpd/smtpd.h8
5 files changed, 42 insertions, 40 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index 7b8ee1575c0..0223998846c 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.79 2018/05/31 21:06:12 gilles Exp $ */
+/* $OpenBSD: bounce.c,v 1.80 2018/12/08 08:01:15 sunil Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@poolp.org>
@@ -150,13 +150,13 @@ bounce_add(uint64_t evpid)
switch (evp.esc_class) {
case ESC_STATUS_OK:
- key.bounce.type = B_DSN;
+ key.bounce.type = B_DELIVERED;
break;
case ESC_STATUS_TEMPFAIL:
- key.bounce.type = B_WARNING;
+ key.bounce.type = B_DELAYED;
break;
default:
- key.bounce.type = B_ERROR;
+ key.bounce.type = B_FAILED;
}
key.bounce.dsn_ret = evp.dsn_ret;
@@ -478,14 +478,14 @@ bounce_next(struct bounce_session *s)
s->boundary, s->smtpname);
switch (s->msg->bounce.type) {
- case B_ERROR:
+ case B_FAILED:
io_xprint(s->io, notice_error);
break;
- case B_WARNING:
+ case B_DELAYED:
io_xprintf(s->io, notice_warning,
bounce_duration(s->msg->bounce.delay));
break;
- case B_DSN:
+ case B_DELIVERED:
io_xprint(s->io, s->msg->bounce.mta_without_dsn ?
notice_relay : notice_success);
break;
@@ -498,7 +498,7 @@ bounce_next(struct bounce_session *s)
}
io_xprint(s->io, "\n");
- if (s->msg->bounce.type == B_WARNING)
+ if (s->msg->bounce.type == B_DELAYED)
io_xprintf(s->io, notice_warning2,
bounce_duration(s->msg->bounce.ttl));
@@ -549,7 +549,7 @@ bounce_next(struct bounce_session *s)
if ((len = getline(&line, &sz, s->msgfp)) == -1)
break;
if (len == 1 && line[0] == '\n' && /* end of headers */
- s->msg->bounce.type == B_DSN &&
+ s->msg->bounce.type == B_DELIVERED &&
s->msg->bounce.dsn_ret == DSN_RETHDRS) {
free(line);
fclose(s->msgfp);
@@ -795,15 +795,15 @@ static const char *
action_str(const struct delivery_bounce *b)
{
switch (b->type) {
- case B_ERROR:
- return ("error");
- case B_WARNING:
+ case B_FAILED:
+ return ("failed");
+ case B_DELAYED:
return ("delayed");
- case B_DSN:
+ case B_DELIVERED:
if (b->mta_without_dsn)
return ("relayed");
- return ("success");
+ return ("delivered");
default:
log_warn("warn: bounce: unknown bounce_type");
return ("");
diff --git a/usr.sbin/smtpd/envelope.c b/usr.sbin/smtpd/envelope.c
index 98b51dcbbd3..7b80259dfb7 100644
--- a/usr.sbin/smtpd/envelope.c
+++ b/usr.sbin/smtpd/envelope.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: envelope.c,v 1.39 2018/05/29 19:48:19 eric Exp $ */
+/* $OpenBSD: envelope.c,v 1.40 2018/12/08 08:01:15 sunil Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -344,12 +344,14 @@ ascii_load_flags(enum envelope_flags *dest, char *buf)
static int
ascii_load_bounce_type(enum bounce_type *dest, char *buf)
{
- if (strcasecmp(buf, "error") == 0)
- *dest = B_ERROR;
- else if (strcasecmp(buf, "warn") == 0)
- *dest = B_WARNING;
- else if (strcasecmp(buf, "dsn") == 0)
- *dest = B_DSN;
+ if (strcasecmp(buf, "error") == 0 || strcasecmp(buf, "failed") == 0)
+ *dest = B_FAILED;
+ else if (strcasecmp(buf, "warn") == 0 ||
+ strcasecmp(buf, "delayed") == 0)
+ *dest = B_DELAYED;
+ else if (strcasecmp(buf, "dsn") == 0 ||
+ strcasecmp(buf, "delivered") == 0)
+ *dest = B_DELIVERED;
else
return 0;
return 1;
@@ -574,14 +576,14 @@ ascii_dump_bounce_type(enum bounce_type type, char *dest, size_t len)
char *p = NULL;
switch (type) {
- case B_ERROR:
- p = "error";
+ case B_FAILED:
+ p = "failed";
break;
- case B_WARNING:
- p = "warn";
+ case B_DELAYED:
+ p = "delayed";
break;
- case B_DSN:
- p = "dsn";
+ case B_DELIVERED:
+ p = "delivered";
break;
default:
return 0;
@@ -612,13 +614,13 @@ ascii_dump_field(const char *field, const struct envelope *ep,
return ascii_dump_string(ep->dispatcher, buf, len);
if (strcasecmp(field, "bounce-delay") == 0) {
- if (ep->agent.bounce.type != B_WARNING)
+ if (ep->agent.bounce.type != B_DELAYED)
return (1);
return ascii_dump_time(ep->agent.bounce.delay, buf, len);
}
if (strcasecmp(field, "bounce-ttl") == 0) {
- if (ep->agent.bounce.type != B_WARNING)
+ if (ep->agent.bounce.type != B_DELAYED)
return (1);
return ascii_dump_time(ep->agent.bounce.ttl, buf, len);
}
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index 29f4e70eb24..489069eca03 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.187 2018/05/31 21:06:12 gilles Exp $ */
+/* $OpenBSD: queue.c,v 1.188 2018/12/08 08:01:15 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -210,7 +210,7 @@ queue_imsg(struct mproc *p, struct imsg *imsg)
if (queue_envelope_load(evpid, &evp) == 0)
return;
- bounce.type = B_ERROR;
+ bounce.type = B_FAILED;
envelope_set_errormsg(&evp, "Envelope expired");
envelope_set_esc_class(&evp, ESC_STATUS_TEMPFAIL);
envelope_set_esc_code(&evp, ESC_DELIVERY_TIME_EXPIRED);
@@ -342,7 +342,7 @@ queue_imsg(struct mproc *p, struct imsg *imsg)
return;
}
if (evp.dsn_notify & DSN_SUCCESS) {
- bounce.type = B_DSN;
+ bounce.type = B_DELIVERED;
bounce.dsn_ret = evp.dsn_ret;
envelope_set_esc_class(&evp, ESC_STATUS_OK);
if (imsg->hdr.type == IMSG_MDA_DELIVERY_OK)
@@ -400,7 +400,7 @@ queue_imsg(struct mproc *p, struct imsg *imsg)
m_close(p_scheduler);
return;
}
- bounce.type = B_ERROR;
+ bounce.type = B_FAILED;
envelope_set_errormsg(&evp, "%s", reason);
envelope_set_esc_class(&evp, ESC_STATUS_PERMFAIL);
envelope_set_esc_code(&evp, code);
@@ -427,7 +427,7 @@ queue_imsg(struct mproc *p, struct imsg *imsg)
envelope_set_errormsg(&evp, "%s", "Loop detected");
envelope_set_esc_class(&evp, ESC_STATUS_TEMPFAIL);
envelope_set_esc_code(&evp, ESC_ROUTING_LOOP_DETECTED);
- bounce.type = B_ERROR;
+ bounce.type = B_FAILED;
queue_bounce(&evp, &bounce);
queue_envelope_delete(evp.id);
m_create(p_scheduler, IMSG_QUEUE_DELIVERY_LOOP, 0, 0, -1);
diff --git a/usr.sbin/smtpd/scheduler.c b/usr.sbin/smtpd/scheduler.c
index f8966fd8c49..de21342ee4c 100644
--- a/usr.sbin/smtpd/scheduler.c
+++ b/usr.sbin/smtpd/scheduler.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler.c,v 1.58 2018/05/31 21:06:12 gilles Exp $ */
+/* $OpenBSD: scheduler.c,v 1.59 2018/12/08 08:01:15 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -214,7 +214,7 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg)
si.lastbounce < timestamp) {
req.evpid = evp.id;
req.timestamp = timestamp;
- req.bounce.type = B_WARNING;
+ req.bounce.type = B_DELAYED;
req.bounce.delay = env->sc_bounce_warn[i];
req.bounce.ttl = si.ttl;
m_compose(p, IMSG_SCHED_ENVELOPE_BOUNCE, 0, 0, -1,
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 5f1f9518478..eda1aee11c5 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.581 2018/12/07 08:05:59 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.582 2018/12/08 08:01:15 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -386,9 +386,9 @@ struct table_backend {
enum bounce_type {
- B_ERROR,
- B_WARNING,
- B_DSN
+ B_FAILED,
+ B_DELAYED,
+ B_DELIVERED
};
enum dsn_ret {