Add postfixadmin_permit_localpart_login

This commit is contained in:
s3lph 2022-02-19 13:43:59 +01:00
parent 68d971f20f
commit 29db5b9c1e
3 changed files with 14 additions and 5 deletions
galaxy.yml
roles/postfixadmin
defaults
templates/etc/dovecot

View file

@ -8,7 +8,7 @@ namespace: s3lph
name: mailserver
# The version of the collection. Must be compatible with semantic versioning
version: '0.2.2'
version: '0.2.3'
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md

View file

@ -85,7 +85,11 @@ postfixadmin_database_postfix_user: postfix
postfixadmin_database_postfix_hosts: 'unix:/run/mysqld/mysqld.sock'
postfixadmin_database_dovecot_user: postfix
postfixadmin_database_dovecot_hosts: '/run/mysqld/mysqld.sock'
# This permits disabled users to still read their mail, but will not allow them to send mail.
postfixadmin_permit_inactive_user_nosmtp: no
# allow login as <user> in addition to <user>@<domain>
# Only set this when when you're only serving a single domain or can otherwise avoid conflicts
postfixadmin_permit_localpart_login: no
postfixadmin_additional_config: ''

View file

@ -3,12 +3,17 @@
driver = mysql
connect = host={{ postfixadmin_database_dovecot_hosts }} dbname={{ postfixadmin_database_name }} user={{ postfixadmin_database_dovecot_user }} password={{ postfixadmin_database_dovecot_password }}
default_pass_scheme = BLF-CRYPT
{% if postfixadmin_permit_localpart_login %}
{% set user_filter = "local_part = '%n'" %}
{% else %}
{% set user_filter = "username = '%u'" %}
{% endif %}
{% if postfixadmin_permit_inactive_user_nosmtp %}
# '%s'<>'smtp' permits login for inactive users, but only if the service is NOT smtp.
# This permits disabled users to still read their mail, but will not allow them to send mail.
password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND ( active='1' OR '%s'<>'smtp' )
user_query = SELECT CONCAT('{{ virtual_mail_home }}', maildir) AS home, {{ virtual_mail_numeric_uid }} AS uid, {{ virtual_mail_numeric_gid }} AS gid, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND ( active='1' OR '%s'<>'smtp' )
password_query = SELECT username AS user,password FROM mailbox WHERE {{ user_filter }} AND ( active='1' OR '%s'<>'smtp' )
user_query = SELECT CONCAT('{{ virtual_mail_home }}', maildir) AS home, {{ virtual_mail_numeric_uid }} AS uid, {{ virtual_mail_numeric_gid }} AS gid, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE {{ user_filter }} AND ( active='1' OR '%s'<>'smtp' )
{% else %}
password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1'
user_query = SELECT CONCAT('{{ virtual_mail_home }}', maildir) AS home, {{ virtual_mail_numeric_uid }} AS uid, {{ virtual_mail_numeric_gid }} AS gid, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active='1'
password_query = SELECT username AS user,password FROM mailbox WHERE {{ user_filter }} AND active='1'
user_query = SELECT CONCAT('{{ virtual_mail_home }}', maildir) AS home, {{ virtual_mail_numeric_uid }} AS uid, {{ virtual_mail_numeric_gid }} AS gid, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox {{ user_filter }} AND active='1'
{% endif %}