From 6ff55e505e209073eacf1f1e49285464df70d6e3 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Fri, 6 Nov 2015 15:55:25 +0000 Subject: [PATCH] Transport: permit an empty string for the transport_filter option. Bug 1714 --- doc/doc-docbook/spec.xfpt | 3 ++ doc/doc-txt/ChangeLog | 3 ++ src/src/transport.c | 5 ++- test/log/0393 | 8 +++-- test/mail/0393.userx | 24 ++++++++++++- test/msglog/0393.10HmaX-0005vi-00 | 2 -- test/paniclog/0393 | 1 - test/runtest | 3 -- test/scripts/0000-Basic/0393 | 5 +-- test/stderr/0393 | 57 ++++++++++++++++++++++++------- 10 files changed, 87 insertions(+), 24 deletions(-) delete mode 100644 test/msglog/0393.10HmaX-0005vi-00 delete mode 100644 test/paniclog/0393 diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index b0b1585fe..af57d9b85 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -20717,6 +20717,9 @@ headers that some sites insist on. This option sets up a filtering (in the Unix shell sense) process for messages at transport time. It should not be confused with mail filtering as set up by individual users or via a system filter. +.new +If unset, or expanding to an empty string, no filtering is done. +.wen When the message is about to be written out, the command specified by &%transport_filter%& is started up in a separate, parallel process, and diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 4e5663fab..2caae227c 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -73,6 +73,9 @@ JH/14 Change header file name for freeradius-client. Relevant if compiling JH/15 Bug 1712: Introduce $prdr_requested flag variable +JH/16 Bug 1714: Permit an empty string as expansion result for transport + option transport_filter, meaning no filtering. + Exim version 4.86 ----------------- diff --git a/src/src/transport.c b/src/src/transport.c index 62cbdc632..e77479b97 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -1213,7 +1213,10 @@ transport_filter_timed_out = FALSE; /* If there is no filter command set up, call the internal function that does the actual work, passing it the incoming fd, and return its result. */ -if (transport_filter_argv == NULL) +if ( !transport_filter_argv + || !*transport_filter_argv + || !**transport_filter_argv + ) return internal_transport_write_message(addr, fd, options, size_limit, add_headers, remove_headers, check_string, escape_string, rewrite_rules, rewrite_existflags); diff --git a/test/log/0393 b/test/log/0393 index dee87e361..7d70439a0 100644 --- a/test/log/0393 +++ b/test/log/0393 @@ -1,5 +1,9 @@ +1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmaX-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 10HmaX-0005vi-00 Completed 1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmaY-0005vi-00 => userx R=r1 T=t1 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed -1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss -1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=r1 T=t1 defer (-24): transport filter process failed (127) while writing to TESTSUITE/test-mail/userx: unable to execute command +1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@test.ex U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmaZ-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed diff --git a/test/mail/0393.userx b/test/mail/0393.userx index ab724c4ef..24ab3d64f 100644 --- a/test/mail/0393.userx +++ b/test/mail/0393.userx @@ -1,3 +1,14 @@ +From CALLER@test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by the.local.host.name with local (Exim x.yz) + (envelope-from ) + id 10HmaX-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Testing with filter + From CALLER@test.ex Tue Mar 02 09:44:33 1999 Received: from CALLER by the.local.host.name with local (Exim x.yz) (envelope-from ) @@ -7,5 +18,16 @@ Message-Id: From: CALLER_NAME Date: Tue, 2 Mar 1999 09:44:33 +0000 -Testing with filter +Testing without filter + +From CALLER@test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by the.local.host.name with local (Exim x.yz) + (envelope-from ) + id 10HmaZ-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: CALLER_NAME +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +Testing with expand-to-empty filter diff --git a/test/msglog/0393.10HmaX-0005vi-00 b/test/msglog/0393.10HmaX-0005vi-00 deleted file mode 100644 index 4586818bc..000000000 --- a/test/msglog/0393.10HmaX-0005vi-00 +++ /dev/null @@ -1,2 +0,0 @@ -1999-03-02 09:44:33 Received from CALLER@test.ex U=CALLER P=local S=sss -1999-03-02 09:44:33 userx@test.ex R=r1 T=t1 defer (-24): transport filter process failed (127) while writing to TESTSUITE/test-mail/userx: unable to execute command diff --git a/test/paniclog/0393 b/test/paniclog/0393 deleted file mode 100644 index 0fee43b5a..000000000 --- a/test/paniclog/0393 +++ /dev/null @@ -1 +0,0 @@ -1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=r1 T=t1 defer (-24): transport filter process failed (127) while writing to TESTSUITE/test-mail/userx: unable to execute command diff --git a/test/runtest b/test/runtest index 7e2dbe8eb..6899caeff 100755 --- a/test/runtest +++ b/test/runtest @@ -1362,9 +1362,6 @@ $munges = 'optional_ocsp' => { 'stderr' => '/127.0.0.1 in hosts_requ(ire|est)_ocsp/' }, - 'no_tpt_filter_epipe' => - { 'stderr' => '/^writing error 32: Broken pipe$/' }, - 'optional_cert_hostnames' => { 'stderr' => '/in tls_verify_cert_hostnames\? no/' }, diff --git a/test/scripts/0000-Basic/0393 b/test/scripts/0000-Basic/0393 index f34154c93..dfd549a05 100644 --- a/test/scripts/0000-Basic/0393 +++ b/test/scripts/0000-Basic/0393 @@ -1,10 +1,11 @@ # empty transport filter # -munge no_tpt_filter_epipe -# exim -d-all+transport -odi userx Testing with filter **** exim -DFILTER= -d-all+transport -odi userx Testing without filter **** +exim -DFILTER='${if={1}{1}{}{}}' -d-all+transport -odi userx +Testing with expand-to-empty filter +**** diff --git a/test/stderr/0393 b/test/stderr/0393 index a7d72dc98..c40aa6f52 100644 --- a/test/stderr/0393 +++ b/test/stderr/0393 @@ -70,18 +70,51 @@ lock file created mailbox TESTSUITE/test-mail/userx is locked writing to file TESTSUITE/test-mail/userx writing data block fd=dddd size=sss timeout=0 -process pppp running as transport filter: write=dddd read=dddd writing data block fd=dddd size=sss timeout=0 -process pppp writing to transport filter -copying from the filter -waiting for filter process -filter process returned 127 -waiting for writing process -end of filtering transport writing: yield=0 -errno=-24 more_errno=dd -appendfile yields 10 with errno=-24 more_errno=dd -t1 transport returned PANIC for userx@test.ex -LOG: MAIN PANIC - == userx@test.ex R=r1 T=t1 defer (-24): transport filter process failed (127) while writing to TESTSUITE/test-mail/userx: unable to execute command +writing data block fd=dddd size=sss timeout=0 +appendfile yields 0 with errno=dd more_errno=dd +t1 transport returned OK for userx@test.ex +LOG: MAIN + => userx R=r1 T=t1 +LOG: MAIN + Completed +>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> +Exim version x.yz .... +configuration file is TESTSUITE/test-config +admin user +LOG: MAIN + <= CALLER@test.ex U=CALLER P=local S=sss +Exim version x.yz .... +configuration file is TESTSUITE/test-config +trusted user +admin user +>>>>>>>>>>>>>>>> Local deliveries >>>>>>>>>>>>>>>> +--------> userx@test.ex <-------- +direct command: + argv[0] = ${if={1}{1}{}{}} +direct command after expansion: + argv[0] = +appendfile transport entered +appendfile: mode=600 notify_comsat=0 quota=0 warning=0 + file=TESTSUITE/test-mail/userx format=unix + message_prefix=From ${if def:return_path{$return_path}{MAILER-DAEMON}} ${tod_bsdinbox}\n + message_suffix=\n + maildir_use_size_file=no + locking by lockfile fcntl +lock name: TESTSUITE/test-mail/userx.lock +hitch name: TESTSUITE/test-mail/userx.lock.test.ex.dddddddd.pppppppp +lock file created +mailbox TESTSUITE/test-mail/userx is locked +writing to file TESTSUITE/test-mail/userx +writing data block fd=dddd size=sss timeout=0 +writing data block fd=dddd size=sss timeout=0 +writing data block fd=dddd size=sss timeout=0 +appendfile yields 0 with errno=dd more_errno=dd +t1 transport returned OK for userx@test.ex +LOG: MAIN + => userx R=r1 T=t1 +LOG: MAIN + Completed >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> -- 2.25.1