* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) The Exim Maintainers 2020 - 2022 */
+/* Copyright (c) The Exim Maintainers 2020 - 2023 */
/* Copyright (c) University of Cambridge 1995 - 2018 */
/* See the file NOTICE for conditions of use and distribution. */
/* SPDX-License-Identifier: GPL-2.0-or-later */
addr->local_part, tp->name);
/* Setting these globals in the subprocess means we need never clear them */
- transport_name = addr->transport->name;
+
+ transport_name = tp->name;
+ if (addr->router) router_name = addr->router->name;
driver_srcfile = tp->srcfile;
driver_srcline = tp->srcline;
host_item *h;
/* Setting these globals in the subprocess means we need never clear them */
- transport_name = addr->transport->name;
+
+ transport_name = tp->name;
+ if (addr->router) router_name = addr->router->name;
driver_srcfile = tp->srcfile;
driver_srcline = tp->srcline;
fprintf(f, "\n "); /* sic (because space follows) */
count = 0;
}
+ else if (count > 254) /* arbitrary limit */
+ {
+ fprintf(f, "[truncated]");
+ do s++; while (*s && !(*s == '\\' && s[1] == '\n'));
+ }
}
}
unsigned cnt;
/* af_pass_message and addr->message set ? print remote host answer */
-if (s)
- {
- DEBUG(D_deliver)
- debug_printf("DSN Diagnostic-Code: addr->message = %s\n", addr->message);
+if (!s)
+ return;
- /* search first ": ". we assume to find the remote-MTA answer there */
- if (!(s = Ustrstr(addr->message, ": ")))
- return; /* not found, bail out */
- s += 2; /* skip ": " */
- cnt = fprintf(f, "Diagnostic-Code: smtp; ");
- }
-/* no message available. do nothing */
-else return;
+DEBUG(D_deliver)
+ debug_printf("DSN Diagnostic-Code: addr->message = %s\n", addr->message);
+
+/* search first ": ". we assume to find the remote-MTA answer there */
+if (!(s = Ustrstr(addr->message, ": ")))
+ return; /* not found, bail out */
+
+s += 2; /* skip ": " */
+cnt = fprintf(f, "Diagnostic-Code: smtp; ");
while (*s)
{
return fp;
}
+
+/* Output the given header and string, converting either
+the sequence "\n" or a real newline into newline plus space.
+If that still takes us past column 78, look for the last space
+and split there too.
+Append a newline if string did not have one.
+Limit to about 1024 chars total. */
+
+static void
+dsn_put_wrapped(FILE * fp, const uschar * header, const uschar * s)
+{
+gstring * g = string_cat(NULL, header);
+
+g = string_cat(g, s);
+gstring_release_unused(g);
+fprintf(fp, "%s\n", wrap_header(string_from_gstring(g), 79, 1023, US" ", 1));
+}
+
+
+
+
/*************************************************
* Send a bounce message *
*************************************************/
if (dsn_envid)
{
/* must be decoded from xtext: see RFC 3461:6.3a */
- uschar *xdec_envid;
+ uschar * xdec_envid;
if (auth_xtextdecode(dsn_envid, &xdec_envid) > 0)
fprintf(fp, "Original-Envelope-ID: %s\n", dsn_envid);
else
fprintf(fp, "Remote-MTA: X-ip; [%s]%s\n", hu->address, p);
}
if ((s = addr->smtp_greeting) && *s)
- fprintf(fp, "X-Remote-MTA-smtp-greeting: X-str; %.900s\n", s);
+ dsn_put_wrapped(fp, US"X-Remote-MTA-smtp-greeting: X-str; ", s);
if ((s = addr->helo_response) && *s)
- fprintf(fp, "X-Remote-MTA-helo-response: X-str; %.900s\n", s);
+ dsn_put_wrapped(fp, US"X-Remote-MTA-helo-response: X-str; ", s);
if ((s = addr->message) && *s)
- fprintf(fp, "X-Exim-Diagnostic: X-str; %.900s\n", s);
+ dsn_put_wrapped(fp, US"X-Exim-Diagnostic: X-str; ", s);
}
#endif
print_dsn_diagnostic_code(addr, fp);
tctx.u.fd = fileno(fp);
tctx.tblock = &tb;
- tctx.options = topt;
+ tctx.options = topt | topt_truncate_headers;
tb.add_headers = dsnnotifyhdr;
/*XXX no checking for failure! buggy! */
fflush(f);
/* header only as required by RFC. only failure DSN needs to honor RET=FULL */
tctx.u.fd = fileno(f);
-tctx.options = topt_add_return_path | topt_no_body;
+tctx.options = topt_add_return_path | topt_truncate_headers | topt_no_body;
transport_filter_argv = NULL; /* Just in case */
return_path = sender_address; /* In case not previously set */
/* Write the original email out */
tctx.u.fd = fd;
- tctx.options = topt_add_return_path | topt_no_body;
+ tctx.options = topt_add_return_path | topt_truncate_headers | topt_no_body;
/*XXX hmm, FALSE(fail) retval ignored.
Could error for any number of reasons, and they are not handled. */
transport_write_message(&tctx, 0);
*/
int
-deliver_message(uschar *id, BOOL forced, BOOL give_up)
+deliver_message(uschar * id, BOOL forced, BOOL give_up)
{
int i, rc;
int final_yield = DELIVER_ATTEMPTED_NORMAL;
if ((deliver_datafile = spool_open_datafile(id)) < 0)
return continue_closedown(); /* yields DELIVER_NOT_ATTEMPTED */
-/* The value of message_size at this point has been set to the data length,
+/* tHe value of message_size at this point has been set to the data length,
plus one for the blank line that notionally precedes the data. */
/* Now read the contents of the header file, which will set up the headers in
if (rc != spool_read_hdrerror)
{
received_time.tv_sec = received_time.tv_usec = 0;
- /*XXX subsec precision?*/
- for (i = 0; i < 6; i++)
+ /*III subsec precision?*/
+ for (i = 0; i < MESSAGE_ID_TIME_LEN; i++)
received_time.tv_sec = received_time.tv_sec * BASE_62 + tab62[id[i] - '0'];
}