Mailing List Archive

Empty variable expansion in header
Hello list,

I am using this condition for flagging all MS office documents during acl_smtp_mime. Later on I use the redirect driver to move them into a special mailbox based on acl_m_block1.

---
accept
condition = ${if match \
{${lc:$mime_filename}} \
{\N(?i)\.(leotest|doc|docm|docx|dot|dotx|pot|potm|potx|ppam|pps|ppsm|ppsx|ppt|pptm|pptx|xla|xlam|xll|xlm|xls|xlsm|xlsx|xlt|xltm|xltx|accdb|accde|accdr|accdt|mdb|pub|sldm|sldx|vsd|vsdm|vsdx|vss|vssm|vst|vstm|vstx|wbk|wks)$\N} \
{1}{0}}
set acl_m_block1 = $mime_filename
add_header = X-Test-Suspicious: $acl_m_block1
logwrite = LEO: We found an extension ($acl_m_block1) that we dont trust. Setting acl_m_block1 for later processing
---

In the logs the variable acl_m_block1 is expanded as expected.

---
2021-04-01 22:15:27 1lS3ix-0008Rl-IC LEO: We found an extension (test.ppt) that we dont trust. Setting acl_m_block1 for later processing
2021-04-01 22:15:27 1lS3ix-0008Rl-IC LEO: We found an extension (test.leotest) that we dont trust. Setting acl_m_block1 for later processing
2021-04-01 22:15:27 1lS3ix-0008Rl-IC LEO: We found an extension (test.xls) that we dont trust. Setting acl_m_block1 for later processing
---

But in the MUA mailbox one occurrence is always missing in the header.

---
X-Test-Suspicious:
X-Test-Suspicious: test.ppt
X-Test-Suspicious: test.leotest
---

Sending just one suspicious attachment always results in an empty "X-Test-Suspicious:"
What am I doing wrong here?

---
exim -bV
Exim version 4.92 #3 built 18-Mar-2021 08:10:15
uname -a
4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux
---

Thank you in advance and greetings
Leo

--
## 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: Empty variable expansion in header [ In reply to ]
On 01/04/2021 21:55, Leonhardt,Christian via Exim-users wrote:
> ---
> 2021-04-01 22:15:27 1lS3ix-0008Rl-IC LEO: We found an extension (test.ppt) that we dont trust. Setting acl_m_block1 for later processing
> 2021-04-01 22:15:27 1lS3ix-0008Rl-IC LEO: We found an extension (test.leotest) that we dont trust. Setting acl_m_block1 for later processing
> 2021-04-01 22:15:27 1lS3ix-0008Rl-IC LEO: We found an extension (test.xls) that we dont trust. Setting acl_m_block1 for later processing
> ---
>
> But in the MUA mailbox one occurrence is always missing in the header.
>
> ---
> X-Test-Suspicious:
> X-Test-Suspicious: test.ppt
> X-Test-Suspicious: test.leotest
> ---
>
> Sending just one suspicious attachment always results in an empty "X-Test-Suspicious:"
> What am I doing wrong here?

Trying to add the same header multiple times. Per the ACL docs chapter,
section 24:

"Further header lines may be accumulated during the DATA and MIME ACLs,
after which they are added to the message, again with duplicates suppressed".

- so you've probably found a bug too; that deduplication isn't working right.
Please raise a bug for that.

I suggest appending to your variable in the MIME ACL, generating a
list of dodgy file names seen. Then if non-empty in the DATA ACL, add the header
there (once).
--
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: Empty variable expansion in header [ In reply to ]
On 2021-04-02 10:55, Jeremy Harris wrote:
> I suggest appending to your variable in the MIME ACL, generating a
> list of dodgy file names seen.? Then if non-empty in the DATA ACL, add the header
> there (once).

Hi Jeremy,

thank you for pointing me in this direction.
With
---
set acl_m_block1 = $mime_filename $acl_m_block1
---
and a conditional add_header during the DATA ACL it is working now.
---
X-Test-Suspicious: test.xls test.ppt test.leotest
---
Greetings
Leo

--
## 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/