From: Philip Hazel Date: Tue, 27 Jun 2006 14:34:26 +0000 (+0000) Subject: Implement filter_prepend_home option. X-Git-Tag: exim-4_63~39 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/4608d6834bf682e578a5d907a2f6b8fb674c07a0?ds=inline;hp=4e167a8cc7dd4a135f23abee763763add28494fd Implement filter_prepend_home option. --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 2f96604ba..08c60a8c3 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -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 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index 264501b01..6fa8b4b83 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -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 ------------ diff --git a/doc/doc-txt/OptionLists.txt b/doc/doc-txt/OptionLists.txt index 80be8a7b8..07d05c99d 100644 --- a/doc/doc-txt/OptionLists.txt +++ b/doc/doc-txt/OptionLists.txt @@ -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 diff --git a/src/ACKNOWLEDGMENTS b/src/ACKNOWLEDGMENTS index ce4bf787c..8eb06f402 100644 --- a/src/ACKNOWLEDGMENTS +++ b/src/ACKNOWLEDGMENTS @@ -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 diff --git a/src/src/filter.c b/src/src/filter.c index e94cbd135..a924defa2 100644 --- a/src/src/filter.c +++ b/src/src/filter.c @@ -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 diff --git a/src/src/macros.h b/src/src/macros.h index 7de0c4bfc..17337089d 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -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. */ diff --git a/src/src/routers/redirect.c b/src/src/routers/redirect.c index c2e2a21fe..d94240ebc 100644 --- a/src/src/routers/redirect.c +++ b/src/src/routers/redirect.c @@ -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 index 000000000..01d6c6db7 --- /dev/null +++ b/test/aux-fixed/0037.f-7 @@ -0,0 +1,3 @@ +#exim filter + +save relative diff --git a/test/confs/0037 b/test/confs/0037 index 522694aab..ad855ec1a 100644 --- a/test/confs/0037 +++ b/test/confs/0037 @@ -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 diff --git a/test/scripts/0000-Basic/0037 b/test/scripts/0000-Basic/0037 index be3aa94cd..5737c724b 100644 --- a/test/scripts/0000-Basic/0037 +++ b/test/scripts/0000-Basic/0037 @@ -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 diff --git a/test/stderr/0037 b/test/stderr/0037 index 168878873..208cda9fb 100644 --- a/test/stderr/0037 +++ b/test/stderr/0037 @@ -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 diff --git a/test/stdout/0037 b/test/stdout/0037 index a6643e466..47139ffda 100644 --- a/test/stdout/0037 +++ b/test/stdout/0037 @@ -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