"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/routers/manualroute.c" between
exim-4.91.tar.xz and exim-4.92.tar.xz

About: Exim is a message transfer agent (MTA).

manualroute.c  (exim-4.91.tar.xz):manualroute.c  (exim-4.92.tar.xz)
skipping to change at line 151 skipping to change at line 151
Returns: FALSE if domain expected and string is empty; Returns: FALSE if domain expected and string is empty;
TRUE otherwise TRUE otherwise
*/ */
static BOOL static BOOL
parse_route_item(const uschar *s, const uschar **domain, const uschar **hostlist , parse_route_item(const uschar *s, const uschar **domain, const uschar **hostlist ,
const uschar **options) const uschar **options)
{ {
while (*s != 0 && isspace(*s)) s++; while (*s != 0 && isspace(*s)) s++;
if (domain != NULL) if (domain)
{ {
if (*s == 0) return FALSE; /* missing data */ if (!*s) return FALSE; /* missing data */
*domain = string_dequote(&s); *domain = string_dequote(&s);
while (*s != 0 && isspace(*s)) s++; while (*s && isspace(*s)) s++;
} }
*hostlist = string_dequote(&s); *hostlist = string_dequote(&s);
while (*s != 0 && isspace(*s)) s++; while (*s && isspace(*s)) s++;
*options = s; *options = s;
return TRUE; return TRUE;
} }
/************************************************* /*************************************************
* Main entry point * * Main entry point *
*************************************************/ *************************************************/
/* The manualroute router provides a manual routing facility (surprise, /* The manualroute router provides a manual routing facility (surprise,
surprise). The data that defines the routing can either be set in route_data surprise). The data that defines the routing can either be set in route_data
skipping to change at line 251 skipping to change at line 251
addr_new = addr_new; /* Keep picky compilers happy */ addr_new = addr_new; /* Keep picky compilers happy */
addr_succeed = addr_succeed; addr_succeed = addr_succeed;
DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n", DEBUG(D_route) debug_printf("%s router called for %s\n domain = %s\n",
rblock->name, addr->address, addr->domain); rblock->name, addr->address, addr->domain);
/* The initialization check ensures that either route_list or route_data is /* The initialization check ensures that either route_list or route_data is
set. */ set. */
if (ob->route_list != NULL) if (ob->route_list)
{ {
int sep = -(';'); /* Default is semicolon */ int sep = -(';'); /* Default is semicolon */
listptr = ob->route_list; listptr = ob->route_list;
while ((route_item = string_nextinlist(&listptr, &sep, NULL, 0)) != NULL) while ((route_item = string_nextinlist(&listptr, &sep, NULL, 0)) != NULL)
{ {
int rc; int rc;
DEBUG(D_route) debug_printf("route_item = %s\n", route_item); DEBUG(D_route) debug_printf("route_item = %s\n", route_item);
if (!parse_route_item(route_item, &domain, &hostlist, &options)) if (!parse_route_item(route_item, &domain, &hostlist, &options))
skipping to change at line 279 skipping to change at line 279
/* If there was a problem doing the check, defer */ /* If there was a problem doing the check, defer */
if (rc == DEFER) if (rc == DEFER)
{ {
addr->message = US"lookup defer in route_list"; addr->message = US"lookup defer in route_list";
return DEFER; return DEFER;
} }
} }
if (route_item == NULL) return DECLINE; /* No pattern in the list matched */ if (!route_item) return DECLINE; /* No pattern in the list matched */
} }
/* Handle a single routing item in route_data. If it expands to an empty /* Handle a single routing item in route_data. If it expands to an empty
string, decline. */ string, decline. */
else else
{ {
route_item = rf_expand_data(addr, ob->route_data, &rc); if (!(route_item = rf_expand_data(addr, ob->route_data, &rc)))
if (route_item == NULL) return rc; return rc;
(void) parse_route_item(route_item, NULL, &hostlist, &options); (void) parse_route_item(route_item, NULL, &hostlist, &options);
if (hostlist[0] == 0) return DECLINE; if (!hostlist[0]) return DECLINE;
} }
/* Expand the hostlist item. It may then pointing to an empty string, or to a /* Expand the hostlist item. It may then pointing to an empty string, or to a
single host or a list of hosts; options is pointing to the rest of the single host or a list of hosts; options is pointing to the rest of the
routelist item, which is either empty or contains various option words. */ routelist item, which is either empty or contains various option words. */
DEBUG(D_route) debug_printf("original list of hosts = \"%s\" options = %s\n", DEBUG(D_route) debug_printf("original list of hosts = '%s' options = '%s'\n",
hostlist, options); hostlist, options);
newhostlist = expand_string_copy(hostlist); newhostlist = expand_string_copy(hostlist);
lookup_value = NULL; /* Finished with */ lookup_value = NULL; /* Finished with */
expand_nmax = -1; expand_nmax = -1;
/* If the expansion was forced to fail, just decline. Otherwise there is a /* If the expansion was forced to fail, just decline. Otherwise there is a
configuration problem. */ configuration problem. */
if (newhostlist == NULL) if (!newhostlist)
{ {
if (expand_string_forcedfail) return DECLINE; if (f.expand_string_forcedfail) return DECLINE;
addr->message = string_sprintf("%s router: failed to expand \"%s\": %s", addr->message = string_sprintf("%s router: failed to expand \"%s\": %s",
rblock->name, hostlist, expand_string_message); rblock->name, hostlist, expand_string_message);
return DEFER; return DEFER;
} }
else hostlist = newhostlist; else hostlist = newhostlist;
DEBUG(D_route) debug_printf("expanded list of hosts = \"%s\" options = %s\n", DEBUG(D_route) debug_printf("expanded list of hosts = '%s' options = '%s'\n",
hostlist, options); hostlist, options);
/* Set default lookup type and scan the options */ /* Set default lookup type and scan the options */
lookup_type = LK_DEFAULT; lookup_type = LK_DEFAULT;
while (*options != 0) while (*options)
{ {
unsigned n; unsigned n;
const uschar *s = options; const uschar *s = options;
while (*options != 0 && !isspace(*options)) options++; while (*options != 0 && !isspace(*options)) options++;
n = options-s; n = options-s;
if (Ustrncmp(s, "randomize", n) == 0) randomize = TRUE; if (Ustrncmp(s, "randomize", n) == 0) randomize = TRUE;
else if (Ustrncmp(s, "no_randomize", n) == 0) randomize = FALSE; else if (Ustrncmp(s, "no_randomize", n) == 0) randomize = FALSE;
else if (Ustrncmp(s, "byname", n) == 0) else if (Ustrncmp(s, "byname", n) == 0)
lookup_type = lookup_type & ~(LK_DEFAULT | LK_BYDNS) | LK_BYNAME; lookup_type = lookup_type & ~(LK_DEFAULT | LK_BYDNS) | LK_BYNAME;
skipping to change at line 370 skipping to change at line 370
options++; options++;
while (*options != 0 && isspace(*options)) options++; while (*options != 0 && isspace(*options)) options++;
} }
} }
/* Set up the errors address, if any. */ /* Set up the errors address, if any. */
rc = rf_get_errors_address(addr, rblock, verify, &addr->prop.errors_address); rc = rf_get_errors_address(addr, rblock, verify, &addr->prop.errors_address);
if (rc != OK) return rc; if (rc != OK) return rc;
/* Set up the additional and removeable headers for this address. */ /* Set up the additional and removable headers for this address. */
rc = rf_get_munge_headers(addr, rblock, &addr->prop.extra_headers, rc = rf_get_munge_headers(addr, rblock, &addr->prop.extra_headers,
&addr->prop.remove_headers); &addr->prop.remove_headers);
if (rc != OK) return rc; if (rc != OK) return rc;
/* If an individual transport is not set, get the transport for this router, if /* If an individual transport is not set, get the transport for this router, if
any. It might be expanded, or it might be unset if this router has verify_only any. It might be expanded, or it might be unset if this router has verify_only
set. */ set. */
if (!individual_transport_set) if (!individual_transport_set)
skipping to change at line 393 skipping to change at line 393
rblock->name, NULL)) rblock->name, NULL))
return DEFER; return DEFER;
transport = rblock->transport; transport = rblock->transport;
} }
/* Deal with the case of a local transport. The host list is passed over as a /* Deal with the case of a local transport. The host list is passed over as a
single text string that ends up in $host. */ single text string that ends up in $host. */
if (transport && transport->info->local) if (transport && transport->info->local)
{ {
if (hostlist[0] != 0) if (hostlist[0])
{ {
host_item *h; host_item *h;
addr->host_list = h = store_get(sizeof(host_item)); addr->host_list = h = store_get(sizeof(host_item));
h->name = string_copy(hostlist); h->name = string_copy(hostlist);
h->address = NULL; h->address = NULL;
h->port = PORT_NONE; h->port = PORT_NONE;
h->mx = MX_NONE; h->mx = MX_NONE;
h->status = hstatus_unknown; h->status = hstatus_unknown;
h->why = hwhy_unknown; h->why = hwhy_unknown;
h->last_try = 0; h->last_try = 0;
skipping to change at line 420 skipping to change at line 420
addr->transport = transport; addr->transport = transport;
return rf_queue_add(addr, addr_local, addr_remote, rblock, pw)? return rf_queue_add(addr, addr_local, addr_remote, rblock, pw)?
OK : DEFER; OK : DEFER;
} }
/* There is either no transport (verify_only) or a remote transport. A host /* There is either no transport (verify_only) or a remote transport. A host
list is mandatory in either case, except when verifying, in which case the list is mandatory in either case, except when verifying, in which case the
address is just accepted. */ address is just accepted. */
if (hostlist[0] == 0) if (!hostlist[0])
{ {
if (verify != v_none) goto ROUTED; if (verify != v_none) goto ROUTED;
addr->message = string_sprintf("error in %s router: no host(s) specified " addr->message = string_sprintf("error in %s router: no host(s) specified "
"for domain %s", rblock->name, addr->domain); "for domain %s", rblock->name, addr->domain);
log_write(0, LOG_MAIN, "%s", addr->message); log_write(0, LOG_MAIN, "%s", addr->message);
return DEFER; return DEFER;
} }
/* Otherwise we finish the routing here by building a chain of host items /* Otherwise we finish the routing here by building a chain of host items
for the list of configured hosts, and then finding their addresses. */ for the list of configured hosts, and then finding their addresses. */
host_build_hostlist(&(addr->host_list), hostlist, randomize); host_build_hostlist(&addr->host_list, hostlist, randomize);
rc = rf_lookup_hostlist(rblock, addr, rblock->ignore_target_hosts, lookup_type, rc = rf_lookup_hostlist(rblock, addr, rblock->ignore_target_hosts, lookup_type,
ob->hff_code, addr_new); ob->hff_code, addr_new);
if (rc != OK) return rc; if (rc != OK) return rc;
/* If host_find_failed is set to "ignore", it is possible for all the hosts to /* If host_find_failed is set to "ignore", it is possible for all the hosts to
be ignored, in which case we will end up with an empty host list. What happens be ignored, in which case we will end up with an empty host list. What happens
is controlled by host_all_ignored. */ is controlled by host_all_ignored. */
if (!addr->host_list) if (!addr->host_list)
{ {
 End of changes. 17 change blocks. 
18 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)