--- Begin Message ---
Gilles Chehade <[email protected]> wrote:
> On Wed, Dec 05, 2018 at 04:53:20AM +0000, [email protected] wrote:
> > Gilles Chehade <[email protected]> wrote:
> > [...]
> > > > ascii_load_bounce_type(enum bounce_type *dest, char *buf)
> > > > {
> > > > if (strcasecmp(buf, "error") == 0)
> > > > - *dest = B_ERROR;
> > > > + *dest = B_FAILED;
> > > > else if (strcasecmp(buf, "warn") == 0)
> > > > - *dest = B_WARNING;
> > > > + *dest = B_DELAYED;
> > > > else if (strcasecmp(buf, "dsn") == 0)
> > > > - *dest = B_DSN;
> > > > + *dest = B_DELIVERED;
> > >
> > >
> > > the strcasecmp are not correct here
> > >
> > >
> > > > else
> > > > return 0;
> > > > return 1;
> > > > @@ -574,13 +574,13 @@ ascii_dump_bounce_type(enum bounce_type
> > > > char *p = NULL;
> > > >
> > > > switch (type) {
> > > > - case B_ERROR:
> > > > + case B_FAILED:
> > > > p = "error";
> > > > break;
> > > > - case B_WARNING:
> > > > + case B_DELAYED:
> > > > p = "warn";
> > > > break;
> > > > - case B_DSN:
> > > > + case B_DELIVERED:
> > > > p = "dsn";
> > > > break;
> > >
> > > the dumped strings are not correct here
> >
> > Wouldn't that require a bump to SMTPD_ENVELOPE_VERSION?
>
> not necessarily
>
> what you can do is have the load function recognize both strings but have
> the dump function only emit new strings. this way you have a transitional
> phase that we can retain until 6.6, and SMTPD_ENVELOPE_VERSION won't need
> a bump because we can safely assume that no one will have bounce envelope
> temp failing for over six months.
Sure, updated diff...
Index: bounce.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v
retrieving revision 1.79
diff -u -p -r1.79 bounce.c
--- bounce.c 31 May 2018 21:06:12 -0000 1.79
+++ bounce.c 4 Dec 2018 13:05:14 -0000
@@ -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 ("");
Index: envelope.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/envelope.c,v
retrieving revision 1.39
diff -u -p -r1.39 envelope.c
--- envelope.c 29 May 2018 19:48:19 -0000 1.39
+++ envelope.c 6 Dec 2018 03:58:58 -0000
@@ -344,12 +344,14 @@ ascii_load_flags(enum envelope_flags *de
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
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, cons
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);
}
Index: queue.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/queue.c,v
retrieving revision 1.187
diff -u -p -r1.187 queue.c
--- queue.c 31 May 2018 21:06:12 -0000 1.187
+++ queue.c 4 Dec 2018 13:05:14 -0000
@@ -210,7 +210,7 @@ queue_imsg(struct mproc *p, struct 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
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
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
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);
Index: scheduler.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/scheduler.c,v
retrieving revision 1.58
diff -u -p -r1.58 scheduler.c
--- scheduler.c 31 May 2018 21:06:12 -0000 1.58
+++ scheduler.c 4 Dec 2018 13:04:53 -0000
@@ -214,7 +214,7 @@ scheduler_imsg(struct mproc *p, struct i
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,
Index: smtpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpd.h,v
retrieving revision 1.575
diff -u -p -r1.575 smtpd.h
--- smtpd.h 30 Nov 2018 15:33:40 -0000 1.575
+++ smtpd.h 4 Dec 2018 13:05:14 -0000
@@ -374,9 +374,9 @@ struct table_backend {
enum bounce_type {
- B_ERROR,
- B_WARNING,
- B_DSN
+ B_FAILED,
+ B_DELAYED,
+ B_DELIVERED
};
enum dsn_ret {
--- End Message ---