Implement filter_prepend_home option.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 27 Jun 2006 14:34:26 +0000 (14:34 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 27 Jun 2006 14:34:26 +0000 (14:34 +0000)
12 files changed:
doc/doc-txt/ChangeLog
doc/doc-txt/NewStuff
doc/doc-txt/OptionLists.txt
src/ACKNOWLEDGMENTS
src/src/filter.c
src/src/macros.h
src/src/routers/redirect.c
test/aux-fixed/0037.f-7 [new file with mode: 0644]
test/confs/0037
test/scripts/0000-Basic/0037
test/stderr/0037
test/stdout/0037

index 2f96604ba941f7dd993d6c83d4e493f326fa52bf..08c60a8c305d73093ba4cbe1a9fc86435f2fca92 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.358 2006/06/27 14:04:29 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.359 2006/06/27 14:34:26 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -41,6 +41,8 @@ PH/01 Added #define LDAP_DEPRECATED 1 to ldap.c because some of the "old"
 
 PH/02 Add the verb name to the "unknown ACL verb" error.
 
+PH/03 Magnus Holmgren's patch for filter_prepend_home.
+
 
 Exim version 4.62
 -----------------
index 264501b01f6f5ec667ce6caeb8fb47eacfa55cd9..6fa8b4b8358d42ea49627cd4936403641dc4238f 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.102 2006/04/27 08:53:24 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.103 2006/06/27 14:34:26 ph10 Exp $
 
 New Features in Exim
 --------------------
@@ -8,6 +8,16 @@ but have not yet made it into the main manual (which is most conveniently
 updated when there is a relatively large batch of changes). The doc/ChangeLog
 file contains a listing of all changes, including bug fixes.
 
+Version 4.63
+------------
+
+1. There is a new Boolean option called filter_prepend_home for the redirect
+   router. It defaults true, for backward compatibility. If a "save" command in
+   an Exim filter has a relative path for its argument, and $home is defined,
+   it is automatically prepended to the relative path. This action can now be
+   prevented by setting filter_prepend_home false.
+
+
 Version 4.62
 ------------
 
index 80be8a7b816a598cf946d5c66b345bc5b282582d..07d05c99db05a499e1901527aa01de896817d601 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.20 2006/04/27 08:53:24 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.21 2006/06/27 14:34:26 ph10 Exp $
 
 LISTS OF EXIM OPTIONS
 ---------------------
@@ -11,7 +11,7 @@ This file contains complete lists of four kinds of Exim option:
   4. Those that can appear in the build time configuration for the Exim monitor
      (Local/eximon.conf).
 
-This file was last updated for Exim release 4.62.
+This file was last updated for Exim release 4.63.
 
 
 1. RUN TIME OPTIONS
@@ -204,6 +204,7 @@ file_format                          string          unset         appendfile
 file_must_exist                      boolean         false         appendfile
 file_optional                        boolean         false         autoreply
 file_transport                       string*         unset         redirect          4.00
+filter_prepend_home                  boolean         true          redirect          4.63
 final_timeout                        time            10m           smtp
 finduser_retries                     integer         0             main
 forbid_blackhole                     boolean         false         redirect          4.00
index ce4bf787c5b07e05d4bc867cba743c5d57b6b623..8eb06f40260d1d4d897db8fbd77550dfb2f37ff4 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.46 2006/06/07 15:06:26 fanf2 Exp $
+$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.47 2006/06/27 14:34:26 ph10 Exp $
 
 EXIM ACKNOWLEDGEMENTS
 
@@ -20,7 +20,7 @@ relatively small patches.
 Philip Hazel
 
 Lists created: 20 November 2002
-Last updated:  04 April 2006
+Last updated:  27 June 2006
 
 
 THE OLD LIST
@@ -157,6 +157,7 @@ Steve Haslam              Lots of stuff, including
 Sheldon Hearn             Suggested patch for smtp_accept_max_nonmail_hosts
 Bryan Henderson           Patch to use RM_COMMAND everywhere during building
 Jakob Hirsch              Patch for % operator
+Magnus Holmgren           Patch for filter_prepend_home
 Kjetil Torgrim Homme      Patch for require_files problem on NFS file systems
 Tom Hughes                Suggested patch for $n bug in pipe command from filter
 Pierre Humblet            Continued Cygwin support
index e94cbd135b4b46171f590f6f1b36e7b32a218098..a924defa2d055773b97ef23c8a1e61ce875fef65 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/filter.c,v 1.9 2006/02/07 11:19:00 ph10 Exp $ */
+/* $Cambridge: exim/src/src/filter.c,v 1.10 2006/06/27 14:34:26 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1834,11 +1834,12 @@ while (commands != NULL)
 
     else
       {
+      if (s[0] != '/' && (filter_options & RDO_PREPEND_HOME) != 0 &&
+          deliver_home != NULL && deliver_home[0] != 0)
+        s = string_sprintf("%s/%s", deliver_home, s);
       DEBUG(D_filter) debug_printf("Filter: %ssave message to: %s%s\n",
         (commands->seen)? "" : "unseen ", s,
         commands->noerror? " (noerror)" : "");
-      if (s[0] != '/' && deliver_home != NULL && deliver_home[0] != 0)
-        s = string_sprintf("%s/%s", deliver_home, s);
 
       /* Create the new address and add it to the chain, setting the
       af_pfr and af_file flags, the af_ignore_error flag if necessary, and the
index 7de0c4bfce46e623b08bc5148fa09d3b599a9789..17337089d343781a5d750710d343793b8ae28537 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/macros.h,v 1.24 2006/03/09 15:10:16 ph10 Exp $ */
+/* $Cambridge: exim/src/src/macros.h,v 1.25 2006/06/27 14:34:26 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -508,6 +508,7 @@ router, which were chosen to represent the standard situation for users'
 #define RDO_REWRITE      0x00020000  /* Rewrite generated addresses */
 #define RDO_EXIM_FILTER  0x00040000  /* Forbid Exim filters */
 #define RDO_SIEVE_FILTER 0x00080000  /* Forbid Sieve filters */
+#define RDO_PREPEND_HOME 0x00100000  /* Prepend $home to relative paths in Exim filter save commands */
 
 /* This is the set that apply to expansions in filters */
 
@@ -521,7 +522,7 @@ automated, but I haven't bothered. Keep this list in step with the above! */
 enum { RDON_BLACKHOLE, RDON_DEFER, RDON_EACCES, RDON_ENOTDIR, RDON_EXISTS,
   RDON_FAIL, RDON_FILTER, RDON_FREEZE, RDON_INCLUDE, RDON_LOG, RDON_LOOKUP,
   RDON_PERL, RDON_READFILE, RDON_READSOCK, RDON_RUN, RDON_DLFUNC, RDON_REALLOG,
-  RDON_REWRITE, RDON_EXIM_FILTER, RDON_SIEVE_FILTER };
+  RDON_REWRITE, RDON_EXIM_FILTER, RDON_SIEVE_FILTER, RDON_PREPEND_HOME };
 
 /* Results of filter or forward file processing. Some are only from a filter;
 some are only from a forward file. */
index c2e2a21fe061212a0fb160d264851a8142a9f426..d94240ebc447c37db161e104e005129fb0932922 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/routers/redirect.c,v 1.15 2006/02/07 11:19:02 ph10 Exp $ */
+/* $Cambridge: exim/src/src/routers/redirect.c,v 1.16 2006/06/27 14:34:26 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -39,6 +39,8 @@ optionlist redirect_router_options[] = {
       (void *)offsetof(redirect_router_options_block, file) },
   { "file_transport",     opt_stringptr,
       (void *)offsetof(redirect_router_options_block, file_transport_name) },
+  { "filter_prepend_home",opt_bit | (RDON_PREPEND_HOME << 16),
+      (void *)offsetof(redirect_router_options_block, bit_options) },
   { "forbid_blackhole",   opt_bit | (RDON_BLACKHOLE << 16),
       (void *)offsetof(redirect_router_options_block, bit_options) },
   { "forbid_exim_filter", opt_bit | (RDON_EXIM_FILTER << 16),
@@ -160,7 +162,7 @@ redirect_router_options_block redirect_router_option_defaults = {
   NULL,        /* srs_dbselect */
 #endif
   022,         /* modemask */
-  RDO_REWRITE, /* bit_options */
+  RDO_REWRITE | RDO_PREPEND_HOME, /* bit_options */
   FALSE,       /* check_ancestor */
   TRUE_UNSET,  /* check_owner */
   TRUE_UNSET,  /* check_group */
diff --git a/test/aux-fixed/0037.f-7 b/test/aux-fixed/0037.f-7
new file mode 100644 (file)
index 0000000..01d6c6d
--- /dev/null
@@ -0,0 +1,3 @@
+#exim filter
+
+save relative
index 522694aab5fbd9b39a0e39494f8702b846e6b11b..ad855ec1ab50fe6ba93e222d807169ff602afced 100644 (file)
@@ -1,5 +1,7 @@
 # Exim test configuration 0037
 
+FILTER_PREPEND_HOME=
+
 exim_path = EXIM_PATH
 host_lookup_order = bydns
 rfc1413_query_timeout = 0s
@@ -39,6 +41,16 @@ fail_read_filter:
   file = DIR/aux-var/TESTNUM.f-readfile
   user = CALLER
 
+prepend_filter:
+  driver = redirect
+  local_parts = prepend
+  allow_filter
+  router_home_directory = /usr
+  file = DIR/aux-fixed/TESTNUM.f-7
+  file_transport = appendfile
+  user = CALLER
+  FILTER_PREPEND_HOME
+
 userfilter:
   driver = redirect
   allow_filter
index be3aa94cd50b2cb21696ae854f4b1deab1e5b975..5737c724bee5cadd0404484cdc8850d53d64af5b 100644 (file)
@@ -171,4 +171,10 @@ Subject: should give rise to vacation message
 exim -odi filter-stat
 Subject: should give filter error (7)
 ****
+# Check prepend $home
+exim -bt prepend@test.ex
+****
+# Check not prepend $home
+exim -DFILTER_PREPEND_HOME=no_filter_prepend_home -bt prepend@test.ex
+****
 no_msglog_check
index 16887887348203117a69cec04decaddd49b75853..208cda9fba03adcaa3501d05237adcbc22c16da0 100644 (file)
@@ -29,6 +29,10 @@ check_vars router skipped: local_parts mismatch
 local_part=filter-userx domain=test.ex
 checking local_parts
 fail_read_filter router skipped: local_parts mismatch
+--------> prepend_filter router <--------
+local_part=filter-userx domain=test.ex
+checking local_parts
+prepend_filter router skipped: local_parts mismatch
 --------> userfilter router <--------
 local_part=filter-userx domain=test.ex
 checking local_parts
@@ -62,6 +66,10 @@ check_vars router skipped: local_parts mismatch
 local_part=userx domain=test.ex
 checking local_parts
 fail_read_filter router skipped: local_parts mismatch
+--------> prepend_filter router <--------
+local_part=userx domain=test.ex
+checking local_parts
+prepend_filter router skipped: local_parts mismatch
 --------> userfilter router <--------
 local_part=userx domain=test.ex
 checking local_parts
index a6643e466c2dad52b1439123c99616ff73e80ec6..47139ffda69415c8c3e7a87d3c171671d3e86c0f 100644 (file)
@@ -257,3 +257,7 @@ Headers remove "remove-this"
 Unseen deliver message to: userz@test.ex errors_to abcd@test.ex
 Filtering did not set up a significant delivery.
 Normal delivery will occur.
+prepend@test.ex -> /usr/relative
+  transport = appendfile
+prepend@test.ex -> relative
+  transport = appendfile