Mailing List Archive

Combine hosts/sender_domains in condition?
Hellos, I was trying to write a clause that needs to combine
'sender_domains' and 'hosts' in *OR* condition so I can't put on two
separate lines.

Is only way for this to repeat the full clause, once with sender_domains
and one with hosts?


--
## 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: Combine hosts/sender_domains in condition? [ In reply to ]
On 2021-09-07, MRob via Exim-users <exim-users@exim.org> wrote:
> Hellos, I was trying to write a clause that needs to combine
> 'sender_domains' and 'hosts' in *OR* condition so I can't put on two
> separate lines.
>
> Is only way for this to repeat the full clause, once with sender_domains
> and one with hosts?


if it was an accept or deny rule you could just have another
rule for the other condition

So it must be a require rule

change it to a deny rule and invert both conditions.
De Morgan's theorem.

--
Jasen.

--
## 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: Combine hosts/sender_domains in condition? [ In reply to ]
On 2021-09-08 05:03, Jasen Betts via Exim-users wrote:
> On 2021-09-07, MRob via Exim-users <exim-users@exim.org> wrote:
>> Hellos, I was trying to write a clause that needs to combine
>> 'sender_domains' and 'hosts' in *OR* condition so I can't put on two
>> separate lines.
>>
>> Is only way for this to repeat the full clause, once with
>> sender_domains
>> and one with hosts?
>
>
> if it was an accept or deny rule you could just have another
> rule for the other condition
>
> So it must be a require rule
>
> change it to a deny rule and invert both conditions.
> De Morgan's theorem.

It's a deny rule, but I can't change it to accept because if it doesn't
match I want it to continue to the next clause.

--
## 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: Combine hosts/sender_domains in condition? [ In reply to ]
Le 2021-09-08 06:46, MRob via Exim-users a ?crit :
> On 2021-09-08 05:03, Jasen Betts via Exim-users wrote:
> > On 2021-09-07, MRob via Exim-users <exim-users@exim.org> wrote:
> > > Hellos, I was trying to write a clause that needs to combine
> > > 'sender_domains' and 'hosts' in *OR* condition so I can't put on two
> > > separate lines.
> > >
> > > Is only way for this to repeat the full clause, once with
> > > sender_domains
> > > and one with hosts?
> >
> >
> > if it was an accept or deny rule you could just have another
> > rule for the other condition
> >
> > So it must be a require rule
> >
> > change it to a deny rule and invert both conditions.
> > De Morgan's theorem.
>
> It's a deny rule, but I can't change it to accept because if it doesn't
> match I want it to continue to the next clause.
>
> --
> ## 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/
>
Hi,

I'm not sure this is what you want but I have an "or" condition:

condition = ${if or{\
{match{$mime_content_type}{(?i)executable}}\
{match{$mime_filename}{\N(?i)\.(exe|com|vbs|bat|pif|scr|hta|js|cmd|chm|cpl|jsp|reg|vbe|lnk|dll|sys|btm|dat|msi|prf|vb)$\N}}\
}}
Here I use mime type and filename extension.

--
## 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: Combine hosts/sender_domains in condition? [ In reply to ]
On 2021-09-08 07:02, nb via Exim-users wrote:
> Le 2021-09-08 06:46, MRob via Exim-users a écrit :
>> On 2021-09-08 05:03, Jasen Betts via Exim-users wrote:
>> > On 2021-09-07, MRob via Exim-users <exim-users@exim.org> wrote:
>> > > Hellos, I was trying to write a clause that needs to combine
>> > > 'sender_domains' and 'hosts' in *OR* condition so I can't put on two
>> > > separate lines.
>> > >
>> > > Is only way for this to repeat the full clause, once with
>> > > sender_domains
>> > > and one with hosts?
>> >
>> >
>> > if it was an accept or deny rule you could just have another
>> > rule for the other condition
>> >
>> > So it must be a require rule
>> >
>> > change it to a deny rule and invert both conditions.
>> > De Morgan's theorem.
>>
>> It's a deny rule, but I can't change it to accept because if it
>> doesn't
>> match I want it to continue to the next clause.
>>
>> --
>> ## 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/
>>
> Hi,
>
> I'm not sure this is what you want but I have an "or" condition:
>
> condition = ${if or{\
> {match{$mime_content_type}{(?i)executable}}\
>
> {match{$mime_filename}{\N(?i)\.(exe|com|vbs|bat|pif|scr|hta|js|cmd|chm|cpl|jsp|reg|vbe|lnk|dll|sys|btm|dat|msi|prf|vb)$\N}}\
> }}
> Here I use mime type and filename extension.

I don't think you can put hosts or sender_domains in like that:
${if or{{hosts = ...}{sender_domains = ...}}}

--
## 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: Combine hosts/sender_domains in condition? [ In reply to ]
On 2021-09-08, MRob via Exim-users <exim-users@exim.org> wrote:
> On 2021-09-08 05:03, Jasen Betts via Exim-users wrote:
>> On 2021-09-07, MRob via Exim-users <exim-users@exim.org> wrote:
>>> Hellos, I was trying to write a clause that needs to combine
>>> 'sender_domains' and 'hosts' in *OR* condition so I can't put on two
>>> separate lines.
>>>
>>> Is only way for this to repeat the full clause, once with
>>> sender_domains
>>> and one with hosts?
>>
>>
>> if it was an accept or deny rule you could just have another
>> rule for the other condition
>>
>> So it must be a require rule
>>
>> change it to a deny rule and invert both conditions.
>> De Morgan's theorem.
>
> It's a deny rule, but I can't change it to accept because if it doesn't
> match I want it to continue to the next clause.

make two deny rules.

deny sender_domains = +thing
message = I don't like that domain
deny hosts = +thing
message = I don't like that host

--
Jasen.

--
## 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: Combine hosts/sender_domains in condition? [ In reply to ]
On 08/09/2021 08:31, MRob via Exim-users wrote:
> I don't think you can put hosts or sender_domains in like that:
> ${if or{{hosts = ...}{sender_domains = ...}}}

No, but there are variables with the values you are interested
in, and operators for them, which you can build a condition from.
--
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: Combine hosts/sender_domains in condition? [ In reply to ]
Am 08.09.21 um 09:31 schrieb MRob via Exim-users:
>
>> I'm not sure this is what you want but I have an "or" condition:
>>
>>     condition = ${if or{\
>>       {match{$mime_content_type}{(?i)executable}}\
>>
>> {match{$mime_filename}{\N(?i)\.(exe|com|vbs|bat|pif|scr|hta|js|cmd|chm|cpl|jsp|reg|vbe|lnk|dll|sys|btm|dat|msi|prf|vb)$\N}}\
>>
>>       }}
>> Here I use mime type and filename extension.
>
> I don't think you can put hosts or sender_domains in like that:
> ${if or{{hosts = ...}{sender_domains = ...}}}
>

Ofcourse not, you need to add those checks you need too:

or{
     {COND1}
     {COND2}
}

where COND can be one with FORANY/FORALL:

forany{<a list>}{<a condition>}

These conditions iterate over a list. The first argument is expanded
to form the list. By default, the list separator is a colon, but it
can be changed by the normal method (6.21
<https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_runtime_configuration_file.html#SECTlistsepchange>).
The second argument is interpreted as a condition that is to be
applied to each item in the list in turn. During the interpretation
of the condition, the current list item is placed in a variable
called $item.

*

For forany, interpretation stops if the condition is true for
any item, and the result of the whole condition is true. If the
condition is false for all items in the list, the overall
condition is false.

*

For forall, interpretation stops if the condition is false for
any item, and the result of the whole condition is false. If the
condition is true for all items in the list, the overall
condition is true.

Note that negation of forany means that the condition must be false
for all items for the overall condition to succeed, and negation of
forall means that the condition must be false for at least one item.
In this example, the list separator is changed to a comma:

${if forany{<, $recipients}{match{$item}{^user3@}}{yes}{no}}

that way, you can parse those lists and combine the results in an OR . I
think MATCH or EQ are the compareoperators you need.


Best regards,

Marius


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