X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/c988f1f4faa9f679f79beddf3c14676c5dcb8e28..1d28cc061677bd07d9bed48dd84bd5c590247043:/src/src/routers/rf_get_errors_address.c diff --git a/src/src/routers/rf_get_errors_address.c b/src/src/routers/rf_get_errors_address.c index 08d18709a..f70bdf25e 100644 --- a/src/src/routers/rf_get_errors_address.c +++ b/src/src/routers/rf_get_errors_address.c @@ -1,11 +1,11 @@ -/* $Cambridge: exim/src/src/routers/rf_get_errors_address.c,v 1.3 2005/01/04 10:00:44 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2005 */ +/* Copyright (c) University of Cambridge 1995 - 2018 */ +/* Copyright (c) The Exim Maintainers 2020 */ /* See the file NOTICE for conditions of use and distribution. */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ #include "../exim.h" #include "rf_functions.h" @@ -26,7 +26,7 @@ configuration. Arguments: addr the input address rblock the router instance - verify TRUE when verifying + verify v_none / v_recipient / v_sender / v_expn errors_to point the errors address here Returns: OK if no problem @@ -36,18 +36,18 @@ Returns: OK if no problem int rf_get_errors_address(address_item *addr, router_instance *rblock, - BOOL verify, uschar **errors_to) + int verify, uschar **errors_to) { uschar *s; -*errors_to = addr->p.errors_address; +*errors_to = addr->prop.errors_address; if (rblock->errors_to == NULL) return OK; s = expand_string(rblock->errors_to); if (s == NULL) { - if (expand_string_forcedfail) + if (f.expand_string_forcedfail) { DEBUG(D_route) debug_printf("forced expansion failure - ignoring errors_to\n"); @@ -62,7 +62,7 @@ if (s == NULL) if (*s == 0) { - setflag(addr, af_ignore_error); /* For locally detected errors */ + addr->prop.ignore_error = TRUE; /* For locally detected errors */ *errors_to = US""; /* Return path for SMTP */ return OK; } @@ -75,7 +75,7 @@ of routers by checking the sender address. When testing an address, there may not be a sender address. We also need to save and restore the expansion values associated with an address. */ -if (verify) +if (verify != v_none) { *errors_to = s; DEBUG(D_route) @@ -83,35 +83,48 @@ if (verify) } else { - BOOL save_address_test_mode = address_test_mode; + BOOL save_address_test_mode = f.address_test_mode; int save1 = 0; int i; - uschar ***p; - uschar *address_expansions_save[ADDRESS_EXPANSIONS_COUNT]; + const uschar ***p; + const uschar *address_expansions_save[ADDRESS_EXPANSIONS_COUNT]; address_item *snew = deliver_make_addr(s, FALSE); - if (sender_address != NULL) + if (sender_address) { save1 = sender_address[0]; sender_address[0] = 0; } - for (i = 0, p = address_expansions; *p != NULL;) + for (i = 0, p = address_expansions; *p;) address_expansions_save[i++] = **p++; - address_test_mode = FALSE; + f.address_test_mode = FALSE; + + /* NOTE: the address is verified as a recipient, not a sender. This is + perhaps confusing. It isn't immediately obvious what to do: we want to have + some confidence that we can deliver to the address, in which case it will be + a recipient, but on the other hand, it will be passed on in SMTP deliveries + as a sender. However, I think on balance recipient is right because sender + verification is really about the *incoming* sender of the message. + + If this code is changed, note that you must set vopt_fake_sender instead of + vopt_is_recipient, as otherwise sender_address may be altered because + verify_address() thinks it is dealing with *the* sender of the message. */ DEBUG(D_route|D_verify) debug_printf("------ Verifying errors address %s ------\n", s); - if (verify_address(snew, NULL, vopt_is_recipient | vopt_qualify, -1, -1, -1, - NULL, NULL, NULL) == OK) *errors_to = snew->address; + if (verify_address(snew, NULL, + vopt_is_recipient /* vopt_fake_sender is the alternative */ + | vopt_qualify, -1, -1, -1, NULL, NULL, NULL) == OK) + *errors_to = snew->address; DEBUG(D_route|D_verify) debug_printf("------ End verifying errors address %s ------\n", s); - address_test_mode = save_address_test_mode; - for (i = 0, p = address_expansions; *p != NULL;) + f.address_test_mode = save_address_test_mode; + for (i = 0, p = address_expansions; *p; ) **p++ = address_expansions_save[i++]; - if (sender_address != NULL) sender_address[0] = save1; + if (sender_address) sender_address[0] = save1; } return OK;