Skip to content

Commit f0ce06e

Browse files
committed
settings: Describe the new delayed $SET variable expansion
1 parent 4797a32 commit f0ce06e

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

data/updates.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const updates = {
6868
service_auth_listener_type: '2.4.0',
6969
service_dict_expire: '2.4.0',
7070
service_listener_type: '2.4.0',
71+
settings_delayed_expansion_changed: '2.4.2',
7172
settings_syntax_named_filters_added: '2.4.0',
7273
sieve_ext_imapflags: '2.4.0',
7374
sieve_ext_notify: '2.4.0',

docs/core/settings/syntax.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,19 +436,36 @@ functionality is especially useful for reading SSL certificates and keys.
436436

437437
## Variable Expansion
438438

439-
It's possible to refer to other earlier settings as `$SET:name`.
439+
It's possible to refer to other settings as `$SET:name`.
440+
441+
[[changed,settings_delayed_expansion_changed]] Generally, the setting values
442+
are expanded at the end of the configuration parsing. Also the expansion takes
443+
into account what filters are active, as well as chaining of settings.
440444

441445
Example:
442446

443447
```
444-
key = value1
445-
key2 = $SET:key value2
446-
# Equivalent to key2 = value1 value2
448+
service imap {
449+
# expands to "_dovecot"
450+
service_user = $SET:default_internal_user
451+
unix_listener imap {
452+
# expands to the parent filter's service_user, which expands to "_dovecot"
453+
user = $SET:service_user
454+
}
455+
}
456+
# This can be set after the $SET:default_internal_user usage above
457+
default_internal_user = _dovecot
447458
```
448459

449-
However, you must be careful with the ordering of these in the configuration
450-
file, because the `$SET:variables` are expanded immediately while parsing the
451-
config file and they're not updated later.
460+
One exception is that if the setting refers to itself, the whole value is
461+
expanded immediately with the current settings' values. For example:
462+
463+
```
464+
login_log_format_elements = user=<%{user}>
465+
login_log_format_elements = $SET:login_log_format_elements method=%{mechanism}
466+
login_log_format_elements = $SET:login_log_format_elements session=<%{session}>
467+
# Expands to: user=<%{user}> method=%{mechanism} session=<%{session}>
468+
```
452469

453470
See also [[link,settings_variables]].
454471

0 commit comments

Comments
 (0)