Re: [exim] Exim Config and Space characters Question

Góra strony
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
Dla: Potato Chip
CC: exim-users
Temat: Re: [exim] Exim Config and Space characters Question
On Tue, 14 Feb 2006, Potato Chip wrote:

> Spamcheck:
> # If user exists in /etc/passwd, pass username as argument
> transport_filter = /usr/bin/spamc -x
> ${lookup{$local_part}lsearch{/etc/passwd}{-u $local_part}}
>
> This is the error I get:
>
> Expansion of "${lookup{$local_part}lsearch{/etc/passwd}{-u" from command
> "/usr/bin/spamc -x ${lookup{$local_part}lsearch{/etc/passwd}{-u
> $local_part}}" in transport filter failed: missing } at end of string
>
> Can someone advise me of how to fix this? Thank you very much for the
> help!


This is actually quite tricky. You might think you could use this:

   transport_filter = /usr/bin/spamc -x \
     ${lookup{$local_part}lsearch{/etc/passwd}{-u\x20$local_part}}


but it wouldn't work, because the string "-u whatever" would then be
passed as a single argument to the command, whereas you want two
separate arguments. You have to do this:

   transport_filter = /usr/bin/spamc -x \
     ${lookup{$local_part}lsearch{/etc/passwd}{-u}} \
     ${lookup{$local_part}lsearch{/etc/passwd}{$local_part}}


It's not quite as horrendous as it looks, because the lookup will be
cached. An alternative would be

   transport_filter = /bin/sh -c "/usr/bin/spamc -x \
     ${lookup{$local_part}lsearch{/etc/passwd}{-u $local_part}}"


but that costs you an additional shell process.


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