[exim-dev] widen_domains etc.

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: Tony Finch
Data:  
Para: exim-dev
Assunto: [exim-dev] widen_domains etc.
I've worked out a possible fix for the widen_domains bug I posted about on
exim-users yesterday. It's rather larger than it might otherwise be
because I've changed the router entry function API such that the verify
parameter is an int (encoding what sort of verification might be taking
place) instead of just a BOOL. I have not tested it yet :-)

When putting together the patch I noticed something odd in
rf_get_errors_address:

  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;
  DEBUG(D_route|D_verify)
    debug_printf("------ End verifying errors address %s ------\n", s);


Shouldn't the errors_to address be verified as a sender address?

Tony.
--
<fanf@???> <dot@???> http://dotat.at/ ${sg{\N${sg{\
N\}{([^N]*)(.)(.)(.*)}{\$1\$3\$2\$1\$3\n\$2\$3\$4\$3\n\$3\$2\$4}}\
\N}{([^N]*)(.)(.)(.*)}{\$1\$3\$2\$1\$3\n\$2\$3\$4\$3\n\$3\$2\$4}}--- route.c    15 Mar 2005 11:37:21 -0000    1.5
+++ route.c    8 Sep 2005 10:32:17 -0000
@@ -1697,8 +1697,8 @@
 
   HDEBUG(D_route) debug_printf("calling %s router\n", r->name);
 
-  yield = (r->info->code)(r, addr, pw, verify != v_none, paddr_local,
-    paddr_remote, addr_new, addr_succeed);
+  yield = (r->info->code)(r, addr, pw, verify, paddr_local, paddr_remote,
+    addr_new, addr_succeed);
 
   if (yield == FAIL)
     {
--- structs.h    24 May 2005 08:15:02 -0000    1.6
+++ structs.h    8 Sep 2005 10:32:17 -0000
@@ -307,7 +307,7 @@
     router_instance *,
     struct address_item *,
     struct passwd *,
-    BOOL,
+    int,
     struct address_item **,
     struct address_item **,
     struct address_item **,
--- routers/accept.c    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/accept.c    8 Sep 2005 10:32:17 -0000
@@ -81,7 +81,7 @@
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
--- routers/accept.h    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/accept.h    8 Sep 2005 10:32:17 -0000
@@ -25,7 +25,7 @@
 /* The main and initialization entry points for the router */
 
 extern int accept_router_entry(router_instance *, address_item *,
-  struct passwd *, BOOL, address_item **, address_item **,
+  struct passwd *, int, address_item **, address_item **,
   address_item **, address_item **);
 
 extern void accept_router_init(router_instance *);
--- routers/dnslookup.c    17 Jun 2005 14:20:48 -0000    1.4
+++ routers/dnslookup.c    8 Sep 2005 10:32:17 -0000
@@ -128,7 +128,7 @@
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
@@ -177,9 +177,19 @@
 be something in the "ch" toplevel domain, but it also might be xxx.ch.xyz.com.
 The choice of pre- or post-widening affects which takes precedence. If ever
 somebody comes up with some kind of requirement for pre-widening, presumably
-with some conditions under which it is done, it can be selected here. */
+with some conditions under which it is done, it can be selected here.
 
-if (ob->widen_domains != NULL)
+The rewrite_headers option only works when routing an address at transport
+time, because the alterations to the headers are not persistent so must be
+worked out immediately before they are used. Sender addresses are only routed
+for verification purposes, not at transport time, so any header changes that
+you might expect as a result of sender domain widening do not occur.
+Therefore we do not perform widening when verifying sender addresses; however,
+widening sender addresses is OK if we do not have to rewrite the headers.
+The suppression of widening for sender addresses is silent because it is the
+normal desirable behaviour. */
+
+if (ob->widen_domains != NULL && (verify != v_sender || !ob->rewrite_headers))
   {
   listptr = ob->widen_domains;
   widen = string_nextinlist(&listptr, &widen_sep, widen_buffer,
--- routers/dnslookup.h    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/dnslookup.h    8 Sep 2005 10:32:17 -0000
@@ -33,7 +33,7 @@
 /* The main and initialization entry points for the router */
 
 extern int dnslookup_router_entry(router_instance *, address_item *,
-  struct passwd *, BOOL, address_item **, address_item **,
+  struct passwd *, int, address_item **, address_item **,
   address_item **, address_item **);
 
 extern void dnslookup_router_init(router_instance *);
--- routers/ipliteral.c    11 Jan 2005 15:51:03 -0000    1.4
+++ routers/ipliteral.c    8 Sep 2005 10:32:17 -0000
@@ -90,7 +90,7 @@
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
--- routers/ipliteral.h    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/ipliteral.h    8 Sep 2005 10:32:17 -0000
@@ -28,7 +28,7 @@
 /* The main and initialization entry points for the router */
 
 extern int ipliteral_router_entry(router_instance *, address_item *,
-  struct passwd *, BOOL, address_item **, address_item **,
+  struct passwd *, int, address_item **, address_item **,
   address_item **, address_item **);
 
 extern void ipliteral_router_init(router_instance *);
--- routers/iplookup.c    27 Jun 2005 14:29:44 -0000    1.3
+++ routers/iplookup.c    8 Sep 2005 10:32:17 -0000
@@ -137,7 +137,7 @@
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
--- routers/iplookup.h    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/iplookup.h    8 Sep 2005 10:32:17 -0000
@@ -35,7 +35,7 @@
 /* The main and initialization entry points for the router */
 
 extern int iplookup_router_entry(router_instance *, address_item *,
-  struct passwd *, BOOL, address_item **, address_item **,
+  struct passwd *, int, address_item **, address_item **,
   address_item **, address_item **);
 
 extern void iplookup_router_init(router_instance *);
--- routers/manualroute.c    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/manualroute.c    8 Sep 2005 10:32:17 -0000
@@ -191,7 +191,7 @@
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
@@ -386,7 +386,7 @@
 
 if (hostlist[0] == 0)
   {
-  if (verify) goto ROUTED;
+  if (verify != v_none) goto ROUTED;
   addr->message = string_sprintf("error in %s router: no host(s) specified "
     "for domain %s", rblock->name, domain);
   log_write(0, LOG_MAIN, "%s", addr->message);
@@ -405,7 +405,7 @@
 defined for these hosts. It will be a remote one, as a local transport is
 dealt with above. However, we don't need one if verifying only. */
 
-if (transport == NULL && !verify)
+if (transport == NULL && verify == v_none)
     {
     log_write(0, LOG_MAIN, "Error in %s router: no transport defined",
       rblock->name);
--- routers/manualroute.h    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/manualroute.h    8 Sep 2005 10:32:17 -0000
@@ -31,7 +31,7 @@
 /* The main and initialization entry points for the router */
 
 extern int manualroute_router_entry(router_instance *, address_item *,
-  struct passwd *, BOOL, address_item **, address_item **,
+  struct passwd *, int, address_item **, address_item **,
   address_item **, address_item **);
 
 extern void manualroute_router_init(router_instance *);
--- routers/queryprogram.c    27 Jun 2005 14:29:44 -0000    1.5
+++ routers/queryprogram.c    8 Sep 2005 10:32:17 -0000
@@ -181,7 +181,7 @@
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
--- routers/queryprogram.h    4 Jan 2005 10:00:44 -0000    1.2
+++ routers/queryprogram.h    8 Sep 2005 10:32:17 -0000
@@ -34,7 +34,7 @@
 /* The main and initialization entry points for the router */
 
 extern int queryprogram_router_entry(router_instance *, address_item *,
-  struct passwd *, BOOL, address_item **, address_item **,
+  struct passwd *, int, address_item **, address_item **,
   address_item **, address_item **);
 
 extern void queryprogram_router_init(router_instance *);
--- routers/redirect.c    27 Jun 2005 15:11:04 -0000    1.13
+++ routers/redirect.c    8 Sep 2005 10:32:17 -0000
@@ -258,7 +258,7 @@
 Arguments:
   rblock               the router control block
   addr                 the address being routed
-  verify               true if verifying
+  verify               v_none / v_recipient / v_sender / v_expn
   addr_prop            point to the propagated block, which is where the
                          new values are to be placed
 
@@ -268,7 +268,7 @@
 
 static int
 sort_errors_and_headers(router_instance *rblock, address_item *addr,
-  BOOL verify, address_item_propagated *addr_prop)
+  int verify, address_item_propagated *addr_prop)
 {
 int frc = rf_get_errors_address(addr, rblock, verify,
   &(addr_prop->errors_address));
@@ -499,7 +499,7 @@
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
@@ -539,7 +539,7 @@
 /* When verifying and testing addresses, the "logwrite" command in filters
 must be bypassed. */
 
-if (!verify && !address_test_mode) options |= RDO_REALLOG;
+if (verify == v_none && !address_test_mode) options |= RDO_REALLOG;
 
 /* Sort out the fixed or dynamic uid/gid. This uid is used (a) for reading the
 file (and interpreting a filter) and (b) for running the transports for
@@ -618,7 +618,8 @@
 
       /* Forward SRS */
       /* No point in actually performing SRS if we are just verifying a recipient */
-      if((srs_action & 1) && !verify && (sender_address ? sender_address[0] != 0 : FALSE))
+      if((srs_action & 1) && verify == v_none
+        && (sender_address ? sender_address[0] != 0 : FALSE))
       {
 
         srs_orig_sender = sender_address;
@@ -803,7 +804,7 @@
   if (!moan_skipped_syntax_errors(
         rblock->name,                           /* For message content */
         eblock,                                 /* Ditto */
-        (verify || address_test_mode)?
+        (verify != v_none || address_test_mode)?
           NULL : ob->syntax_errors_to,          /* Who to mail */
         generated != NULL,                      /* True if not all failed */
         ob->syntax_errors_text))                /* Custom message */
@@ -835,7 +836,7 @@
 
 if (frc == FF_DELIVERED)
   {
-  if (generated == NULL && !verify && !address_test_mode)
+  if (generated == NULL && verify == v_none && !address_test_mode)
     {
     log_write(0, LOG_MAIN, "=> %s <%s> R=%s", discarded, addr->address,
       rblock->name);
--- routers/redirect.h    24 May 2005 08:15:02 -0000    1.5
+++ routers/redirect.h    8 Sep 2005 10:32:17 -0000
@@ -69,7 +69,7 @@
 /* The main and initialization entry points for the router */
 
 extern int redirect_router_entry(router_instance *, address_item *,
-  struct passwd *, BOOL, address_item **, address_item **,
+  struct passwd *, int, address_item **, address_item **,
   address_item **, address_item **);
 
 extern void redirect_router_init(router_instance *);
--- routers/rf_get_errors_address.c    4 Jan 2005 10:00:44 -0000    1.3
+++ routers/rf_get_errors_address.c    8 Sep 2005 10:32:17 -0000
@@ -26,7 +26,7 @@
 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,7 +36,7 @@
 
 int
 rf_get_errors_address(address_item *addr, router_instance *rblock,
-  BOOL verify, uschar **errors_to)
+  int verify, uschar **errors_to)
 {
 uschar *s;
 
@@ -75,7 +75,7 @@
 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)