aboutsummaryrefslogtreecommitdiffstats
path: root/roles/mail/templates/dovecot/passdb.j2
blob: e6c65c9ccb17cf3a239b0c01636e6fc2cdcd024b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# /usr/local/etc/dovecot/passdb
# Dovecot authentication database in passwd-file format.
#
# References:
# * Dovecot - PasswordDatabase
#   https://wiki.dovecot.org/PasswordDatabase
# * Dovecot - AuthDatabase / PasswdFile
#   https://wiki.dovecot.org/AuthDatabase/PasswdFile
#
#
# Aaron LI
#

# Fields
# ------
# user:password:(uid):(gid):(gecos):(home):(shell):extra_fields
# The ()-enclosed fields are ignored by Dovecot passdb lookup.
# ----------------------------------------------------------------------
{% set mydomain = mail.domains[0] %}
{% for domain in mail.domains %}
# [domain: {{ domain }}]
{% for user in mail.userdb %}
{% set username = user.name %}
{% set email = username + "@" + domain %}
{% set pass = user.pass %}
# (user: {{ username }})
{{ email }}:{{ pass | dovecot_makepass }}::::::user={{ email }}
{% for dev in user.devices|default([]) %}
{% set devname = dev.name %}
{% set pass = dev.pass %}
{{ email }}@{{ devname }}:{{ pass | dovecot_makepass }}::::::user={{ email }}
{% endfor %}{# devices #}
{% if username != "root" and user.aliases is defined %}
# aliases
{% for alias in user.aliases|default([]) %}
{% set email = alias + "@" + domain %}
{{ email }}:{{ pass | dovecot_makepass }}::::::user={{ email }}
{% for dev in user.devices|default([]) %}
{% set devname = dev.name %}
{% set pass = dev.pass %}
{{ email }}@{{ devname }}:{{ pass | dovecot_makepass }}::::::user={{ email }}
{% endfor %}{# devices #}
{% endfor %}{# alias #}
{% endif %}{# aliases #}
{% endfor %}{# user #}
{% endfor %}{# domain #}
# EOF