Skip to content

Commit 202bab6

Browse files
committed
Upgrade configuration files for Dovecot 2.3
1 parent 43ef9e2 commit 202bab6

11 files changed

Lines changed: 173 additions & 100 deletions

File tree

ansible/roles/dovecot/tasks/main.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,33 +176,34 @@
176176
tags:
177177
- role::dovecot
178178

179-
- name: Template Dovecot LDAP config
180-
template:
181-
src: dovecot-ldap.conf.ext.j2
182-
dest: /etc/dovecot/dovecot-ldap.conf.ext
183-
group: root
184-
owner: root
185-
mode: "0600"
179+
# BEGIN temporary cleanup task
180+
- name: Kill Dovecot LDAP config
181+
file:
182+
path: /etc/dovecot/dovecot-ldap.conf.ext
183+
state: absent
186184
tags:
187185
- role::dovecot
188186
notify:
189187
- Reload Dovecot
188+
# END temporary cleanup task
190189

191190
- name: Template Dovecot component configurations
192191
template:
193192
src: "configs/{{ item }}.j2"
194193
dest: "/etc/dovecot/conf.d/{{ item }}"
195194
group: root
196195
owner: root
197-
mode: "0644"
196+
mode: "0600"
198197
loop:
198+
- 10-director.conf
199199
- 10-mail.conf
200200
- 10-master.conf
201201
- 10-auth.conf
202202
- 10-ssl.conf
203203
- 15-mailboxes.conf
204204
- 20-lmtp.conf
205205
- 20-imap.conf
206+
- 90-acl.conf
206207
- auth-ldap.conf.ext
207208
tags:
208209
- role::dovecot

ansible/roles/dovecot/templates/configs/10-auth.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# matches the local IP (ie. you're connecting from the same computer), the
1010
# connection is considered secure and plaintext authentication is allowed.
1111
# See also ssl=required setting.
12-
disable_plaintext_auth = yes
12+
auth_allow_cleartext = no
1313

1414
# Authentication cache size (e.g. 10M). 0 means it's disabled. Note that
1515
# bsdauth and PAM require cache_key to be set for caching to be used.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# {{ ansible_managed }}
2+
3+
##
4+
## Director-specific settings.
5+
##
6+
7+
# Director can be used by Dovecot proxy to keep a temporary user -> mail server
8+
# mapping. As long as user has simultaneous connections, the user is always
9+
# redirected to the same server. Each proxy server is running its own director
10+
# process, and the directors are communicating the state to each others.
11+
# Directors are mainly useful with NFS-like setups.
12+
13+
# List of IPs or hostnames to all director servers, including ourself.
14+
# Ports can be specified as ip:port. The default port is the same as
15+
# what director service's inet_listener is using.
16+
#director_servers =
17+
18+
# List of IPs or hostnames to all backend mail servers. Ranges are allowed
19+
# too, like 10.0.0.10-10.0.0.30.
20+
#director_mail_servers =
21+
22+
# How long to redirect users to a specific server after it no longer has
23+
# any connections.
24+
#director_user_expire = 15 min
25+
26+
# How the username is translated before being hashed. Useful values include
27+
# %Ln if user can log in with or without @domain, %Ld if mailboxes are shared
28+
# within domain.
29+
#director_username_hash = %Lu
30+
31+
# To enable director service, uncomment the modes and assign a port.
32+
service director {
33+
unix_listener login/director {
34+
#mode = 0666
35+
}
36+
fifo_listener login/proxy-notify {
37+
#mode = 0666
38+
}
39+
unix_listener director-userdb {
40+
#mode = 0600
41+
}
42+
inet_listener schweinehund {
43+
#port =
44+
}
45+
}
46+
47+
# Enable director for the wanted login services by telling them to
48+
# connect to director socket instead of the default login socket:
49+
service imap-login {
50+
#executable = imap-login director
51+
}
52+
service pop3-login {
53+
#executable = pop3-login director
54+
}
55+
service submission-login {
56+
#executable = submission-login director
57+
}
58+
59+
# Enable director for LMTP proxying:
60+
protocol lmtp {
61+
#auth_socket_path = director-userdb
62+
}

ansible/roles/dovecot/templates/configs/10-mail.conf.j2

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
#
3030
# <doc/wiki/MailLocation.txt>
3131
#
32-
mail_home = /var/vmail/%u
33-
mail_location = maildir:~/mail
32+
mail_home = /var/vmail/%{user}
33+
mail_driver = Maildir
34+
mail_path = %{home}/mail
3435

3536

3637
# If you need to set multiple mailbox locations or want to change default
@@ -219,7 +220,10 @@ mail_privileged_group = mail
219220

220221
# Space separated list of plugins to load for all services. Plugins specific to
221222
# IMAP, LDA, etc. are added to this list in their own .conf files.
222-
mail_plugins = welcome notify
223+
mail_plugins {
224+
welcome = yes
225+
notify = yes
226+
}
223227

224228
##
225229
## Mailbox handling optimizations
@@ -424,9 +428,11 @@ protocol !indexer-worker {
424428
# exclude-inlined - Exclude any Content-Disposition=inline MIME part.
425429
#mail_attachment_detection_options =
426430

427-
plugin {
428-
welcome_script = welcome %u
429-
welcome_wait = no
431+
welcome {
432+
execute welcome {
433+
args = %{user}
434+
}
435+
wait = no
430436
}
431437

432438
service welcome {

ansible/roles/dovecot/templates/configs/10-ssl.conf.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ ssl = yes
1111
# dropping root privileges, so keep the key file unreadable by anyone but
1212
# root. Included doc/mkcert.sh can be used to easily generate self-signed
1313
# certificate, just make sure to update the domains in dovecot-openssl.cnf
14-
ssl_cert = </etc/letsencrypt/live/pydis.wtf/fullchain.pem
15-
ssl_key = </etc/letsencrypt/live/pydis.wtf/privkey.pem
14+
ssl_server_cert_file = /etc/letsencrypt/live/pydis.wtf/fullchain.pem
15+
ssl_server_key_file = /etc/letsencrypt/live/pydis.wtf/privkey.pem
1616

1717
# If key file is password protected, give the password here. Alternatively
1818
# give it when starting dovecot with -p parameter. Since this file is often
@@ -54,7 +54,7 @@ ssl_client_ca_dir = /etc/ssl/certs
5454
# Generate new params with `openssl dhparam -out /etc/dovecot/dh.pem 4096`
5555
# Or migrate from old ssl-parameters.dat file with the command dovecot
5656
# gives on startup when ssl_dh is unset.
57-
ssl_dh = </usr/share/dovecot/dh.pem
57+
ssl_server_dh_file = /usr/share/dovecot/dh.pem
5858

5959
# Minimum SSL protocol version to use. Potentially recognized values are SSLv3,
6060
# TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3, depending on the OpenSSL version used.

ansible/roles/dovecot/templates/configs/20-imap.conf.j2

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,17 @@
9191
# from going into infinite loops trying to FETCH a broken mail.
9292
#imap_fetch_failure = disconnect-immediately
9393
94-
mail_attribute_dict = file:~/mail/dovecot-attributes
94+
mail_attribute {
95+
dict file {
96+
path = %{home}/mail/dovecot-attributes
97+
}
98+
}
9599
96100
protocol imap {
97101
# Space separated list of plugins to load (default is global mail_plugins).
98-
mail_plugins = $mail_plugins imap_sieve
102+
mail_plugins {
103+
imap_sieve = yes
104+
}
99105
100106
imap_metadata = yes
101107

ansible/roles/dovecot/templates/configs/20-lmtp.conf.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ lmtp_add_received_header = yes
3838

3939
protocol lmtp {
4040
# Space separated list of plugins to load (default is global mail_plugins).
41-
mail_plugins = $mail_plugins sieve
41+
mail_plugins {
42+
sieve = yes
43+
}
4244
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# {{ ansible_managed }}
2+
3+
##
4+
## Mailbox access control lists.
5+
##
6+
7+
# vfile backend reads ACLs from "dovecot-acl" file from mail directory.
8+
# You can also optionally give a global ACL directory path where ACLs are
9+
# applied to all users' mailboxes. The global ACL directory contains
10+
# one file for each mailbox, eg. INBOX or sub.mailbox. cache_secs parameter
11+
# specifies how many seconds to wait between stat()ing dovecot-acl file
12+
# to see if it changed.
13+
#plugin {
14+
#acl = vfile:/etc/dovecot/global-acls:cache_secs=300
15+
#}
16+
17+
# To let users LIST mailboxes shared by other users, Dovecot needs a
18+
# shared mailbox dictionary. For example:
19+
#plugin {
20+
#acl_shared_dict = file:/var/lib/dovecot/shared-mailboxes
21+
#}

ansible/roles/dovecot/templates/configs/auth-ldap.conf.ext.j2

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,58 @@
44
#
55
# <doc/wiki/AuthDatabase.LDAP.txt>
66

7-
passdb {
8-
driver = ldap
7+
# This file is opened as root, so it should be owned by root and mode 0600.
8+
#
9+
ldap_uris = {{ dovecot_ldap_host }}
10+
11+
# Distinguished Name - the username used to login to the LDAP server.
12+
# Leave it commented out to bind anonymously (useful with auth_bind=yes).
13+
ldap_auth_dn = {{ dovecot_ldap_user }}
14+
15+
# Password for LDAP server, if dn is specified.
16+
ldap_auth_dn_password = {{ dovecot_ldap_password }}
17+
18+
# TLS options, currently supported only with OpenLDAP:
19+
ldap_tls_ca_cert_file = {{ dovecot_ldap_tls_ca }}
920

10-
# Path for LDAP configuration file, see example-config/dovecot-ldap.conf.ext
11-
args = /etc/dovecot/dovecot-ldap.conf.ext
12-
}
1321

14-
userdb {
15-
driver = prefetch
22+
# LDAP protocol version to use. Likely 2 or 3.
23+
ldap_version = 3
24+
25+
# LDAP base. %variables can be used here.
26+
# For example: dc=mail, dc=example, dc=org
27+
ldap_base = cn=users,cn=accounts,dc=box,dc=pydis,dc=wtf
28+
29+
# User attributes are given in LDAP-name=dovecot-internal-name list. The
30+
# internal names are:
31+
# uid - System UID
32+
# gid - System GID
33+
# home - Home directory
34+
# mail - Mail location
35+
#
36+
# There are also other special fields which can be returned, see
37+
# http://wiki2.dovecot.org/UserDatabase/ExtraFields
38+
ldap_user_attrs = uidNumber=uid, sieve=${home}/main.sieve, sieve_user_log=${home}/sieve.log
39+
40+
passdb ldap {
41+
fields {
42+
uidNumber = %{ldap:uid}
43+
sieve = ${home}/main.sieve
44+
sieve_user_log = ${home}/sieve.log
45+
}
46+
bind = yes
47+
bind_userdn = uid=%{user},cn=users,cn=accounts,dc=box,dc=pydis,dc=wtf
48+
49+
filter = (&(objectClass=posixAccount)(uid=%{user}))
50+
driver = ldap
1651
}
1752

18-
userdb {
53+
userdb ldap {
54+
fields {
55+
uidNumber = %{ldap:uid}
56+
sieve = ${home}/main.sieve
57+
sieve_user_log = ${home}/sieve.log
58+
}
59+
filter = (&(objectClass=posixAccount)(uid=%{user}))
1960
driver = ldap
20-
args = /etc/dovecot/dovecot-ldap.conf.ext
2161
}

ansible/roles/dovecot/templates/dovecot-ldap.conf.ext.j2

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)