Re: [exim] transport_filter and expansion

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Stian Jordet
CC: exim-users
Subject: Re: [exim] transport_filter and expansion
On Mon, 16 Jan 2006, Stian Jordet wrote:

> I'm trying to achieve this:
>
> transport_filter = '${if eq{$acl_m2}{spam}{/usr/bin/spamc -U /var/run/spamd.sock -u $acl_m1}{/bin/cat}}'
>
> But I get:
>
> 2006-01-16 00:15:11 1EyH2p-0002Fy-E1 == ingvild@???
> <ingvild@???> R=local_user T=maildir_home defer (-24): transport
> filter process failed (127) while writing to
> tmp/1137366911.H620387P9050.buick.jordet.net: unable to execute command
>
> I understand that this is because of the whitespace in the command. I've
> tried every way of escaping I know of, but it seems impossible to have
> both the "${if" and the command escaped correctly.
>
> Is this impossible, or does it only seem so?


Hmm. I see the problem. By adopting the same rules as for pipe commands,
Exim has made it hard to do what you want. If Exim abandoned the
transport filter on an expansion failure, it could be possible directly,
but unfortunately, it does not. The only solution may be to interpose
some intermediate script, but that puts up the resource usage. You could
use a shell:

  transport_filter = /bin/sh -c \
    '${if eq{$acl_m2}{spam}{/usr/bin/spamc -U /var/run/spamd.sock -u $acl_m1}{/bin/cat}}'


Alternatively, do it at a higher level. Have two transports, one with
the transport filter and one without. Then in the router, you can have

  transport = ${if eq{$acl_m2}{spam}{transport_with_filter}\
              {transport_without_filter}}


That might be easiest, and what's more, when you don't need a transport
filter, you don't have the extra expense of running /bin/cat as a null
filter.

-- 
Philip Hazel            University of Cambridge Computing Service
Get the Exim 4 book:    http://www.uit.co.uk/exim-book