Re: OpenSMTPD: Don't return message body in successfull DNS reports

2023-04-20 Thread Todd C . Miller
On Thu, 20 Apr 2023 19:40:49 +0200, Christopher Zimmermann wrote:

> delivery success DSNs include the message body if not explicitely 
> disabled by RET HDRS.
> But according to rfc3461 4.3 the body should _only_ be included for 
> failure DSNs.
>
> To me it seems more sane to not include the whole message, which may 
> well be quite large.

Make sense to me.  OK millert@

 - todd



OpenSMTPD: Don't return message body in successfull DNS reports

2023-04-20 Thread Christopher Zimmermann

Hi,

delivery success DSNs include the message body if not explicitely 
disabled by RET HDRS.
But according to rfc3461 4.3 the body should _only_ be included for 
failure DSNs:


[…] If a DSN contains no indications of delivery failure, only the 
headers of the message should be returned.


The default behaviour when neither RET HDRS nor RET FULL is requested is 
not specified:


If no RET parameter is supplied, the MTA MAY return either the headers 
of the message or the entire message for any DSN containing indication 
of failed deliveries.


To me it seems more sane to not include the whole message, which may 
well be quite large.


Therefore I propose the following change. OK ?


Christopher

Index: bounce.c
===
RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v
retrieving revision 1.87
diff -u -p -r1.87 bounce.c
--- bounce.c8 Feb 2023 08:20:54 -   1.87
+++ bounce.c20 Apr 2023 17:30:58 -
@@ -538,8 +538,8 @@ 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_DELIVERED &&
-   s->msg->bounce.dsn_ret ==  DSN_RETHDRS) {
+   (s->msg->bounce.type != B_FAILED ||
+   s->msg->bounce.dsn_ret != DSN_RETFULL)) {
free(line);
fclose(s->msgfp);
s->msgfp = NULL;