Mailing List Archive

using environment ${env {}} for helo_data
Hi folx,

for a new dockerized exim setup I'm trying to use environment variables
to customize some settings in the exim config file.


My exim4.config sample:
```
...
keep_environment = EH : EXIM_HOSTNAME : EXIM_HELONAME
smtp_active_hostname = ${env{EXIM_HOSTNAME}{$value}{hostname-undefined}}

...
begin transports
...
remote_smtp:
...
# helo_data = ${env{EXIM_HELONAME}{$value}{heloname-undefined}}
helo_data = ${env {EXIM_HELONAME}}
...
# for debugging only:
headers_add = "X-HOSTNAME: ${env {EXIM_HOSTNAME}}"
headers_add = "X-EH: ${env {EH}}"
headers_add = "X-EXIM_HELONAME: ${env {EXIM_HELONAME}}"

```


My test:
export EXIM_HELONAME=myheloname
# restart exim
swaks --from="<>" --to=$ME --server=localhost


The result:

...
1 Received: from dck01.**** ([x.x.x.x] helo=)
2 by mail.* with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
...
14 Date: Wed, 29 Jul 2020 10:43:32 +0200
15 To: fh@lf.net
16 From:
17 Subject: test Wed, 29 Jul 2020 10:43:32 +0200
18 Message-Id: <20200729104332.003268@14c3c675c896>
19 X-Mailer: swaks v20181104.0 jetmore.org/john/code/swaks/
20 X-HOSTNAME:
21 X-EH:
22 X-EXIM_HELONAME:
...

As you can see, neither heloname is set (line 1), nor the additional
headerlines (lines 20-22) are.
Strangely enough, setting the active hostname works:

export EXIM_HOSTNAME=myeximhostname
# restart exim
telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 myeximhostname custom MTA conf v3.0 Wed, 29 Jul 2020 11:28:48 +0200
^^^^^^^^^^^^^^


The basic system is:
Debian GNU/Linux 10
Exim version 4.92 #3 built 13-May-2020 16:01:31

Anybody here could give me a hint, why setting smtp_active_hostname works
but helo_data or headers_add does not?


--
Best regards
Frank


--
## 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: using environment ${env {}} for helo_data [ In reply to ]
On 29/07/2020 10:48, Frank Heydlauf via Exim-users wrote:
> My test:
> export EXIM_HELONAME=myheloname
> # restart exim
> swaks --from="<>" --to=$ME --server=localhost

I'm guessing that you're not actually running exim from
the shell you set the environment variable in.

Look into how your Debian actually starts the exim binary.
If it's systemd, for example, you'll be needing to set
the environment in the recipe (whatever they call it)
it uses for the service.
--
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: using environment ${env {}} for helo_data [ In reply to ]
Hi Jeremy,

On Wed, Jul 29, 2020 at 11:11:22AM +0100, Jeremy Harris via Exim-users wrote:
> On 29/07/2020 10:48, Frank Heydlauf via Exim-users wrote:
> > My test:
> > export EXIM_HELONAME=myheloname
> > # restart exim
> > swaks --from="<>" --to=$ME --server=localhost
>
> I'm guessing that you're not actually running exim from
> the shell you set the environment variable in.

To avoid this I stop/start exim with 'kill -TERM' and '/usr/sbin/exim4 -bd -q5m'
where /usr/sbin/exim4 is the binary (verified).
The env variables are exported in the very same shell, the exim is
started from.

If this wouldn't work, the active-hostname would not be set either - but that works:

root@14c3c675c896:/# ps ax | grep exim
4401 ? Ss 0:00 /usr/sbin/exim4 -bd -q5m
6695 pts/0 S+ 0:00 grep exim
root@14c3c675c896:/# kill -TERM 4401
root@14c3c675c896:/# ps ax | grep exim
6697 pts/0 S+ 0:00 grep exim
root@14c3c675c896:/# export EXIM_HOSTNAME=justanothertest
root@14c3c675c896:/# /usr/sbin/exim4 -bd -q5m
root@14c3c675c896:/# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 justanothertest LF.net custom MTA conf v3.0 Wed, 29 Jul 2020 13:20:49 +0200
quit
221 justanothertest closing connection
Connection closed by foreign host.



Very strange :(

--
Regards
Frank

--
## 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: using environment ${env {}} for helo_data [ In reply to ]
Am 29.07.20 um 13:25 schrieb Frank Heydlauf via Exim-users:
> To avoid this I stop/start exim with 'kill -TERM' and '/usr/sbin/exim4 -bd -q5m'
> where /usr/sbin/exim4 is the binary (verified).
> The env variables are exported in the very same shell, the exim is
> started from.
>
> Very strange :(
>

Did you make use of "keep_environment = " in your config?

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: using environment ${env {}} for helo_data [ In reply to ]
Frank Heydlauf via Exim-users <exim-users@exim.org> (Mi 29 Jul 2020 11:48:55 CEST):
> My exim4.config sample:
> ```
> ...
> keep_environment = EH : EXIM_HOSTNAME : EXIM_HELONAME
> smtp_active_hostname = ${env{EXIM_HOSTNAME}{$value}{hostname-undefined}}
>
> ...
> begin transports
> ...
> remote_smtp:
> ...
> # helo_data = ${env{EXIM_HELONAME}{$value}{heloname-undefined}}
> helo_data = ${env {EXIM_HELONAME}}
> ...
> # for debugging only:
> headers_add = "X-HOSTNAME: ${env {EXIM_HOSTNAME}}"
> headers_add = "X-EH: ${env {EH}}"
> headers_add = "X-EXIM_HELONAME: ${env {EXIM_HELONAME}}"
>

Did you define macros using substrings of the environment variables
you're trying to use?

--
Heiko
Re: using environment ${env {}} for helo_data [ In reply to ]
Hi Heiko,

On Wed, Jul 29, 2020 at 06:47:32PM +0200, Heiko Schlittermann via Exim-users wrote:
> Frank Heydlauf via Exim-users <exim-users@exim.org> (Mi 29 Jul 2020 11:48:55 CEST):
...
> > ...
> > # helo_data = ${env{EXIM_HELONAME}{$value}{heloname-undefined}}
> > helo_data = ${env {EXIM_HELONAME}}
> > ...
> > # for debugging only:
> > headers_add = "X-HOSTNAME: ${env {EXIM_HOSTNAME}}"
> > headers_add = "X-EH: ${env {EH}}"
> > headers_add = "X-EXIM_HELONAME: ${env {EXIM_HELONAME}}"
> >
>
> Did you define macros using substrings of the environment variables
> you're trying to use?

No, I use the variables just as they are (or should be).

After a several tests I guess ${env {}} is just not set/expanded
in the transports section.
However, I could not find anything about that in the dokumentation.


--
Regards
Frank

--
## 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: using environment ${env {}} for helo_data [ In reply to ]
Frank Heydlauf via Exim-users <exim-users@exim.org> (Mi 29 Jul 2020 22:12:13 CEST):
> > > ...
> > > # helo_data = ${env{EXIM_HELONAME}{$value}{heloname-undefined}}
> > > helo_data = ${env {EXIM_HELONAME}}
> > > ...
> > > # for debugging only:
> > > headers_add = "X-HOSTNAME: ${env {EXIM_HOSTNAME}}"
> > > headers_add = "X-EH: ${env {EH}}"
> > > headers_add = "X-EXIM_HELONAME: ${env {EXIM_HELONAME}}"
>
> After a several tests I guess ${env {}} is just not set/expanded
> in the transports section.
> However, I could not find anything about that in the dokumentation.

That is very unlikely. Either expansion is applied or not. But from what
I understand (whithout explicitly checking now) from the code is, that
we have an "expand" function, and there is no list of items to be
expanded or not expanded. But… I might be wrong.

Can you post the smallest working config that you use to reproduce the
behaviour?

Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
--
SCHLITTERMANN.de ---------------------------- internet & unix support -
Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
gnupg encrypted messages are welcome --------------- key ID: F69376CE -
Re: using environment ${env {}} for helo_data [ In reply to ]
Hi Heiko,

On Thu, Jul 30, 2020 at 10:39:10AM +0200, Heiko Schlittermann via Exim-users wrote:
...
> > After a several tests I guess ${env {}} is just not set/expanded
> > in the transports section.
> > However, I could not find anything about that in the dokumentation.
>
> That is very unlikely. Either expansion is applied or not. But from what
> I understand (whithout explicitly checking now) from the code is, that
> we have an "expand" function, and there is no list of items to be
> expanded or not expanded. But… I might be wrong.
>
> Can you post the smallest working config that you use to reproduce the
> behaviour?

uh. Made a minimal config, about 60 lines (instead of nearly 500).
And - what could I say - ${env{}} works :-O
I'll try to find the section which causes the trouble...

--
Regards
Frank

--
## 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: using environment ${env {}} for helo_data [ In reply to ]
Frank Heydlauf via Exim-users <exim-users@exim.org> (Do 30 Jul 2020 16:01:42 CEST):
> uh. Made a minimal config, about 60 lines (instead of nearly 500).
> And - what could I say - ${env{}} works :-O
> I'll try to find the section which causes the trouble...

Can you share these both files privately?

Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
--
SCHLITTERMANN.de ---------------------------- internet & unix support -
Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
gnupg encrypted messages are welcome --------------- key ID: F69376CE -
Re: using environment ${env {}} for helo_data [ In reply to ]
Hi folx,

solved!

On Thu, Jul 30, 2020 at 04:01:42PM +0200, Frank Heydlauf via Exim-users wrote:
...
> > Can you post the smallest working config that you use to reproduce the
> > behaviour?
>
> uh. Made a minimal config, about 60 lines (instead of nearly 500).
> And - what could I say - ${env{}} works :-O
> I'll try to find the section which causes the trouble...

begin transports
...
spamcheck:
driver = pipe
command = /usr/sbin/exim -oMr spam-scanned -bS -oMa 127.0.0.1
...

is the trouble maker.

The exim is started with plain environment;
add_environment is not supported with pipe transport.

A wrapper would work (tested) - but I'd lose the benefits I had
hoped for, using ${env {}} variables.

--
Regards
Frank

--
## 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: using environment ${env {}} for helo_data [ In reply to ]
On Thu, 30 Jul 2020, Frank Heydlauf via Exim-users wrote:

> Hi folx,
>
> solved!
>
> On Thu, Jul 30, 2020 at 04:01:42PM +0200, Frank Heydlauf via Exim-users wrote:
> ...
>>> Can you post the smallest working config that you use to reproduce the
>>> behaviour?
>>
>> uh. Made a minimal config, about 60 lines (instead of nearly 500).
>> And - what could I say - ${env{}} works :-O
>> I'll try to find the section which causes the trouble...
>
> begin transports
> ...
> spamcheck:
> driver = pipe
> command = /usr/sbin/exim -oMr spam-scanned -bS -oMa 127.0.0.1
> ...
>
> is the trouble maker.
>
> The exim is started with plain environment;
> add_environment is not supported with pipe transport.

29.4 Environment variables
--------------------------

The environment variables listed below are set up when the command is
invoked. This list is a compromise for maximum compatibility with
other MTAs.
*** Note that the environment option can be used to add
*** additional variables to this environment.
The environment for the pipe transport is not subject to the
add_environment and keep_environment main config options.

Stars added by me (ACA).

> A wrapper would work (tested) - but I'd lose the benefits I had
> hoped for, using ${env {}} variables.

Does something like
environment = EH=${env{EH}}
in the pipe transport (untested) help ?
From the code it appears to be a list.

--
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: using environment ${env {}} for helo_data [ In reply to ]
Hi Andrew,

On Thu, Jul 30, 2020 at 07:26:33PM +0100, Andrew C Aitchison via Exim-users wrote:
...

> Does something like
> environment = EH=${env{EH}}
> in the pipe transport (untested) help ?
> From the code it appears to be a list.

Great, this works!
Missed the "environment" option totally /o\
Tnx for giving me this hint!

--
Greets
Frank

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