ph10 2007/03/13 15:32:48 GMT
Modified files:
exim-doc/doc-txt ChangeLog NewStuff OptionLists.txt
exim-src/src macros.h
exim-src/src/routers manualroute.c manualroute.h
rf_lookup_hostlist.c
exim-test/stdout 0536
Added files:
exim-test/confs 0557
exim-test/scripts/0000-Basic 0557
exim-test/stderr 0557
exim-test/stdout 0557
Log:
Add host_find_failed=ignore and host_all_ignored to manualroute.
Revision Changes Path
1.493 +5 -0 exim/exim-doc/doc-txt/ChangeLog
1.145 +7 -0 exim/exim-doc/doc-txt/NewStuff
1.31 +1 -0 exim/exim-doc/doc-txt/OptionLists.txt
1.33 +2 -1 exim/exim-src/src/macros.h
1.6 +65 -12 exim/exim-src/src/routers/manualroute.c
1.6 +2 -0 exim/exim-src/src/routers/manualroute.h
1.9 +7 -0 exim/exim-src/src/routers/rf_lookup_hostlist.c
1.1 +49 -0 exim/exim-test/confs/0557 (new)
1.1 +28 -0 exim/exim-test/scripts/0000-Basic/0557 (new)
1.1 +2 -0 exim/exim-test/stderr/0557 (new)
1.2 +4 -4 exim/exim-test/stdout/0536
1.1 +16 -0 exim/exim-test/stdout/0557 (new)
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.492
retrieving revision 1.493
diff -u -r1.492 -r1.493
--- ChangeLog 13 Mar 2007 11:26:49 -0000 1.492
+++ ChangeLog 13 Mar 2007 15:32:47 -0000 1.493
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.492 2007/03/13 11:26:49 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.493 2007/03/13 15:32:47 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -162,6 +162,11 @@
it was listed as "not completed". Such messages can be identified by the
lack of a "<=" line in the log, and they are now listed as "not
accepted".
+
+PH/38 The host_find_failed option in the manualroute router can now be set
+ to "ignore", to completely ignore a host whose IP address cannot be
+ found. If all hosts are ignored, the behaviour is controlled by the new
+ host_all_ignored option.
Exim version 4.66
Index: NewStuff
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/NewStuff,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -r1.144 -r1.145
--- NewStuff 13 Mar 2007 11:06:48 -0000 1.144
+++ NewStuff 13 Mar 2007 15:32:47 -0000 1.145
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.144 2007/03/13 11:06:48 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.145 2007/03/13 15:32:47 ph10 Exp $
New Features in Exim
--------------------
@@ -393,6 +393,13 @@
19. The exigrep utility now has a -v option, which inverts the matching
condition.
+
+20. The host_find_failed option in the manualroute router can now be set to
+ "ignore". This causes it to completely ignore a host whose IP address
+ cannot be found. If all the hosts in the list are ignored, the behaviour is
+ controlled by the new host_all_ignored option, which takes the same values
+ as host_find_failed, except that it cannot be set to "ignore". Its default
+ is "defer".
Version 4.66
Index: OptionLists.txt
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/OptionLists.txt,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- OptionLists.txt 6 Feb 2007 14:49:13 -0000 1.30
+++ OptionLists.txt 13 Mar 2007 15:32:47 -0000 1.31
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/OptionLists.txt,v 1.30 2007/02/06 14:49:13 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/OptionLists.txt,v 1.31 2007/03/13 15:32:47 ph10 Exp $
LISTS OF EXIM OPTIONS
---------------------
@@ -258,6 +258,7 @@
hide_child_in_errmsg false redirect 4.00
hold_domains domain list unset main 1.70
home_directory string* unset transports 4.00 replaces individual options
+host_all_ignored string "defer" manualroute 4.67
host_find_failed string "freeze" manualroute 4.00
host_lookup host list unset main 3.00
host_lookup_order string list "bydns:byaddr" main 4.30
Index: macros.h
===================================================================
RCS file: /home/cvs/exim/exim-src/src/macros.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- macros.h 6 Feb 2007 11:11:40 -0000 1.32
+++ macros.h 13 Mar 2007 15:32:48 -0000 1.33
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/macros.h,v 1.32 2007/02/06 11:11:40 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/macros.h,v 1.33 2007/03/13 15:32:48 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -754,13 +754,14 @@
#define topt_no_body 0x040 /* Omit body */
#define topt_escape_headers 0x080 /* Apply escape check to headers */
-/* Codes for the host_find_failed option. */
+/* Codes for the host_find_failed and host_all_ignored options. */
#define hff_freeze 0
#define hff_defer 1
#define hff_pass 2
#define hff_decline 3
#define hff_fail 4
+#define hff_ignore 5
/* Router information flags */
Index: manualroute.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/routers/manualroute.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- manualroute.c 8 Jan 2007 10:50:20 -0000 1.5
+++ manualroute.c 13 Mar 2007 15:32:48 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/routers/manualroute.c,v 1.5 2007/01/08 10:50:20 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/routers/manualroute.c,v 1.6 2007/03/13 15:32:48 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -16,6 +16,8 @@
/* Options specific to the manualroute router. */
optionlist manualroute_router_options[] = {
+ { "host_all_ignored", opt_stringptr,
+ (void *)(offsetof(manualroute_router_options_block, host_all_ignored)) },
{ "host_find_failed", opt_stringptr,
(void *)(offsetof(manualroute_router_options_block, host_find_failed)) },
{ "hosts_randomize", opt_bool,
@@ -37,14 +39,30 @@
/* Default private options block for the manualroute router. */
manualroute_router_options_block manualroute_router_option_defaults = {
- hff_freeze, /* host_find_failed code */
+ -1, /* host_all_ignored code (unset) */
+ -1, /* host_find_failed code (unset) */
FALSE, /* hosts_randomize */
+ US"defer", /* host_all_ignored */
US"freeze", /* host_find_failed */
NULL, /* route_data */
NULL /* route_list */
};
+/* Names and values for host_find_failed and host_all_ignored. */
+
+static uschar *hff_names[] = {
+ US"ignore", /* MUST be first - not valid for host_all_ignored */
+ US"decline",
+ US"defer",
+ US"fail",
+ US"freeze",
+ US"pass" };
+
+static int hff_codes[] = { hff_ignore, hff_decline, hff_defer, hff_fail,
+ hff_freeze, hff_pass };
+
+static int hff_count= sizeof(hff_codes)/sizeof(int);
@@ -60,23 +78,34 @@
{
manualroute_router_options_block *ob =
(manualroute_router_options_block *)(rblock->options_block);
+int i;
/* Host_find_failed must be a recognized word */
-if (Ustrcmp(ob->host_find_failed, "freeze") == 0)
- ob->hff_code = hff_freeze;
-else if (Ustrcmp(ob->host_find_failed, "decline") == 0)
- ob->hff_code = hff_decline;
-else if (Ustrcmp(ob->host_find_failed, "defer") == 0)
- ob->hff_code = hff_defer;
-else if (Ustrcmp(ob->host_find_failed, "pass") == 0)
- ob->hff_code = hff_pass;
-else if (Ustrcmp(ob->host_find_failed, "fail") == 0)
- ob->hff_code = hff_fail;
-else
+for (i = 0; i < hff_count; i++)
+ {
+ if (Ustrcmp(ob->host_find_failed, hff_names[i]) == 0)
+ {
+ ob->hff_code = hff_codes[i];
+ break;
+ }
+ }
+if (ob->hff_code < 0)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_FOR, "%s router:\n "
"unrecognized setting for host_find_failed option", rblock->name);
+for (i = 1; i < hff_count; i++) /* NB starts at 1 to skip "ignore" */
+ {
+ if (Ustrcmp(ob->host_all_ignored, hff_names[i]) == 0)
+ {
+ ob->hai_code = hff_codes[i];
+ break;
+ }
+ }
+if (ob->hai_code < 0)
+ log_write(0, LOG_PANIC_DIE|LOG_CONFIG_FOR, "%s router:\n "
+ "unrecognized setting for host_all_ignored option", rblock->name);
+
/* One of route_list or route_data must be specified */
if ((ob->route_list == NULL && ob->route_data == NULL) ||
@@ -400,6 +429,30 @@
rc = rf_lookup_hostlist(rblock, addr, rblock->ignore_target_hosts, lookup_type,
ob->hff_code, addr_new);
if (rc != OK) return rc;
+
+/* 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
+is controlled by host_all_ignored. */
+
+if (addr->host_list == NULL)
+ {
+ int i;
+ DEBUG(D_route) debug_printf("host_find_failed ignored every host\n");
+ if (ob->hai_code == hff_decline) return DECLINE;
+ if (ob->hai_code == hff_pass) return PASS;
+
+ for (i = 0; i < hff_count; i++)
+ if (ob->hai_code == hff_codes[i]) break;
+
+ addr->message = string_sprintf("lookup failed for all hosts in %s router: "
+ "host_find_failed=ignore host_all_ignored=%s", rblock->name, hff_names[i]);
+
+ if (ob->hai_code == hff_defer) return DEFER;
+ if (ob->hai_code == hff_fail) return FAIL;
+
+ addr->special_action = SPECIAL_FREEZE;
+ return DEFER;
+ }
/* Finally, since we have done all the routing here, there must be a transport
defined for these hosts. It will be a remote one, as a local transport is
Index: manualroute.h
===================================================================
RCS file: /home/cvs/exim/exim-src/src/routers/manualroute.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- manualroute.h 8 Jan 2007 10:50:20 -0000 1.5
+++ manualroute.h 13 Mar 2007 15:32:48 -0000 1.6
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/routers/manualroute.h,v 1.5 2007/01/08 10:50:20 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/routers/manualroute.h,v 1.6 2007/03/13 15:32:48 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -12,8 +12,10 @@
/* Structure for the private options. */
typedef struct {
+ int hai_code;
int hff_code;
BOOL hosts_randomize;
+ uschar *host_all_ignored;
uschar *host_find_failed;
uschar *route_data;
uschar *route_list;
Index: rf_lookup_hostlist.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/routers/rf_lookup_hostlist.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- rf_lookup_hostlist.c 8 Jan 2007 10:50:20 -0000 1.8
+++ rf_lookup_hostlist.c 13 Mar 2007 15:32:48 -0000 1.9
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/routers/rf_lookup_hostlist.c,v 1.8 2007/01/08 10:50:20 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/routers/rf_lookup_hostlist.c,v 1.9 2007/03/13 15:32:48 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -157,6 +157,13 @@
if (rc == HOST_FIND_FAILED)
{
+ if (hff_code == hff_ignore)
+ {
+ if (prev == NULL) addr->host_list = next_h; else prev->next = next_h;
+ h = prev; /* Because the loop sets prev to h */
+ continue; /* With the next host */
+ }
+
if (hff_code == hff_pass) return PASS;
if (hff_code == hff_decline) return DECLINE;
Index: 0557
====================================================================
# Exim test configuration 0557
X=
Y=
HOSTS=
HAI=
exim_path = EXIM_PATH
host_lookup_order = bydns
primary_hostname = myhost.test.ex
rfc1413_query_timeout = 0s
spool_directory = DIR/spool
log_file_path = DIR/spool/log/%slog
gecos_pattern = ""
gecos_name = CALLER_NAME
# ----- Main settings -----
# ----- Routers -----
begin routers
r1:
driver = manualroute
route_list = * HOSTS
X host_find_failed = ignore
Y host_all_ignored = HAI
no_more
self = send
transport = t1
r2:
driver = accept
transport = t2
# ----- Transports -----
begin transports
t1:
driver = smtp
t2:
driver = appendfile
file = /dev/null
# End
Index: 0557
====================================================================
# host_find_failed=ignore
1
exim -DX=# -DY=# -bt userx@???
****
1
exim -DY=# -DHOSTS=a.non.exist -bt userx@???
****
1
exim -DY=# -DHOSTS=a.non.exist:b.non.exist -bt userx@???
****
exim -DY=# -DHOSTS=a.non.exist:127.0.0.1 -bt userx@???
****
exim -DY=# -DHOSTS=127.0.0.1:b.non.exist:127.0.0.2 -bt userx@???
****
1
exim -DHOSTS=a.non.exist -DHAI=defer -bt userx@???
****
2
exim -DHOSTS=a.non.exist -DHAI=decline -bt userx@???
****
2
exim -DHOSTS=a.non.exist -DHAI=fail -bt userx@???
****
exim -DHOSTS=a.non.exist -DHAI=pass -bt userx@???
****
1
exim -DHOSTS=a.non.exist -DHAI=freeze -bt userx@???
****
Index: 0557
====================================================================
LOG: MAIN
error in r1 router: no host(s) specified for domain *
Index: 0557
====================================================================
userx@??? cannot be resolved at this time: error in r1 router: no host(s) specified for domain *
userx@??? cannot be resolved at this time: lookup failed for all hosts in r1 router: host_find_failed=ignore host_all_ignored=defer
userx@??? cannot be resolved at this time: lookup failed for all hosts in r1 router: host_find_failed=ignore host_all_ignored=defer
userx@???
router = r1, transport = t1
host 127.0.0.1 [127.0.0.1]
userx@???
router = r1, transport = t1
host 127.0.0.1 [127.0.0.1]
host 127.0.0.2 [127.0.0.2]
userx@??? cannot be resolved at this time: lookup failed for all hosts in r1 router: host_find_failed=ignore host_all_ignored=defer
userx@??? is undeliverable: Unrouteable address
userx@??? is undeliverable: lookup failed for all hosts in r1 router: host_find_failed=ignore host_all_ignored=fail
userx@???
router = r2, transport = t2
userx@??? cannot be resolved at this time: lookup failed for all hosts in r1 router: host_find_failed=ignore host_all_ignored=freeze
Index: 0536
===================================================================
RCS file: /home/cvs/exim/exim-test/stdout/0536,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 0536 13 Jul 2006 13:53:34 -0000 1.1
+++ 0536 13 Mar 2007 15:32:48 -0000 1.2
@@ -22,10 +22,10 @@
590 Main code
590 5.4.3 Main and extended code
550 Wrong code
-451 Temporary local problem - please try later
-490 Temporary local problem - please try later
-490 4.4.3 Temporary local problem - please try later
-451 Temporary local problem - please try later
+451 No code
+490 Main code
+490 4.4.3 Main and extended code
+451 Wrong code
221 myhost.test.ex closing connection
220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
250-myhost.test.ex Hello CALLER at test.ex