Mailing List Archive

Help to logical OR two conditions
Dear Colleagues,

Could you please help me unite the following two ACL expressions into one:

accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}

Should be fairly simple but... I've tried variants of '${if or {...' by
the manual but all I got were errors like

"${or" is not a known operator (or a } is missing in a variable reference)

I'm probably miscounting brackets or something. Could you please suggest
a working tested example of a logical OR between such conditions?

TIA.

--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/
Re: Help to logical OR two conditions [ In reply to ]
Am 01.10.20 um 08:24 schrieb Victor Sudakov via Exim-users:
> Dear Colleagues,
>
> Could you please help me unite the following two ACL expressions into one:
>
> accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
> accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}
>
> Should be fairly simple but... I've tried variants of '${if or {...' by
> the manual but all I got were errors like
>
> "${or" is not a known operator (or a } is missing in a variable reference)
>
> I'm probably miscounting brackets or something. Could you please suggest
> a working tested example of a logical OR between such conditions?
>

accept? condition? = ${if or{\
?????????????????????????????? { and{ {CONDITION 1}{CONDITION 2} }}\
?????????????????????????????? { CONDITION 3 }\
????????????????????????????? } {1}}

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/
Re: Help to logical OR two conditions [ In reply to ]
Cyborg via Exim-users wrote:
> Am 01.10.20 um 08:24 schrieb Victor Sudakov via Exim-users:
> > Dear Colleagues,
> >
> > Could you please help me unite the following two ACL expressions into one:
> >
> > accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
> > accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}
> >
> > Should be fairly simple but... I've tried variants of '${if or {...' by
> > the manual but all I got were errors like
> >
> > "${or" is not a known operator (or a } is missing in a variable reference)
> >
> > I'm probably miscounting brackets or something. Could you please suggest
> > a working tested example of a logical OR between such conditions?
> >
>
> accept? condition? = ${if or{\
> ?????????????????????????????? { and{ {CONDITION 1}{CONDITION 2} }}\
> ?????????????????????????????? { CONDITION 3 }\
> ????????????????????????????? } {1}}

So, for my case it should look like this, right )(copied verbatim from my test config):

accept condition = ${if or{\
${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} \
${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} \
} {yes}}


Does not work however:
failed to expand ACL string "${if or{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} } {yes}}": each subcondition inside an "or{...}" condition must be in its own {}


What am I doing wrong?

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

--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/
Re: Help to logical OR two conditions [ In reply to ]
Am 01.10.20 um 09:59 schrieb Victor Sudakov via Exim-users:
>
>> accept? condition? = ${if or{\
>> ?????????????????????????????? { and{ {CONDITION 1}{CONDITION 2} }}\
>> ?????????????????????????????? { CONDITION 3 }\
>> ????????????????????????????? } {1}}
> So, for my case it should look like this, right )(copied verbatim from my test config):
>
> accept condition = ${if or{\
> ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} \
> ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} \
> } {yes}}
>
>
> Does not work however:
> failed to expand ACL string "${if or{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} } {yes}}": each subcondition inside an "or{...}" condition must be in its own {}
>
>
> What am I doing wrong?
>
>
I cant explain it better than the error message already does :

each subcondition inside an "or{...}" condition must be in its own {}


means:

accept condition = ${if or{\
*{*${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}*}* \
*{*${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}*}* \
} {yes}}


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/
Re: Help to logical OR two conditions [ In reply to ]
Cyborg via Exim-users wrote:
> >
> >> accept? condition? = ${if or{\
> >> ?????????????????????????????? { and{ {CONDITION 1}{CONDITION 2} }}\
> >> ?????????????????????????????? { CONDITION 3 }\
> >> ????????????????????????????? } {1}}
> > So, for my case it should look like this, right )(copied verbatim from my test config):
> >
> > accept condition = ${if or{\
> > ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} \
> > ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} \
> > } {yes}}
> >
> >
> > Does not work however:
> > failed to expand ACL string "${if or{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} } {yes}}": each subcondition inside an "or{...}" condition must be in its own {}
> >
> >
> > What am I doing wrong?
> >
> >
> I cant explain it better than the error message already does :
>
> each subcondition inside an "or{...}" condition must be in its own {}
>
>
> means:
>
> accept condition = ${if or{\
> *{*${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}*}* \
> *{*${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}*}* \
> } {yes}}

This variant does not work either:

accept condition = ${if or{\
{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}} \
{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}} \
} {yes}}

failed to expand ACL string "${if or{{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}} {${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}} } {yes}}": condition name expected, but found "${lookup{$local_" inside "or{...}" condition

And I'm damned if I understand what is "condition name expected."


--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/
Re: Help to logical OR two conditions [ In reply to ]
On 01/10/2020 10:00, Victor Sudakov via Exim-users wrote:
> And I'm damned if I understand what is "condition name expected."

http://exim.org/exim-html-current/doc/html/spec_html/ch-string_expansions.html

Section 7, "Expansion conditions".
--
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: Help to logical OR two conditions [ In reply to ]
Jeremy Harris via Exim-users wrote:
> On 01/10/2020 10:00, Victor Sudakov via Exim-users wrote:
> > And I'm damned if I understand what is "condition name expected."
>
> http://exim.org/exim-html-current/doc/html/spec_html/ch-string_expansions.html
>
> Section 7, "Expansion conditions".

I've read it, and "8. Combining expansion conditions" too.

But some help with combining the specific conditions I have provided would
be much more appreciated.

Obviously if a person has read the manual and is struggling with syntax,
sending the person back to the manual is not quite helpful, especially if
you know the answer.

--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/
Re: Help to logical OR two conditions [ In reply to ]
On Thu, Oct 01, 2020 at 05:21:38PM +0700, Victor Sudakov via Exim-users wrote:
> Jeremy Harris via Exim-users wrote:
> > On 01/10/2020 10:00, Victor Sudakov via Exim-users wrote:
> > > And I'm damned if I understand what is "condition name expected."
> >
> > http://exim.org/exim-html-current/doc/html/spec_html/ch-string_expansions.html
> >
> > Section 7, "Expansion conditions".
>
> I've read it, and "8. Combining expansion conditions" too.
>
> But some help with combining the specific conditions I have provided would
> be much more appreciated.

You feed the string "yes" to or{..} as argument, but Exim does not treat
strings as conditions. In particular, bool{} transforms string to boolean,
you can do conversion with it. Or use syntax like eq{{LOOKUP}{yes}}.

> Obviously if a person has read the manual and is struggling with syntax,
> sending the person back to the manual is not quite helpful, especially if
> you know the answer.

IMHO, Exim documentation is very clean and structured.
However, it assumes some background in CS and/or programming.
--
Eugene Berdnikov

--
## 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: Help to logical OR two conditions [ In reply to ]
Evgeniy Berdnikov via Exim-users wrote:
> On Thu, Oct 01, 2020 at 05:21:38PM +0700, Victor Sudakov via Exim-users wrote:
> > Jeremy Harris via Exim-users wrote:
> > > On 01/10/2020 10:00, Victor Sudakov via Exim-users wrote:
> > > > And I'm damned if I understand what is "condition name expected."
> > >
> > > http://exim.org/exim-html-current/doc/html/spec_html/ch-string_expansions.html
> > >
> > > Section 7, "Expansion conditions".
> >
> > I've read it, and "8. Combining expansion conditions" too.
> >
> > But some help with combining the specific conditions I have provided would
> > be much more appreciated.
>
> You feed the string "yes" to or{..} as argument, but Exim does not treat
> strings as conditions.

I'm afraid I don't understand you. Look at this quite legitimate line:

accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}

Doesn't this line mean that the right part of the expression is err... hmm... a condition?

> In particular, bool{} transforms string to boolean,
> you can do conversion with it. Or use syntax like eq{{LOOKUP}{yes}}.

OK, I have changed my expression to

accept condition = ${if or {\
eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}{yes}} \
eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}{yes}} \
} {yes}}

and still it's not the thing:

failed to expand ACL string "${if or {eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}{yes}} eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}{yes}} } {yes}}": each subcondition inside an "or{...}" condition must be in its own {}

Then into

accept condition = ${if or {\
{eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}{yes}}} \
{eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}{yes}}} \
} {yes}}

and still:

failed to expand ACL string "${if or {{eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}{yes}}} {eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}{yes}}} } {yes}}": missing 2nd string in {} after "eq" inside "or{...}" condition

Can you possibly please reword my combined expression into a working one?

>
> > Obviously if a person has read the manual and is struggling with syntax,
> > sending the person back to the manual is not quite helpful, especially if
> > you know the answer.
>
> IMHO, Exim documentation is very clean and structured.

I agree. Exim is my favorite opensource MTA.

> However, it assumes some background in CS and/or programming.

Even people with some background in CS and/or programming often need
and appreciate good cookbooks and howtos.

BTW while googling for the solution, I've found quite a few questions in mailing
lists and Web-fora where people are frustrated by exim's nested conditions.

--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/

--
## 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: Help to logical OR two conditions [ In reply to ]
Am 01.10.20 um 11:00 schrieb Victor Sudakov via Exim-users:
> Cyborg via Exim-users wrote:
>>>> accept? condition? = ${if or{\
>>>> ?????????????????????????????? { and{ {CONDITION 1}{CONDITION 2} }}\
>>>> ?????????????????????????????? { CONDITION 3 }\
>>>> ????????????????????????????? } {1}}
>>> So, for my case it should look like this, right )(copied verbatim from my test config):
>>>
>>> accept condition = ${if or{\
>>> ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} \
>>> ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} \
>>> } {yes}}
>>>
>>>
>>> Does not work however:
>>> failed to expand ACL string "${if or{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}} } {yes}}": each subcondition inside an "or{...}" condition must be in its own {}
>>>
>>>
>>> What am I doing wrong?
>>>
>>>
>> I cant explain it better than the error message already does :
>>
>> each subcondition inside an "or{...}" condition must be in its own {}
>>
>>
>> means:
>>
>> accept condition = ${if or{\
>> *{*${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}*}* \
>> *{*${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}*}* \
>> } {yes}}
> This variant does not work either:
>
> accept condition = ${if or{\
> {${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}} \
> {${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}} \
> } {yes}}
>
> failed to expand ACL string "${if or{{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}} {${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}} } {yes}}": condition name expected, but found "${lookup{$local_" inside "or{...}" condition
>
> And I'm damned if I understand what is "condition name expected."
>
>
>

to make it bool:

{match{ ${lookup ..... }}{yes or what it shall match}}

full example to make it easier:

?accept condition = ${if or{\
{ eq{$h_subject}{Hello} }\
{ match{ ${lookup mysql {SELECT 1 FROM table WHERE a=b LIMIT 1 }} }*{1}* }\
} *{1}*}

I'm not using lsearches, so i can't give you an working example.. but i'm pretty sure one is in the docs.


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/
Re: Help to logical OR two conditions [ In reply to ]
On 01/10/2020 12:45, Victor Sudakov via Exim-users wrote:
> accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
>
> Doesn't this line mean that the right part of the expression is err... hmm... a condition?

No. The ACL general-purpose condition called "condition" takes a string
argument and converts it, using *its* set of rules, into a conditional
value for the ACL.

But you are dealing with an expansion condition, a different thing,
which is not a string. It is a separate concept. You were trying
to use a string (derived from an expansion, a lookup - but that isn't
really important here).
You could convert that string into an expansion condition, by using
either "bool" or "eq". Bool would be simpler.

> OK, I have changed my expression to
[...]
> Then into
>
> accept condition = ${if or {\
> {eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}{yes}}} \
> {eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}{yes}}} \
> } {yes}}
>
> and still:
>
> failed to expand ACL string "${if or {{eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}{yes}}} {eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}{yes}}} } {yes}}": missing 2nd string in {} after "eq" inside "or{...}" condition

re-laying out that...

${if or {\
{eq \
{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}} \
^^^^ missing a } here
{yes}\
} \
} \

{eq{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}{yes}}} \
} {yes}}

>
> Can you possibly please reword my combined expression into a working one?

I like to use a bracket-matching-capable editor when developing
complex conditions.
--
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: Help to logical OR two conditions [ In reply to ]
On 2020-10-01 at 13:24 +0700, Victor Sudakov via Exim-users wrote:
> Could you please help me unite the following two ACL expressions into one:
>
> accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
> accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}

Why?

It's _possible_ to combine conditions but too often it creates a bit of
a mess.

If you just leave it as two different accept verbs, then if the first
one doesn't pass, the second will be tested and ... you will have a
short-circuiting OR by using accept-then-accept.

For a Router, all condition rules must pass, so it becomes an AND.

> Should be fairly simple but... I've tried variants of '${if or {...' by
> the manual but all I got were errors like

The explanations here have been covered by others in the thread but I'm
combining it all into one, then comparing to the original.

So: a string needs to be made into a boolean status, because or/and take
booleans, not general strings. "Expansion conditions".

* bool{X} interprets X in the same way that ACL condition rules do
* bool_lax{X} interprets X in the same way that Router conditions do

So these should be equivalent:

accept condition = ${if or{\
{bool{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}}}\
{bool{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}}}\
}}

accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}

I don't know about you, but I find the separate rules easier to read and
debug, with fewer braces to be matched and fewer bits of specialist lore
to be memorized.

Simplicity and lack of nesting wins out over fancy boolean conditions
constructed by a human instead of a machine.

(But I'm biased, I added the ability to have multiple condition rules to
a Router.)

-Phil

--
## 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: Help to logical OR two conditions [ In reply to ]
Phil Pennock via Exim-users wrote:
> On 2020-10-01 at 13:24 +0700, Victor Sudakov via Exim-users wrote:
> > Could you please help me unite the following two ACL expressions into one:
> >
> > accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}
> > accept condition = ${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}
>
> Why?
>
> It's _possible_ to combine conditions but too often it creates a bit of
> a mess.
>
> If you just leave it as two different accept verbs, then if the first
> one doesn't pass, the second will be tested and ... you will have a
> short-circuiting OR by using accept-then-accept.

Hello Phil,

I thought there would be a performance penalty if we evaluate two ACL
conditions in a succession (in case the first fails, we evaluate the
second), instead of always evaluating one ACL condition.

Actually I have no other reason to combine them.

>
> For a Router, all condition rules must pass, so it becomes an AND.
>
> > Should be fairly simple but... I've tried variants of '${if or {...' by
> > the manual but all I got were errors like
>
> The explanations here have been covered by others in the thread but I'm
> combining it all into one, then comparing to the original.
>
> So: a string needs to be made into a boolean status, because or/and take
> booleans, not general strings. "Expansion conditions".
>
> * bool{X} interprets X in the same way that ACL condition rules do
> * bool_lax{X} interprets X in the same way that Router conditions do

Why did the Exim architects find it necessary to complicate things by
making if/or/and behave differently from ACL and Router condition rules?

And why did they call bool{...} and friends "Expansion conditions"
while they are clearly not conditions, but operators?

>
> So these should be equivalent:
>
> accept condition = ${if or{\
> {bool{${lookup{$local_part@$domain}lsearch{/etc/dovecot/aliases}{yes}}}}\
> {bool{${lookup{$local_part@$domain}lsearch{/etc/dovecot/users}{yes}}}}\
> }}

Yes, thanks, this works. I wish however that I would not have to write
complicated nested conditions for exim any time soon.

>
> I don't know about you, but I find the separate rules easier to read and
> debug, with fewer braces to be matched and fewer bits of specialist lore
> to be memorized.
>
> Simplicity and lack of nesting wins out over fancy boolean conditions
> constructed by a human instead of a machine.
>

--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/

--
## 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: Help to logical OR two conditions [ In reply to ]
On Sat, 3 Oct 2020, Victor Sudakov via Exim-users wrote:

> Why did the Exim architects find it necessary to complicate things by
> making if/or/and behave differently from ACL and Router condition rules?

IIRC if/or/and existed before ACLs.

> And why did they call bool{...} and friends "Expansion conditions"
> while they are clearly not conditions, but operators?

Sorry, no idea.

--
Andrew C. Aitchison Kendal, UK
andrew@aitchison.me.uk

--
## 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: Help to logical OR two conditions [ In reply to ]
On 03/10/2020 15:18, Victor Sudakov via Exim-users wrote:
> And why did they call bool{...} and friends "Expansion conditions"
> while they are clearly not conditions, but operators?

The operate on things and result in conditionals. Have to call
them something.
--
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: Help to logical OR two conditions [ In reply to ]
Jeremy Harris via Exim-users wrote:
> On 03/10/2020 15:18, Victor Sudakov via Exim-users wrote:
> > And why did they call bool{...} and friends "Expansion conditions"
> > while they are clearly not conditions, but operators?
>
> The operate on things and result in conditionals. Have to call

What you do mean by "result in conditionals" ? They result in boolean
values.

--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/

--
## 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: Help to logical OR two conditions [ In reply to ]
On 04/10/2020 08:30, Victor Sudakov via Exim-users wrote:
> Jeremy Harris via Exim-users wrote:
>> On 03/10/2020 15:18, Victor Sudakov via Exim-users wrote:
>>> And why did they call bool{...} and friends "Expansion conditions"
>>> while they are clearly not conditions, but operators?
>>
>> The operate on things and result in conditionals. Have to call
>
> What you do mean by "result in conditionals" ? They result in boolean
> values.

Those are the same.
--
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: Help to logical OR two conditions [ In reply to ]
Having had a chat with Victor off-list, I think the thing he's curious
about is why *or* *requires* strict true/false values as its arguments, but
the *condition* condition *doesn't* — instead *condition* effectively
performs a *bool_lax* on the expression evaluated on its right hand side.
This difference is documented within the description of bool_lax in the
String Expansions chapter, but is easy to miss for people new to Exim

I suggested that strictly requiring true/false within an *or* is likely a
safety measure, otherwise it's very easy to write expressions that appear
to work but don't in all situations because of the lenient interpretation.

I think there was also some confusion over the Expansion Items, Expansion
Operators, Expansion Conditions and Combination Conditions. From the
developers perspective these are different types of thing, that are can be
used in different ways/places. But for a newcomer to Exim it can be
confusing. For example,

- A *condition* condition wants a true/false value
- An *or* returns a Boolean true/false value
- But (if memory serves, I no longer run the mail service here so don't
have access now to the test system) you can't write
condition = or{ {<cond1>} {<cond2} }
- Instead you need to wrap the *or* up within an *if*
- The *if* can potentially return any string, which an implicit
*bool_lax* then makes into a Bolean true/false acceptable to the
*condition*.


So one can gradually learn that *condition* is happy to interpret the empty
string and "no", "false" and 0 as a Boolean false, with everything else
meaning true, and then assume that in other places where true/false values
are wanted you can do likewise. But in fact you can't, because most places
instead want a strict Boolean true/false, and you therefore need to
manually add the *bool_lax* (which you don't for *condition*).
????

I'm guessing this has come about because of the evolution of Exim over the
years and needing to maintain compatibility with previous
version's configuration files, which is fine and something long-term users
understand and accept.

Cheers,
Mike B-)

On Sun, 4 Oct 2020 at 11:56, Jeremy Harris via Exim-users <
exim-users@exim.org> wrote:

> On 04/10/2020 08:30, Victor Sudakov via Exim-users wrote:
> > Jeremy Harris via Exim-users wrote:
> >> On 03/10/2020 15:18, Victor Sudakov via Exim-users wrote:
> >>> And why did they call bool{...} and friends "Expansion conditions"
> >>> while they are clearly not conditions, but operators?
> >>
> >> The operate on things and result in conditionals. Have to call
> >
> > What you do mean by "result in conditionals" ? They result in boolean
> > values.
>
> Those are the same.
> --
> 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/
>


--
*My normal working days are Tuesdays, Wednesdays and Thursdays.*

Systems Administrator working in Teaching & Learning
IT Services, University of York, Heslington, York YO10 5DD, UK
Tel: +44-(0)1904-323811
Email Disclaimer: www.york.ac.uk/about/legal-statements/email-disclaimer/

Web: www.york.ac.uk/it-services
Disclaimer: www.york.ac.uk/docs/disclaimer/email.htm
--
## 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: Help to logical OR two conditions [ In reply to ]
On Tue, Oct 06, 2020 at 10:31:48AM +0100, Mike Brudenell via Exim-users wrote:
> I'm guessing this has come about because of the evolution of Exim over the
> years and needing to maintain compatibility with previous
> version's configuration files, which is fine and something long-term users
> understand and accept.

Such change as automatic casting strings to boolean for conditional
expressions does not break backword compatibility, IMHO.

However, look & feel of Exim's API leaves much to be desired...
I would prefer C/Perl style (without numerous {}), which does not require
syntax-highlighting editor to be managed even for simple expressions.
Say, <cond1> || <cond2> instead of or{{<cond1>}{<cond2}}.
--
Eugene Berdnikov

--
## 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: Help to logical OR two conditions [ In reply to ]
Evgeniy Berdnikov via Exim-users wrote:
>
> However, look & feel of Exim's API leaves much to be desired...
> I would prefer C/Perl style (without numerous {}), which does not require
> syntax-highlighting editor to be managed even for simple expressions.
> Say, <cond1> || <cond2> instead of or{{<cond1>}{<cond2}}.

Well, maybe after Sendmail has become irrelevant, we still need
something to be very tricky?

--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
2:5005/49@fidonet http://vas.tomsk.ru/

--
## 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: Help to logical OR two conditions [ In reply to ]
On 7 Oct 2020, at 04:33, Victor Sudakov via Exim-users <exim-users@exim.org> wrote:
> Well, maybe after Sendmail has become irrelevant, we still need
> something to be very tricky?

Wearing my admin and occasional contributor hat, this is the point at which I can hear both Jeremy and Phil quietly saying "code contributions are accepted" :)

Seriously: if something feels wrong to you, and you can fix it/make it better/make it less contradictory *without breaking backward compatibility*, please feel free to do so.

That said, I'd be minded to say that wholesale API changes are likely to render any future development a fork, at best, as it would not be the Exim we all know and love/tolerate/have to work with.

Graeme
--
## 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: Help to logical OR two conditions [ In reply to ]
On 2020-10-07 10:33, Victor Sudakov wrote:

> > However, look & feel of Exim's API leaves much to be desired... I
> > would prefer C/Perl style (without numerous {}), which does not
> > require syntax-highlighting editor to be managed even for simple
> > expressions. Say, <cond1> || <cond2> instead of
> > or{{<cond1>}{<cond2}}.
>
> Well, maybe after Sendmail has become irrelevant, we still need
> something to be very tricky?

That's funny, because right after I read Evgeny's post I felt an urge to
point out that you can always write a macro preprocessor if the real
syntax is too ugly ;-)

--
Ian

--
## 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: Help to logical OR two conditions [ In reply to ]
On Wed, Oct 07, 2020 at 09:30:38AM -0700, Ian Zimmerman via Exim-users wrote:
> On 2020-10-07 10:33, Victor Sudakov wrote:
>
> > > However, look & feel of Exim's API leaves much to be desired... I
> > > would prefer C/Perl style (without numerous {}), which does not
> > > require syntax-highlighting editor to be managed even for simple
> > > expressions. Say, <cond1> || <cond2> instead of
> > > or{{<cond1>}{<cond2}}.
> >
> > Well, maybe after Sendmail has become irrelevant, we still need
> > something to be very tricky?
>
> That's funny, because right after I read Evgeny's post I felt an urge to
> point out that you can always write a macro preprocessor if the real
> syntax is too ugly ;-)

Yes. ;) BTW, Exim has built-in macro facility, which is really helpful.
Decompositions like

COND1 = ...
COND2 = ...
EXP1 = ...
something = ... ${if or{{COND1}{COND2}} {EXP1}fail} ...

may significantly improve readability and save time.
--
Eugene Berdnikov

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