1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) University of Cambridge 1995 - 2009 */
6 /* See the file NOTICE for conditions of use and distribution. */
10 #include "rf_functions.h"
14 /*************************************************
15 * Decode actions for self reference *
16 *************************************************/
18 /* This function is called from a number of routers on receiving
19 HOST_FOUND_LOCAL when looking up a supposedly remote host. The action is
20 controlled by a generic configuration option called "self" on each router,
23 . freeze: Log the incident, freeze, and return DEFER
25 . defer: Log the incident and return DEFER
27 . fail: Fail the address
29 . send: Carry on with the delivery regardless -
30 this makes sense only if the SMTP
31 listener on this machine is a differently
34 . pass: The router passes; the address
35 gets passed to the next router, overriding
36 the setting of no_more
38 . reroute:<new-domain> Change the domain to the given domain
39 and return REROUTE so it gets passed back
42 . reroute:rewrite:<new-domain> The same, but headers containing the
43 old domain get rewritten.
45 These string values are interpreted earlier on, and passed into this function
46 as the values of "code" and "rewrite".
49 addr the address being routed
50 host the host that is local, with MX set (or -1 if MX not used)
51 code the action to be taken (one of the self_xxx enums)
52 rewrite TRUE if rewriting headers required for REROUTED
53 new new domain to be used for REROUTED
54 addr_new child chain for REROUTEED
56 Returns: DEFER, REROUTED, PASS, FAIL, or OK, according to the value of code.
60 rf_self_action(address_item *addr, host_item *host, int code, BOOL rewrite,
61 uschar *new, address_item **addr_new)
63 uschar *msg = (host->mx >= 0)?
64 US"lowest numbered MX record points to local host" :
65 US"remote host address is the local host";
71 /* If there is no message id, this is happening during an address
72 verification, so give information about the address that is being verified,
73 and where it has come from. Otherwise, during message delivery, the normal
74 logging for the address will be sufficient. */
76 if (message_id[0] == 0)
78 if (sender_fullhost == NULL)
80 log_write(0, LOG_MAIN, "%s: %s (while routing <%s>)", msg,
81 addr->domain, addr->address);
85 log_write(0, LOG_MAIN, "%s: %s (while verifying <%s> from host %s)",
86 msg, addr->domain, addr->address, sender_fullhost);
90 log_write(0, LOG_MAIN, "%s: %s", msg, addr->domain);
93 addr->special_action = SPECIAL_FREEZE;
103 debug_printf("%s: %s", msg, addr->domain);
104 debug_printf(": domain changed to %s\n", new);
106 rf_change_domain(addr, new, rewrite, addr_new);
112 debug_printf("%s: %s", msg, addr->domain);
113 debug_printf(": configured to try delivery anyway\n");
117 case self_pass: /* This is soft failure; pass to next router */
120 debug_printf("%s: %s", msg, addr->domain);
121 debug_printf(": passed to next router (self = pass)\n");
124 addr->self_hostname = string_copy(host->name);
130 debug_printf("%s: %s", msg, addr->domain);
131 debug_printf(": address failed (self = fail)\n");
134 setflag(addr, af_pass_message);
138 return DEFER; /* paranoia */
141 /* End of rf_self_action.c */