Option to disable dovecot quota

This commit is contained in:
youtous 2020-05-01 23:42:21 +02:00
parent 46c50f93ad
commit 0c838706d0
No known key found for this signature in database
GPG key ID: 592173AE8CD254A5
3 changed files with 65 additions and 2 deletions

View file

@ -352,6 +352,14 @@ Set the mailbox size limit for all users. If set to zero, the size will be unlim
- **empty** => 0 (no limit)
##### ENABLE_QUOTAS
- **1** => Dovecot quota is enabled
- 0 => Dovecot quota is disabled
See [mailbox quota](https://github.com/tomav/docker-mailserver/wiki/Configure-Accounts#mailbox-quota).
##### POSTFIX\_MESSAGE\_SIZE\_LIMIT
Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!)

View file

@ -15,6 +15,7 @@ DEFAULT_VARS["ENABLE_MANAGESIEVE"]="${ENABLE_MANAGESIEVE:="0"}"
DEFAULT_VARS["ENABLE_FETCHMAIL"]="${ENABLE_FETCHMAIL:="0"}"
DEFAULT_VARS["FETCHMAIL_POLL"]="${FETCHMAIL_POLL:="300"}"
DEFAULT_VARS["ENABLE_LDAP"]="${ENABLE_LDAP:="0"}"
DEFAULT_VARS["ENABLE_QUOTAS"]="${ENABLE_QUOTAS:="1"}"
DEFAULT_VARS["LDAP_START_TLS"]="${LDAP_START_TLS:="no"}"
DEFAULT_VARS["DOVECOT_TLS"]="${DOVECOT_TLS:="no"}"
DEFAULT_VARS["DOVECOT_MAILBOX_FORMAT"]="${DOVECOT_MAILBOX_FORMAT:="maildir"}"
@ -634,8 +635,8 @@ function _setup_dovecot() {
function _setup_dovecot_quota() {
notify 'task' 'Setting up Dovecot quota'
if [ "$ENABLE_LDAP" = 1 ] || [ "$SMTP_ONLY" = 1 ]; then
# Dovecot quota is disabled when using LDAP or SMTP_ONLY
if [ "$ENABLE_LDAP" = 1 ] || [ "$SMTP_ONLY" = 1 ] || [ "$ENABLE_QUOTAS" = 0 ]; then
# Dovecot quota is disabled when using LDAP or SMTP_ONLY or when explicitly disabled
# disable dovecot quota in docevot confs
if [ -f /etc/dovecot/conf.d/90-quota.conf ]; then

View file

@ -0,0 +1,54 @@
load 'test_helper/common'
# Test case
# ---------
# When ENABLE_QUOTAS is explicitly disabled (ENABLE_QUOTAS=0), dovecot quota must not be enabled.
function setup() {
run_setup_file_if_necessary
}
function teardown() {
run_teardown_file_if_necessary
}
function setup_file() {
docker run -d --name mail_no_quotas \
-v "`pwd`/test/config":/tmp/docker-mailserver \
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
-e DMS_DEBUG=0 \
-e ENABLE_QUOTAS=0 \
-h mail.my-domain.com -t "${NAME}"
wait_for_finished_setup_in_container mail_no_quotas
}
function teardown_file() {
docker rm -f mail_no_quotas
}
@test "first" {
skip 'this test must come first to reliably identify when to run setup_file'
}
@test "checking dovecot: (ENABLE_QUOTAS=0) quota plugin is disabled" {
run docker exec mail_no_quotas /bin/sh -c "grep '\$mail_plugins quota' /etc/dovecot/conf.d/10-mail.conf"
assert_failure
run docker exec mail_no_quotas /bin/sh -c "grep '\$mail_plugins imap_quota' /etc/dovecot/conf.d/20-imap.conf"
assert_failure
run docker exec mail_no_quotas ls /etc/dovecot/conf.d/90-quota.conf
assert_failure
run docker exec mail_no_quotas ls /etc/dovecot/conf.d/90-quota.conf.disab
assert_success
}
@test "checking postfix: (ENABLE_QUOTAS=0) dovecot quota absent in postconf" {
run docker exec mail_no_quotas /bin/bash -c "postconf | grep 'check_policy_service inet:localhost:65265'"
assert_failure
}
@test "last" {
skip 'this test is only there to reliably mark the end for the teardown_file'
}