From 6cf2efb974d060f4804117a55c569e7e4ea64192 Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Mon, 2 Sep 2024 15:09:15 -0600 Subject: [PATCH] Moved postfix to use the emailprimary attribute instead of mail --- .../roles/mail/templates/user-patches.sh.j2 | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/playbooks/roles/mail/templates/user-patches.sh.j2 b/playbooks/roles/mail/templates/user-patches.sh.j2 index 6845563..63b464a 100644 --- a/playbooks/roles/mail/templates/user-patches.sh.j2 +++ b/playbooks/roles/mail/templates/user-patches.sh.j2 @@ -5,9 +5,22 @@ postconf -e 'smtpd_sasl_path = /dev/shm/sasl-auth.sock' postconf -e 'smtpd_sasl_auth_enable = yes' postconf -e 'broken_sasl_auth_clients = yes' -echo 'auth_username_format = %Ln' >> /etc/dovecot/conf.d/10-auth.conf +# 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 -echo 'username_format = %Ln' >> /etc/dovecot/dovecot-oauth2.conf.ext +echo 'auth_username_format = %Ln' >>/etc/dovecot/conf.d/10-auth.conf + +echo 'username_format = %Ln' >>/etc/dovecot/dovecot-oauth2.conf.ext echo "passdb { driver = ldap @@ -17,4 +30,4 @@ echo "passdb { userdb { driver = static args = uid=5000 gid=5000 home=/var/mail/%u -}" > /etc/dovecot/conf.d/auth-ldap.conf.ext +}" >/etc/dovecot/conf.d/auth-ldap.conf.ext -- 2.40.1