variable expansion allowed in 'listen' config not working
Hi,
In a new dovecot 2.4 config I'm setting up a inet_listener for a service.
I want to use an env var in listen
expansion, like
service imap-login { inet_listener imaps { listen = %{env:LAN_IPv4}, 127.0.0.1 } }
This
https://doc.dovecot.org/2.4.1/core/settings/variables.html
says
"You can use special variables in several places: All settings, except of type String without variables."
Reading
https://doc.dovecot.org/2.4.1/core/summaries/settings.html#listen
listen
directive allows
listen Default *, :: Value IP addresses
Unlike, for example
deliver_log_format Default msgid=%{msgid}: %{message} Value String without variables
which would be disallowed for "String without variables"
I CAN use env vars across almost all of my config.
But launch
systemctl start dovecot
fails with
dovecot[17358]: Fatal: service(imap-login) Can't resolve address %{env:LAN_IPv4}: Name or service not known
OTOH replacing
- listen = %{env:LAN_IPv4}, 127.0.0.1
- listen = 10.1.1.1, 127.0.0.1
solves the launch issue.
Like I said it works in other stanzas.
Am I configuring this right for listen
?
Thanks,
Dave
Can you try
listen = $ENV:LAN_IPv4 , 127.0.0.1
note the space before comma
Aki
On 20/09/2025 15:46 EEST publists--- via dovecot
<[1]dovecot@dovecot.org> wrote:
Hi,
In a new dovecot 2.4 config I'm setting up a inet_listener for a
service.
I want to use an env var in `listen` expansion, like
service imap-login {
inet_listener imaps {
listen = %{env:LAN_IPv4}, 127.0.0.1
}
}
This
[2]https://doc.dovecot.org/2.4.1/core/settings/variables.html
says
"You can use special variables in several places:
All settings, except of type String without variables."
Reading
[3]https://doc.dovecot.org/2.4.1/core/summaries/settings.html#listen
`listen` directive allows
listen
Default *, ::
Value IP addresses
Unlike, for example
deliver_log_format
Default msgid=%{msgid}: %{message}
Value String without variables
which would be disallowed for "String without variables"
I CAN use env vars across almost all of my config.
But launch
systemctl start dovecot
fails with
dovecot[17358]: Fatal: service(imap-login) Can't resolve address
%{env:LAN_IPv4}: Name or service not known
OTOH replacing
- listen = %{env:LAN_IPv4}, 127.0.0.1
+ listen = 10.1.1.1, 127.0.0.1
solves the launch issue.
Like I said it works in other stanzas.
Am I configuring this right for `listen`?
Thanks,
Dave
_______________________________________________
dovecot mailing list -- [4]dovecot@dovecot.org
To unsubscribe send an email to [5]dovecot-leave@dovecot.org
References
Visible links
- mailto:dovecot@dovecot.org
- https://doc.dovecot.org/2.4.1/core/settings/variables.html
- https://doc.dovecot.org/2.4.1/core/summaries/settings.html#listen
- mailto:dovecot@dovecot.org
- mailto:dovecot-leave@dovecot.org
Hi,
On Sat, Sep 20, 2025, at 9:13 AM, Aki Tuomi via dovecot wrote:
Can you try
listen = $ENV:LAN_IPv4 , 127.0.0.1
note the space before comma
Aki
With
cat dovecot.conf
importEironment { E_LAN_IPv4 = %{env:LAN_IPv4} E_LAN_IPv6 = %{env:LAN_IPv6} }
cat dovecot.env
LAN_IPv4=10.1.1.1 LAN_IPv6=fd80:10:1::1
cat /etc/systemd/system/dovecot-current.service
EnvironmentFile=/etc/dovecot/dovecot.env
This works
listen = 10.1.1.1, 127.0.0.1, [fd80:10:1::1], [::1]
This fails
listen = $ENV:E_LAN_IPv4 , 127.0.0.1, [$ENV:E_LAN_IPv6] , [::1]
This works
listen = $ENV:E_LAN_IPv4 , 127.0.0.1, $ENV:E_LAN_IPv6 , [::1]
This fails
listen = %{env:E_LAN_IPv4} , 127.0.0.1, [%{env:E_LAN_IPv6}] , [::1]
'works' so far just means that dovecot starts up without complaining.
I didn't yet TEST the listeners.
Dave
It might work better if you export LAN_IPv6 as [address]. The current $ENV: expansion is whitespace delimited.
Aki
On 20/09/2025 16:52 EEST publists--- via dovecot <dovecot@dovecot.org> wrote:
Hi,
On Sat, Sep 20, 2025, at 9:13 AM, Aki Tuomi via dovecot wrote:
Can you try
listen = $ENV:LAN_IPv4 , 127.0.0.1
note the space before comma
Aki
With
cat dovecot.conf
importEironment { E_LAN_IPv4 = %{env:LAN_IPv4} E_LAN_IPv6 = %{env:LAN_IPv6} }
cat dovecot.env
LAN_IPv4=10.1.1.1 LAN_IPv6=fd80:10:1::1
cat /etc/systemd/system/dovecot-current.service
EnvironmentFile=/etc/dovecot/dovecot.env
This works
listen = 10.1.1.1, 127.0.0.1, [fd80:10:1::1], [::1]
This fails
listen = $ENV:E_LAN_IPv4 , 127.0.0.1, [$ENV:E_LAN_IPv6] , [::1]
This works
listen = $ENV:E_LAN_IPv4 , 127.0.0.1, $ENV:E_LAN_IPv6 , [::1]
This fails
listen = %{env:E_LAN_IPv4} , 127.0.0.1, [%{env:E_LAN_IPv6}] , [::1]
'works' so far just means that dovecot starts up without complaining.
I didn't yet TEST the listeners.
Dave
dovecot mailing list -- dovecot@dovecot.org To unsubscribe send an email to dovecot-leave@dovecot.org
Hi,
On Sat, Sep 20, 2025, at 10:49 AM, Aki Tuomi via dovecot wrote:
The current $ENV: expansion is whitespace delimited.
Aki
Is the need to use the $ENV expansion format in 'listen' intentional?
Is that planned to be changed to be consistent with the docs?
Is there a list of parameters that still only work with the $ENV form?
Dave
participants (2)
-
Aki Tuomi
-
publists@emailgroups.net