diff --git a/galaxy.yml b/galaxy.yml index e29d5ea..1c32ac0 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -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 diff --git a/roles/postfixadmin/defaults/main.yml b/roles/postfixadmin/defaults/main.yml index 8be32fe..e962841 100644 --- a/roles/postfixadmin/defaults/main.yml +++ b/roles/postfixadmin/defaults/main.yml @@ -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: '' diff --git a/roles/postfixadmin/templates/etc/dovecot/dovecot-sql.conf.j2 b/roles/postfixadmin/templates/etc/dovecot/dovecot-sql.conf.j2 index 1dfb057..7ad8459 100644 --- a/roles/postfixadmin/templates/etc/dovecot/dovecot-sql.conf.j2 +++ b/roles/postfixadmin/templates/etc/dovecot/dovecot-sql.conf.j2 @@ -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 %} \ No newline at end of file