blob: 34ecd51d29fc77dafe642f9a939725021f6d01bb (
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
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/bash
postconf -e 'smtpd_sasl_type = dovecot'
postconf -e 'smtpd_sasl_path = /dev/shm/sasl-auth.sock'
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'broken_sasl_auth_clients = no'
postconf -e 'smtpd_tls_auth_only = yes'
postconf -e 'smtpd_tls_security_level = encrypt'
postconf -e 'postscreen_bare_newline_enable = no'
postconf -e 'postscreen_non_smtp_command_enable = no'
postconf -e 'postscreen_pipelining_enable = no'
postconf -e 'smtp_tls_wrappermode = yes' # for relay
# This is necessary for any users with multiple email addresses. Kanidm stores all email addresses in
# the mail attribute, which means that postfix clones emails to all addresses. Since dovecot only
# has a mailbox for the primary email address, the other addresses will bounce, and the sender
# will receive a bounce message. Kanidm provides the "primary" (first) email address in the
# emailprimary attribute, so we use that instead.
#
# We don't change the ldap-sender.cf or ldap-groups.cf files because we want people to be able to
# send mail from any of their email addresses, not just the primary one, and we want email to
# groups to be delivered regardless of which email it arrives at.
sed -i 's/result_attribute = mail/result_attribute = emailprimary/' /etc/postfix/ldap-aliases.cf
sed -i 's/result_attribute = mail/result_attribute = emailprimary/' /etc/postfix/ldap-domains.cf
sed -i 's/result_attribute = mail/result_attribute = emailprimary/' /etc/postfix/ldap-users.cf
# recursively search for members in groups
postconf -e 'recursion_limit = 15'
grep -q '^leaf_result_attribute = mail$' /etc/postfix/ldap-groups.cf || echo "leaf_result_attribute = mail" >> /etc/postfix/ldap-groups.cf
grep -q '^special_result_attribute = member$' /etc/postfix/ldap-groups.cf || echo "special_result_attribute = member" >> /etc/postfix/ldap-groups.cf
echo "ssl = required
auth_username_format = %Ln
# use oauth2 before ldap to prevent bind throttling
auth_mechanisms = xoauth2 oauthbearer plain login
!include auth-oauth2.conf.ext
!include auth-ldap.conf.ext" > /etc/dovecot/conf.d/10-auth.conf
echo 'username_format = %Ln' >> /etc/dovecot/dovecot-oauth2.conf.ext
echo "passdb {
driver = ldap
args = /etc/dovecot/dovecot-ldap.conf.ext
}
userdb {
driver = static
args = username_format=%u uid=5000 gid=5000 home=/var/mail/%u
default_fields = uid=5000 gid=5000 home=/var/mail/%u
}" > /etc/dovecot/conf.d/auth-ldap.conf.ext
postconf -e 'virtual_uid_maps = static:5000'
postconf -e 'virtual_gid_maps = static:5000'
postconf -e 'virtual_minimum_uid = 5000'
chown -R 5000:5000 /var/mail/*
|