Mailing List Archive

Error while checking expression with exim -be
Hello.

I need to check if the HTTP response is a JSON.
I did not find a function like isjson, so I decided to check HTTP
response with a regular expression.

When I tried to run exim with a long value of -be option, I got an error:

exim: length limit exceeded (386 > 256) for: recipient

But there are no any recipients in the command line.
Also the 256 character limit is too small in this case.


May be the cause of the problem in this code snippet.


/* An argument not starting with '-' is the start of a recipients list;
break out of the options-scanning loop. */

if (arg[0] != '-')
{
recipients_arg = i;
break;
}


When I run

exim -be '${eval:2*2}'

then '${eval:2*2}' does not start with '-' and is not a recipient address.


--
Best wishes Victor Ustugov
mailto:victor@corvax.kiev.ua
public GnuPG/PGP key: https://victor.corvax.kiev.ua/corvax.asc

--
## 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: Error while checking expression with exim -be [ In reply to ]
On 14/03/2023 11:46, Victor Ustugov via Exim-users wrote:
> When I tried to run exim with a long value of -be option, I got an error:
>
> exim: length limit exceeded (386 > 256) for: recipient

Yes, I've run into that (just this week!)

I assume the "-be <arg>" was a retrofit after the use
of a trailing arg for a mail recipient, and just uses the same
machinery.

What you can do is use the interactive mode of -be instead;
that's ok up to more like a kB - and after that, use "backlash, newline"
continuations.
--
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: Error while checking expression with exim -be [ In reply to ]
Jeremy Harris via Exim-users wrote on 14.03.2023 14:18:

>> exim: length limit exceeded (386 > 256) for: recipient
>
> Yes, I've run into that (just this week!)
>
> I assume the "-be <arg>" was a retrofit after the use
> of a trailing arg for a mail recipient, and just uses the same
> machinery.
>
> What you can do is use the interactive mode of -be instead;
> that's ok up to more like a kB - and after that, use "backlash, newline"
> continuations.

I need to run exim -be with the same expression multiple times
(Office365 OAutn2 access token response size is over 4K). The size of
the expression is quite large. Entering this expression interactively
many times will be very inconvenient.

So far I have switched to passing the expression through stdin.

But a few months ago I ran into the problem of passing some expressions
through stdin. And then I switched to using passing expressions through
a command line parameter. Now I can hardly remember what exactly were
the problems with passing expressions through stdin.


p. s. Due to the need to check for large HTTP responses, I had to change
the size of debug_buffer from 2048 bytes to 8192 bytes in the
src/debug.c file. A few years before I used 4096 bytes and that was enough.


--
Best wishes Victor Ustugov
mailto:victor@corvax.kiev.ua
public GnuPG/PGP key: https://victor.corvax.kiev.ua/corvax.asc

--
## 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: Error while checking expression with exim -be [ In reply to ]
On 14/03/2023 13:17, Victor Ustugov via Exim-users wrote:
> Office365 OAutn2 access token response size is over 4K)

You are seriously stretching the original intent of Exim's
string-handling with this.

[ Have you considered writing an Exim authenticator module? ]

> Entering this expression interactively
> many times will be very inconvenient.

a) you should be able to use stdin. If you are
having problems with it, they are probably from
the shell (as in Bourne Shell, Ksh, Csh) expanding
or dequoting things you didn't expect

b) recent version of the "-be" support let you
define macros and set variables
--
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: Error while checking expression with exim -be [ In reply to ]
Jeremy Harris via Exim-users wrote on 15.03.2023 01:21:
> On 14/03/2023 13:17, Victor Ustugov via Exim-users wrote:
>> Office365 OAutn2 access token response size is over 4K)
>
> You are seriously stretching the original intent of Exim's
> string-handling with this.

Don't underestimate exim. It already let me implement Oauth2 support for
gmail and office365 without ${run, curl, grep, cut, gawk, M365-IMAP,
python, msal, PyJWT and other external stuff.

Only exim, ${acl, ${lookup mysql{ (or whatever you prefer for caching),
${extract{, ${sg{, ${if match{, ${readsocket{ with patch for SNI support
(thanks a lot for it), ${extract json{ and ${extract jsons{.

The only thing I'm missing is a native check if a string is JSON.
Checking such a string against a regular expression is quite primitive.


Many other features are implemented such way:

integration with spamd;
integration with rspamd;
support for memcached;
getting information from whois servers;
getting information about ASN from https://api.iptoasn.com/;
and so on.

I once wanted to implement dspam support in the same way.


> [ Have you considered writing an Exim authenticator module? ]

No.

I'm a postmaster. I haven't really programmed for many years. My skills
are only enough to create patches and intricate things in the exim config.

It was not easy to figure out how to get a refresh token. Especially for
Office365. But this is a one-time manual task for each sender.
No module is needed to use the refresh token to get an access token and
use the access token for OAuth2. You just need a few dozen lines in the
config.


>> Entering this expression interactively
>> many times will be very inconvenient.
>
> a) you should be able to use stdin.  If you are
> having problems with it, they are probably from
> the shell (as in Bourne Shell, Ksh, Csh) expanding
> or dequoting things you didn't expect

I've already got everything I wanted from exim -be to implement OAuth2
support, thanks.


> b) recent version of the "-be" support let you
> define macros and set variables

I'll take that into account, thanks.


--
Best wishes Victor Ustugov
mailto:victor@corvax.kiev.ua
public GnuPG/PGP key: https://victor.corvax.kiev.ua/corvax.asc

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