Mailing List Archive

running an external program on messages data
I am very much afraid that this is a FAQ, and in fact I may have asked
it myself once. Please forgive me, my memory definitely isn't what it
used to be.

What is the recommended/canonical way to run an arbitrary external
process on a mail that is being processed and capture the output of the
process so it can be used for expansion? I know about the following,
but none of it seems to fit:

= the run expansion item; sadly, doesn't get mail on stdin.

- the message_headers_raw, message_body and message_body_end variables.
It would be tricky and error prone just to paste all the pieces back
together to get the whole mail, even if they preserved the data
exactly (they don't).

- the transport_filter facility; modifies mail in place instead of
returning output.

Is there a way to get the file name(s) for the data in the queue? That
would mostly solve my problem.

--
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: running an external program on messages data [ In reply to ]
On 11/11/2018 17:28, Ian Zimmerman via Exim-users wrote:
> What is the recommended/canonical way to run an arbitrary external
> process on a mail that is being processed and capture the output of the
> process so it can be used for expansion?

The malware ACL condition, with your choice of scanner type "sock" or
"cmdline".


> Is there a way to get the file name(s) for the data in the queue? That
> would mostly solve my problem.

If you _really_ must go that way... build them from

$spool_directory and $message_exim_id and -H and -D.
Possibly with $queue_name.

But you're becoming fragile against changes in directory
usage (as exemplified by queue_name) and formats (cf.
spool_files_wireformat). Spoolfiles are not intended to be
a stable interface.

--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: running an external program on messages data [ In reply to ]
On 2018-11-11 17:49, Jeremy Harris wrote:

> > What is the recommended/canonical way to run an arbitrary external
> > process on a mail that is being processed and capture the output of
> > the process so it can be used for expansion?
>
> The malware ACL condition, with your choice of scanner type "sock" or
> "cmdline".

Yea, I thought about that too. Feels like the cleanest solution, but
... it is too early. I need to delay the program until delivery time.

> > Is there a way to get the file name(s) for the data in the queue?
> > That would mostly solve my problem.
>
> If you _really_ must go that way... build them from
>
> $spool_directory and $message_exim_id and -H and -D.
> Possibly with $queue_name.
>
> But you're becoming fragile against changes in directory
> usage (as exemplified by queue_name) and formats (cf.
> spool_files_wireformat). Spoolfiles are not intended to be
> a stable interface.

Understood. Thanks for the help.

> Cheers,
> Jeremy

Ian

--
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: running an external program on messages data [ In reply to ]
On 11/11/2018 18:35, Ian Zimmerman via Exim-users wrote:
> On 2018-11-11 17:49, Jeremy Harris wrote:
>
>>> What is the recommended/canonical way to run an arbitrary external
>>> process on a mail that is being processed and capture the output of
>>> the process so it can be used for expansion?
>>
>> The malware ACL condition, with your choice of scanner type "sock" or
>> "cmdline".
>
> Yea, I thought about that too. Feels like the cleanest solution, but
> ... it is too early. I need to delay the program until delivery time.

That's getting a bit specialised... will the message content remain
unaltered, and you just need to extract and develop something for
use at transport time? Do repeat calls (e.g. thanks to failed
deliveries not matter?

If so, find a transport option that is expanded and that you can
insert a dummy expansion in, that always results in a correct value.
Use a ${acl } expansion, to a custom ACL which makes a malware call.
--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: running an external program on messages data [ In reply to ]
On 2018-11-11 19:22, Jeremy Harris wrote:

> >> The malware ACL condition, with your choice of scanner type "sock"
> >> or "cmdline".
> >
> > Yea, I thought about that too. Feels like the cleanest solution,
> > but ... it is too early. I need to delay the program until delivery
> > time.
>
> That's getting a bit specialised... will the message content remain
> unaltered, and you just need to extract and develop something for
> use at transport time? Do repeat calls (e.g. thanks to failed
> deliveries not matter?
>
> If so, find a transport option that is expanded and that you can
> insert a dummy expansion in, that always results in a correct value.
> Use a ${acl } expansion, to a custom ACL which makes a malware call.

Excellent idea! I think both of your conditions hold, so this should
work out.

--
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/