[Exim] String expansion headaches

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Greg Ward
Dátum:  
Címzett: exim-users
Tárgy: [Exim] String expansion headaches
Hi all -- I'm trying to streamline the recommended transport for Mailman
2.1 with Exim 4, and I'm having weird problems with string expansion.
Perhaps I just need more eyeballs to look at this.

Context: here's the transport I'm working with:

mm21_transport:
driver = pipe
command = MM21_WRAP [...scary expansion...] $local_part
current_directory = MM21_HOME
home_directory = MM21_HOME
user = MM21_UID
group = MM21_GID

The goal is to pipe messages as follows:

  list-request       -> |mailman request list
  list-bounces       -> |mailman bounces list
  list-bounces+...   -> |mailman bounces list  (... = VERP'd address)
  list               -> |mailman post


I have one version of the 'command' that works, but it's a bit hairier
than it needs to be (this comes from the README.EXIM in Mailman's
current CVS, ie. not the rewrite that I'm working on):

  command = MM21_WRAP \
              "${if def:local_part_suffix\
                    {${substr_2:{${sg{${lc:$local_part_suffix}}{\N\+.*\N}{}}}}\
                    {post}}" \
              ${lc:$local_part}


The main excess hair is that the substr{sg{...}} can be done with a
single regex substitution. Also, I believe it's not necessary to
downcase $local_part or $local_part_suffix, and I don't understand why
the quotes are necessary. Oh yeah, it seems to me like there are
unbalanced braces here -- but like I said, it *works*. Note that \N
works just fine on the regex to avoid exploding backslash syndrome.

So here's my slightly simplified version of this command (left the
quotes in because I don't understand them; braces are still unbalanced):

  command = MM21_WRAP \
             "${if def:local_part_suffix\
                  {${sg{$local_part_suffix}{\N-(\w+)(\+.*)?\N}{\$1}}\
                  {post}}" \
             ${lc:$local_part}


When I try to deliver a message via this transport using my simplified
command, Exim barfs on the regex:

LOG: MAIN PANIC
== newtest@??? <newtest-bounces@???> R=mm21_router T=mm21_transport defer (0): Expansion of "${if def:local_part_suffix{${sg{$local_part_suffix}{N-(w+)(+.*)?N}{$1}}{post}}" from command "/usr/local/mailman/mail/mailman "${if def:local_part_suffix{${sg{$local_part_suffix}{\N-(\w+)(\+.*)?\N}{\$1}}{post}}" ${lc:$local_part}" in mm21_transport transport failed: regular expression error in "N-(w+)(+.*)?N": nothing to repeat at offset 7

If I paste this expression into an "exim -be" session, quoted or
otherwise, Exim does not complain about the regex.

Based on the dim recollection that quoting stuff means you need more
backslashes, I tried it without quotes:

command = MM21_WRAP \
             ${if def:local_part_suffix\
                  {${sg{$local_part_suffix}{\N-(\w+)(\+.*)?\N}{\$1}}\
                  {post}} \
             ${lc:$local_part}


Exim no longer complains about the regex, but now I get this:

LOG: MAIN PANIC
== newtest@??? <newtest-bounces@???> R=mm21_router T=mm21_transport defer (0): Expansion of "${if" from command "/usr/local/mailman/mail/mailman ${if def:local_part_suffix{${sg{$local_part_suffix}{\N-(\w+)(\+.*)?\N}{\$1}}{post}} ${lc:$local_part}" in mm21_transport transport failed: condition name expected, but found ""

So it looks like I need to quote the "${if ...}" expression after all.
But if I paste this into exim -be, again no complaint. Oh yeah, it also
works fine if I put it into a debug_print option.

Here's what's confusing me:

  * why do I need to quote this expression in a transport "command"
    option, but not in "exim -be"?


* why does \N work in the first attempt, but not in the second?

Any clues gratefully accepted --

        Greg
--
Greg Ward - software developer                gward@???
MEMS Exchange                            http://www.mems-exchange.org