Re: [exim] Undocumented surprise in ${run ...} processing

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Todd Lyons
Data:  
Para: Chris Siebenmann
CC: exim-users
Asunto: Re: [exim] Undocumented surprise in ${run ...} processing
On Wed, Jul 2, 2014 at 12:01 PM, Chris Siebenmann <cks@???> wrote:
>  Suppose that you have a ${run ...} in a router such as the following:
>         address_data = ${run{/opt/mail/sbin/matchposters.py $return_path /cs/lists/$local_part..posters} {<some IP address>} fail}

>
> Now suppose that this is invoked with the null sender, <>.
> What I expected to happen is that matchposters.py would be invoked
> with two command line arguments; the first would be empty (because
> $return_path is empty due to the null sender) and the second part
> would be the appropriate expansion.
>
> However this is not what happens in Exim 4.76 (Ubuntu 12.04) and Exim
> 4.82 (Ubuntu 14.04). Instead matchposters.py is invoked with only *one*
> command line argument as the empty $return_path is scrubbed out of the
> argument list entirely. As far as I can tell there is no way to stop
> this from happening.


Quote it.

> I don't believe that this is desirable. I feel strongly that command
> line expansions should not vary a command's argument count based on
> whether or not some expansions happen to be empty. At a minimum doing


I tested if I could see what you were seeing. I ran:
sudo exim -d+all -be '${run {/bin/cat $local_part /etc/passwd}}'

It did exactly as I expected:

12:42:35 25840 expanding: /bin/cat $local_part /etc/passwd
12:42:35 25840    result: /bin/cat  /etc/passwd
12:42:35 25840 direct command:
12:42:35 25840   argv[0] = /bin/cat
12:42:35 25840   argv[1] = /etc/passwd
12:42:35 25840 expanding: ${run {/bin/cat $local_part /etc/passwd}}


I think you do the same thing as when you're running it from the shell
to get this positional adherence: quote it:
sudo exim -d+all -be '${run {/bin/cat "$local_part" /etc/passwd}}'

12:44:56 25952 expanding: /bin/cat "$local_part" /etc/passwd
12:44:56 25952    result: /bin/cat "" /etc/passwd
12:44:56 25952 direct command:
12:44:56 25952   argv[0] = /bin/cat
12:44:56 25952   argv[1] =
12:44:56 25952   argv[2] = /etc/passwd
12:44:56 25952 expanding: ${run {/bin/cat "$local_part" /etc/passwd}}


> At a minimum I feel that this should be explicitly documented in
> the ${run} section of the String Expansions chapter of the Exim
> documentation.


I thought it was standard commandline processing. Note that exim does
not start a shell unless you include it in your command. It just
exec's the program with args directly (which is why you don't get any
kind of environment unless you specifically source env files). Are
you saying that normally you do not have to quote args that are empty?
In what? Or are you implying something else that I'm not quite
understanding?

...Todd
--
The total budget at all receivers for solving senders' problems is $0.
If you want them to accept your mail and manage it the way you want,
send it the way the spec says to. --John Levine