Merge branch 'master' into ci/lint-ignore-contributors-workflow
This commit is contained in:
commit
f86f6d2e7d
|
@ -25,7 +25,7 @@ jobs:
|
||||||
|
|
||||||
# The official Github Action for downloading artifacts does not support multi-workflow
|
# The official Github Action for downloading artifacts does not support multi-workflow
|
||||||
- name: 'Download build artifact'
|
- name: 'Download build artifact'
|
||||||
uses: dawidd6/action-download-artifact@v2
|
uses: dawidd6/action-download-artifact@v3
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run_id: ${{ github.event.workflow_run.id }}
|
run_id: ${{ github.event.workflow_run.id }}
|
||||||
|
|
|
@ -73,7 +73,7 @@ jobs:
|
||||||
tar --zstd -cf artifact.tar.zst pr.env ${{ env.BUILD_DIR }}
|
tar --zstd -cf artifact.tar.zst pr.env ${{ env.BUILD_DIR }}
|
||||||
|
|
||||||
- name: 'Upload artifact for workflow transfer'
|
- name: 'Upload artifact for workflow transfer'
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: preview-build
|
name: preview-build
|
||||||
path: artifact.tar.zst
|
path: artifact.tar.zst
|
||||||
|
|
|
@ -23,7 +23,7 @@ jobs:
|
||||||
|
|
||||||
- name: 'Prepare tags'
|
- name: 'Prepare tags'
|
||||||
id: prep
|
id: prep
|
||||||
uses: docker/metadata-action@v5.3.0
|
uses: docker/metadata-action@v5.4.0
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ secrets.DOCKER_REPOSITORY }}
|
${{ secrets.DOCKER_REPOSITORY }}
|
||||||
|
|
|
@ -62,6 +62,6 @@ jobs:
|
||||||
fail-build: false
|
fail-build: false
|
||||||
|
|
||||||
- name: 'Upload vulnerability report'
|
- name: 'Upload vulnerability report'
|
||||||
uses: github/codeql-action/upload-sarif@v2
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
with:
|
with:
|
||||||
sarif_file: ${{ steps.scan.outputs.sarif }}
|
sarif_file: ${{ steps.scan.outputs.sarif }}
|
||||||
|
|
|
@ -8,9 +8,12 @@ All notable changes to this project will be documented in this file. The format
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- **Dovecot:**
|
||||||
|
- ENV `ENABLE_IMAP` ([#3703](https://github.com/docker-mailserver/docker-mailserver/pull/3703))
|
||||||
- **Tests:**
|
- **Tests:**
|
||||||
- You can now use `make run-local-instance` to run a DMS image that was built locally to test changes ([#3663](https://github.com/docker-mailserver/docker-mailserver/pull/3663))
|
- You can now use `make run-local-instance` to run a DMS image that was built locally to test changes ([#3663](https://github.com/docker-mailserver/docker-mailserver/pull/3663))
|
||||||
- Log a warning when update-check is enabled, but no stable release image is used ([#3684](https://github.com/docker-mailserver/docker-mailserver/pull/3684))
|
- **Internal**:
|
||||||
|
- Log a warning when update-check is enabled, but no stable release image is used ([#3684](https://github.com/docker-mailserver/docker-mailserver/pull/3684))
|
||||||
|
|
||||||
### Updates
|
### Updates
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,14 @@ Enabled `policyd-spf` in Postfix's configuration. You will likely want to set th
|
||||||
|
|
||||||
##### ENABLE_POP3
|
##### ENABLE_POP3
|
||||||
|
|
||||||
- **empty** => POP3 service disabled
|
- **0** => POP3 service disabled
|
||||||
- 1 => Enables POP3 service
|
- 1 => Enables POP3 service
|
||||||
|
|
||||||
|
##### ENABLE_IMAP
|
||||||
|
|
||||||
|
- 0 => Disabled
|
||||||
|
- **1** => Enabled
|
||||||
|
|
||||||
##### ENABLE_CLAMAV
|
##### ENABLE_CLAMAV
|
||||||
|
|
||||||
- **0** => ClamAV is disabled
|
- **0** => ClamAV is disabled
|
||||||
|
@ -223,9 +228,9 @@ Provide any valid URI. Examples:
|
||||||
- `lmtps:inet:<host>:<port>` (secure lmtp with starttls)
|
- `lmtps:inet:<host>:<port>` (secure lmtp with starttls)
|
||||||
- `lmtp:<kopano-host>:2003` (use kopano as mailstore)
|
- `lmtp:<kopano-host>:2003` (use kopano as mailstore)
|
||||||
|
|
||||||
##### POSTFIX\_MAILBOX\_SIZE\_LIMIT
|
##### POSTFIX_MAILBOX_SIZE_LIMIT
|
||||||
|
|
||||||
Set the mailbox size limit for all users. If set to zero, the size will be unlimited (default).
|
Set the mailbox size limit for all users. If set to zero, the size will be unlimited (default). Size is in bytes.
|
||||||
|
|
||||||
- **empty** => 0 (no limit)
|
- **empty** => 0 (no limit)
|
||||||
|
|
||||||
|
@ -236,9 +241,9 @@ Set the mailbox size limit for all users. If set to zero, the size will be unlim
|
||||||
|
|
||||||
See [mailbox quota][docs-accounts-quota].
|
See [mailbox quota][docs-accounts-quota].
|
||||||
|
|
||||||
##### POSTFIX\_MESSAGE\_SIZE\_LIMIT
|
##### POSTFIX_MESSAGE_SIZE_LIMIT
|
||||||
|
|
||||||
Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!)
|
Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!). Size is in bytes.
|
||||||
|
|
||||||
- **empty** => 10240000 (~10 MB)
|
- **empty** => 10240000 (~10 MB)
|
||||||
|
|
||||||
|
|
|
@ -119,10 +119,16 @@ ENABLE_OPENDMARC=1
|
||||||
# - **1** => Enabled
|
# - **1** => Enabled
|
||||||
ENABLE_POLICYD_SPF=1
|
ENABLE_POLICYD_SPF=1
|
||||||
|
|
||||||
# 1 => Enables POP3 service
|
# Enables POP3 service
|
||||||
# empty => disables POP3
|
# - **0** => Disabled
|
||||||
|
# - 1 => Enabled
|
||||||
ENABLE_POP3=
|
ENABLE_POP3=
|
||||||
|
|
||||||
|
# Enables IMAP service
|
||||||
|
# - 0 => Disabled
|
||||||
|
# - **1** => Enabled
|
||||||
|
ENABLE_IMAP=1
|
||||||
|
|
||||||
# Enables ClamAV, and anti-virus scanner.
|
# Enables ClamAV, and anti-virus scanner.
|
||||||
# 1 => Enabled
|
# 1 => Enabled
|
||||||
# **0** => Disabled
|
# **0** => Disabled
|
||||||
|
@ -248,7 +254,7 @@ VIRUSMAILS_DELETE_DELAY=
|
||||||
# `lmtp:<kopano-host>:2003` (use kopano as mailstore)
|
# `lmtp:<kopano-host>:2003` (use kopano as mailstore)
|
||||||
POSTFIX_DAGENT=
|
POSTFIX_DAGENT=
|
||||||
|
|
||||||
# Set the mailbox size limit for all users. If set to zero, the size will be unlimited (default).
|
# Set the mailbox size limit for all users. If set to zero, the size will be unlimited (default). Size is in bytes.
|
||||||
#
|
#
|
||||||
# empty => 0
|
# empty => 0
|
||||||
POSTFIX_MAILBOX_SIZE_LIMIT=
|
POSTFIX_MAILBOX_SIZE_LIMIT=
|
||||||
|
@ -258,7 +264,7 @@ POSTFIX_MAILBOX_SIZE_LIMIT=
|
||||||
# 1 => Dovecot quota is enabled
|
# 1 => Dovecot quota is enabled
|
||||||
ENABLE_QUOTAS=1
|
ENABLE_QUOTAS=1
|
||||||
|
|
||||||
# Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!)
|
# Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!). Size is in bytes.
|
||||||
#
|
#
|
||||||
# empty => 10240000 (~10 MB)
|
# empty => 10240000 (~10 MB)
|
||||||
POSTFIX_MESSAGE_SIZE_LIMIT=
|
POSTFIX_MESSAGE_SIZE_LIMIT=
|
||||||
|
|
|
@ -59,10 +59,14 @@ function _quota_request_if_missing() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Dovecot docs incorrectly refer to these units with names for SI types (base 10),
|
||||||
|
# But then mentions they're actually treated as IEC type (base 2):
|
||||||
|
# https://doc.dovecot.org/settings/types/#size
|
||||||
function _quota_unit_is_valid() {
|
function _quota_unit_is_valid() {
|
||||||
if ! grep -qE "^([0-9]+(B|k|M|G|T)|0)\$" <<< "${QUOTA}"; then
|
if ! grep -qE "^([0-9]+(B|k|M|G|T)|0)\$" <<< "${QUOTA}"; then
|
||||||
__usage
|
__usage
|
||||||
_exit_with_error 'Invalid quota format. e.g. 302M (B (byte), k (kilobyte), M (megabyte), G (gigabyte) or T (terabyte))'
|
_exit_with_error 'Invalid quota format. e.g. 302M (B (byte), k (kibibyte), M (mebibyte), G (gibibyte) or T (tebibyte))'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,10 @@ function _setup_dovecot() {
|
||||||
cp -a /usr/share/dovecot/protocols.d /etc/dovecot/
|
cp -a /usr/share/dovecot/protocols.d /etc/dovecot/
|
||||||
# disable pop3 (it will be eventually enabled later in the script, if requested)
|
# disable pop3 (it will be eventually enabled later in the script, if requested)
|
||||||
mv /etc/dovecot/protocols.d/pop3d.protocol /etc/dovecot/protocols.d/pop3d.protocol.disab
|
mv /etc/dovecot/protocols.d/pop3d.protocol /etc/dovecot/protocols.d/pop3d.protocol.disab
|
||||||
|
# disable imap (it will be eventually enabled later in the script, if requested)
|
||||||
|
mv /etc/dovecot/protocols.d/imapd.protocol /etc/dovecot/protocols.d/imapd.protocol.disab
|
||||||
mv /etc/dovecot/protocols.d/managesieved.protocol /etc/dovecot/protocols.d/managesieved.protocol.disab
|
mv /etc/dovecot/protocols.d/managesieved.protocol /etc/dovecot/protocols.d/managesieved.protocol.disab
|
||||||
sed -i -e 's|#ssl = yes|ssl = yes|g' /etc/dovecot/conf.d/10-master.conf
|
sedfile -i 's|^postmaster_address = .*$|postmaster_address = '"${POSTMASTER_ADDRESS}"'|g' /etc/dovecot/conf.d/15-lda.conf
|
||||||
sed -i -e 's|#port = 993|port = 993|g' /etc/dovecot/conf.d/10-master.conf
|
|
||||||
sed -i -e 's|#port = 995|port = 995|g' /etc/dovecot/conf.d/10-master.conf
|
|
||||||
sed -i -e 's|#ssl = yes|ssl = required|g' /etc/dovecot/conf.d/10-ssl.conf
|
|
||||||
sed -i 's|^postmaster_address = .*$|postmaster_address = '"${POSTMASTER_ADDRESS}"'|g' /etc/dovecot/conf.d/15-lda.conf
|
|
||||||
|
|
||||||
if ! grep -q -E '^stats_writer_socket_path=' /etc/dovecot/dovecot.conf; then
|
if ! grep -q -E '^stats_writer_socket_path=' /etc/dovecot/dovecot.conf; then
|
||||||
printf '\n%s\n' 'stats_writer_socket_path=' >>/etc/dovecot/dovecot.conf
|
printf '\n%s\n' 'stats_writer_socket_path=' >>/etc/dovecot/dovecot.conf
|
||||||
|
@ -37,9 +35,21 @@ function _setup_dovecot() {
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ ${ENABLE_POP3} -eq 1 || ${ENABLE_IMAP} -eq 1 ]]; then
|
||||||
|
sedfile -i -e 's|#ssl = yes|ssl = yes|g' /etc/dovecot/conf.d/10-master.conf
|
||||||
|
sedfile -i -e 's|#ssl = yes|ssl = required|g' /etc/dovecot/conf.d/10-ssl.conf
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ${ENABLE_POP3} -eq 1 ]]; then
|
if [[ ${ENABLE_POP3} -eq 1 ]]; then
|
||||||
_log 'debug' 'Enabling POP3 services'
|
_log 'debug' 'Enabling POP3 services'
|
||||||
mv /etc/dovecot/protocols.d/pop3d.protocol.disab /etc/dovecot/protocols.d/pop3d.protocol
|
mv /etc/dovecot/protocols.d/pop3d.protocol.disab /etc/dovecot/protocols.d/pop3d.protocol
|
||||||
|
sedfile -i -e 's|#port = 995|port = 995|g' /etc/dovecot/conf.d/10-master.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${ENABLE_IMAP} -eq 1 ]]; then
|
||||||
|
_log 'debug' 'Enabling IMAP services'
|
||||||
|
mv /etc/dovecot/protocols.d/imapd.protocol.disab /etc/dovecot/protocols.d/imapd.protocol
|
||||||
|
sedfile -i -e 's|#port = 993|port = 993|g' /etc/dovecot/conf.d/10-master.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -f /tmp/docker-mailserver/dovecot.cf ]] && cp /tmp/docker-mailserver/dovecot.cf /etc/dovecot/local.conf
|
[[ -f /tmp/docker-mailserver/dovecot.cf ]] && cp /tmp/docker-mailserver/dovecot.cf /etc/dovecot/local.conf
|
||||||
|
@ -89,23 +99,23 @@ function _setup_dovecot_quota() {
|
||||||
# disable dovecot quota in docevot confs
|
# disable dovecot quota in docevot confs
|
||||||
if [[ -f /etc/dovecot/conf.d/90-quota.conf ]]; then
|
if [[ -f /etc/dovecot/conf.d/90-quota.conf ]]; then
|
||||||
mv /etc/dovecot/conf.d/90-quota.conf /etc/dovecot/conf.d/90-quota.conf.disab
|
mv /etc/dovecot/conf.d/90-quota.conf /etc/dovecot/conf.d/90-quota.conf.disab
|
||||||
sed -i \
|
sedfile -i \
|
||||||
"s|mail_plugins = \$mail_plugins quota|mail_plugins = \$mail_plugins|g" \
|
"s|mail_plugins = \$mail_plugins quota|mail_plugins = \$mail_plugins|g" \
|
||||||
/etc/dovecot/conf.d/10-mail.conf
|
/etc/dovecot/conf.d/10-mail.conf
|
||||||
sed -i \
|
sedfile -i \
|
||||||
"s|mail_plugins = \$mail_plugins imap_quota|mail_plugins = \$mail_plugins|g" \
|
"s|mail_plugins = \$mail_plugins imap_quota|mail_plugins = \$mail_plugins|g" \
|
||||||
/etc/dovecot/conf.d/20-imap.conf
|
/etc/dovecot/conf.d/20-imap.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# disable quota policy check in postfix
|
# disable quota policy check in postfix
|
||||||
sed -i "s|check_policy_service inet:localhost:65265||g" /etc/postfix/main.cf
|
sedfile -i "s|check_policy_service inet:localhost:65265||g" /etc/postfix/main.cf
|
||||||
else
|
else
|
||||||
if [[ -f /etc/dovecot/conf.d/90-quota.conf.disab ]]; then
|
if [[ -f /etc/dovecot/conf.d/90-quota.conf.disab ]]; then
|
||||||
mv /etc/dovecot/conf.d/90-quota.conf.disab /etc/dovecot/conf.d/90-quota.conf
|
mv /etc/dovecot/conf.d/90-quota.conf.disab /etc/dovecot/conf.d/90-quota.conf
|
||||||
sed -i \
|
sedfile -i \
|
||||||
"s|mail_plugins = \$mail_plugins|mail_plugins = \$mail_plugins quota|g" \
|
"s|mail_plugins = \$mail_plugins|mail_plugins = \$mail_plugins quota|g" \
|
||||||
/etc/dovecot/conf.d/10-mail.conf
|
/etc/dovecot/conf.d/10-mail.conf
|
||||||
sed -i \
|
sedfile -i \
|
||||||
"s|mail_plugins = \$mail_plugins|mail_plugins = \$mail_plugins imap_quota|g" \
|
"s|mail_plugins = \$mail_plugins|mail_plugins = \$mail_plugins imap_quota|g" \
|
||||||
/etc/dovecot/conf.d/20-imap.conf
|
/etc/dovecot/conf.d/20-imap.conf
|
||||||
fi
|
fi
|
||||||
|
@ -113,11 +123,11 @@ function _setup_dovecot_quota() {
|
||||||
local MESSAGE_SIZE_LIMIT_MB=$((POSTFIX_MESSAGE_SIZE_LIMIT / 1000000))
|
local MESSAGE_SIZE_LIMIT_MB=$((POSTFIX_MESSAGE_SIZE_LIMIT / 1000000))
|
||||||
local MAILBOX_LIMIT_MB=$((POSTFIX_MAILBOX_SIZE_LIMIT / 1000000))
|
local MAILBOX_LIMIT_MB=$((POSTFIX_MAILBOX_SIZE_LIMIT / 1000000))
|
||||||
|
|
||||||
sed -i \
|
sedfile -i \
|
||||||
"s|quota_max_mail_size =.*|quota_max_mail_size = ${MESSAGE_SIZE_LIMIT_MB}$([[ ${MESSAGE_SIZE_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
"s|quota_max_mail_size =.*|quota_max_mail_size = ${MESSAGE_SIZE_LIMIT_MB}$([[ ${MESSAGE_SIZE_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
||||||
/etc/dovecot/conf.d/90-quota.conf
|
/etc/dovecot/conf.d/90-quota.conf
|
||||||
|
|
||||||
sed -i \
|
sedfile -i \
|
||||||
"s|quota_rule = \*:storage=.*|quota_rule = *:storage=${MAILBOX_LIMIT_MB}$([[ ${MAILBOX_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
"s|quota_rule = \*:storage=.*|quota_rule = *:storage=${MAILBOX_LIMIT_MB}$([[ ${MAILBOX_LIMIT_MB} -eq 0 ]] && echo "" || echo "M")|g" \
|
||||||
/etc/dovecot/conf.d/90-quota.conf
|
/etc/dovecot/conf.d/90-quota.conf
|
||||||
|
|
||||||
|
@ -127,7 +137,7 @@ function _setup_dovecot_quota() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# enable quota policy check in postfix
|
# enable quota policy check in postfix
|
||||||
sed -i -E \
|
sedfile -i -E \
|
||||||
"s|(reject_unknown_recipient_domain)|\1, check_policy_service inet:localhost:65265|g" \
|
"s|(reject_unknown_recipient_domain)|\1, check_policy_service inet:localhost:65265|g" \
|
||||||
/etc/postfix/main.cf
|
/etc/postfix/main.cf
|
||||||
fi
|
fi
|
||||||
|
@ -188,5 +198,5 @@ function _setup_dovecot_dhparam() {
|
||||||
|
|
||||||
function _setup_dovecot_hostname() {
|
function _setup_dovecot_hostname() {
|
||||||
_log 'debug' 'Applying hostname to Dovecot'
|
_log 'debug' 'Applying hostname to Dovecot'
|
||||||
sed -i "s|^#hostname =.*$|hostname = '${HOSTNAME}'|g" /etc/dovecot/conf.d/15-lda.conf
|
sedfile -i "s|^#hostname =.*$|hostname = '${HOSTNAME}'|g" /etc/dovecot/conf.d/15-lda.conf
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ function __environment_variables_general_setup() {
|
||||||
VARS[ENABLE_OPENDMARC]="${ENABLE_OPENDMARC:=1}"
|
VARS[ENABLE_OPENDMARC]="${ENABLE_OPENDMARC:=1}"
|
||||||
VARS[ENABLE_POLICYD_SPF]="${ENABLE_POLICYD_SPF:=1}"
|
VARS[ENABLE_POLICYD_SPF]="${ENABLE_POLICYD_SPF:=1}"
|
||||||
VARS[ENABLE_POP3]="${ENABLE_POP3:=0}"
|
VARS[ENABLE_POP3]="${ENABLE_POP3:=0}"
|
||||||
|
VARS[ENABLE_IMAP]="${ENABLE_IMAP:=1}"
|
||||||
VARS[ENABLE_POSTGREY]="${ENABLE_POSTGREY:=0}"
|
VARS[ENABLE_POSTGREY]="${ENABLE_POSTGREY:=0}"
|
||||||
VARS[ENABLE_QUOTAS]="${ENABLE_QUOTAS:=1}"
|
VARS[ENABLE_QUOTAS]="${ENABLE_QUOTAS:=1}"
|
||||||
VARS[ENABLE_RSPAMD]="${ENABLE_RSPAMD:=0}"
|
VARS[ENABLE_RSPAMD]="${ENABLE_RSPAMD:=0}"
|
||||||
|
|
|
@ -0,0 +1,246 @@
|
||||||
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||||
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||||
|
|
||||||
|
# upstream default: 10 240 000
|
||||||
|
# https://www.postfix.org/postconf.5.html#message_size_limit
|
||||||
|
# > The maximal size in bytes of a message, including envelope information.
|
||||||
|
# > The value cannot exceed LONG_MAX (typically, a 32-bit or 64-bit signed integer).
|
||||||
|
# > Note: Be careful when making changes. Excessively small values will result in the loss of non-delivery notifications, when a bounce message size exceeds the local or remote MTA's message size limit.
|
||||||
|
|
||||||
|
# upstream default: 51 200 000
|
||||||
|
# https://www.postfix.org/postconf.5.html#mailbox_size_limit
|
||||||
|
# > The maximal size of any local(8) individual mailbox or maildir file, or zero (no limit).
|
||||||
|
# > In fact, this limits the size of any file that is written to upon local delivery, including files written by external commands that are executed by the local(8) delivery agent.
|
||||||
|
# > The value cannot exceed LONG_MAX (typically, a 32-bit or 64-bit signed integer).
|
||||||
|
# > This limit must not be smaller than the message size limit.
|
||||||
|
|
||||||
|
# upstream default: 51 200 000
|
||||||
|
# https://www.postfix.org/postconf.5.html#virtual_mailbox_limit
|
||||||
|
# > The maximal size in bytes of an individual virtual(8) mailbox or maildir file, or zero (no limit).
|
||||||
|
# > This parameter is specific to the virtual(8) delivery agent.
|
||||||
|
# > It does not apply when mail is delivered with a different mail delivery program.
|
||||||
|
|
||||||
|
BATS_TEST_NAME_PREFIX='[Dovecot Quotas] '
|
||||||
|
CONTAINER_NAME='dms-test_dovecot-quotas'
|
||||||
|
|
||||||
|
function setup_file() {
|
||||||
|
_init_with_defaults
|
||||||
|
|
||||||
|
local CONTAINER_ARGS_ENV_CUSTOM=(
|
||||||
|
--env ENABLE_QUOTAS=1
|
||||||
|
--env POSTFIX_MAILBOX_SIZE_LIMIT=4096000
|
||||||
|
--env POSTFIX_MESSAGE_SIZE_LIMIT=2048000
|
||||||
|
--env PERMIT_DOCKER=container
|
||||||
|
)
|
||||||
|
_common_container_setup 'CONTAINER_ARGS_ENV_CUSTOM'
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardown_file() { _default_teardown ; }
|
||||||
|
|
||||||
|
@test 'should only support setting quota for a valid account' {
|
||||||
|
# Prepare
|
||||||
|
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
||||||
|
|
||||||
|
# Actual tests
|
||||||
|
_run_in_container setup quota set quota_user 50M
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
_run_in_container setup quota set username@fulldomain 50M
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 50M
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
_run_in_container setup email del -y quota_user@domain.tld
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'should only allow valid units as quota size' {
|
||||||
|
# Prepare
|
||||||
|
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
||||||
|
|
||||||
|
# Actual tests
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 26GIGOTS
|
||||||
|
assert_failure
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 123
|
||||||
|
assert_failure
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld M
|
||||||
|
assert_failure
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld -60M
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 10B
|
||||||
|
assert_success
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 10k
|
||||||
|
assert_success
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 10M
|
||||||
|
assert_success
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 10G
|
||||||
|
assert_success
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 10T
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
_run_in_container setup email del -y quota_user@domain.tld
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'should only support removing quota from a valid account' {
|
||||||
|
# Prepare
|
||||||
|
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
||||||
|
|
||||||
|
# Actual tests
|
||||||
|
_run_in_container setup quota del uota_user@domain.tld
|
||||||
|
assert_failure
|
||||||
|
_run_in_container setup quota del quota_user
|
||||||
|
assert_failure
|
||||||
|
_run_in_container setup quota del dontknowyou@domain.tld
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
_run_in_container setup quota set quota_user@domain.tld 10T
|
||||||
|
assert_success
|
||||||
|
_run_in_container setup quota del quota_user@domain.tld
|
||||||
|
assert_success
|
||||||
|
_run_in_container grep -i 'quota_user@domain.tld' /tmp/docker-mailserver/dovecot-quotas.cf
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
_run_in_container setup email del -y quota_user@domain.tld
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'should not error when there is no quota to remove for an account' {
|
||||||
|
# Prepare
|
||||||
|
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
||||||
|
|
||||||
|
# Actual tests
|
||||||
|
_run_in_container grep -i 'quota_user@domain.tld' /tmp/docker-mailserver/dovecot-quotas.cf
|
||||||
|
assert_failure
|
||||||
|
|
||||||
|
_run_in_container setup quota del quota_user@domain.tld
|
||||||
|
assert_success
|
||||||
|
_run_in_container setup quota del quota_user@domain.tld
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
_run_in_container setup email del -y quota_user@domain.tld
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'should have configured Postfix to use the Dovecot quota-status service' {
|
||||||
|
_run_in_container postconf
|
||||||
|
assert_success
|
||||||
|
assert_output --partial 'check_policy_service inet:localhost:65265'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test '(ENV POSTFIX_MAILBOX_SIZE_LIMIT) should be configured for both Postfix and Dovecot' {
|
||||||
|
_run_in_container postconf -h mailbox_size_limit
|
||||||
|
assert_output 4096000
|
||||||
|
|
||||||
|
# Dovecot mailbox is sized by `virtual_mailbox_size` from Postfix:
|
||||||
|
_run_in_container postconf -h virtual_mailbox_limit
|
||||||
|
assert_output 4096000
|
||||||
|
|
||||||
|
# Quota support:
|
||||||
|
_run_in_container doveconf -h plugin/quota_rule
|
||||||
|
# Global default storage limit quota for each mailbox 4 MiB:
|
||||||
|
assert_output '*:storage=4M'
|
||||||
|
|
||||||
|
# Sizes are equivalent - Bytes to MiB (rounded):
|
||||||
|
run numfmt --to=iec --format '%.0f' 4096000
|
||||||
|
assert_output '4M'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test '(ENV POSTFIX_MESSAGE_SIZE_LIMIT) should be configured for both Postfix and Dovecot' {
|
||||||
|
_run_in_container postconf -h message_size_limit
|
||||||
|
assert_output 2048000
|
||||||
|
|
||||||
|
_run_in_container doveconf -h plugin/quota_max_mail_size
|
||||||
|
assert_output '2M'
|
||||||
|
|
||||||
|
# Sizes are equivalent - Bytes to MiB (rounded):
|
||||||
|
run numfmt --to=iec --format '%.0f' 2048000
|
||||||
|
assert_output '2M'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'Deleting an mailbox account should also remove that account from dovecot-quotas.cf' {
|
||||||
|
_add_mail_account_then_wait_until_ready 'quserremoved@domain.tld'
|
||||||
|
|
||||||
|
_run_in_container setup quota set quserremoved@domain.tld 12M
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
_run_in_container cat '/tmp/docker-mailserver/dovecot-quotas.cf'
|
||||||
|
assert_success
|
||||||
|
assert_output 'quserremoved@domain.tld:12M'
|
||||||
|
|
||||||
|
_run_in_container setup email del -y quserremoved@domain.tld
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
_run_in_container cat /tmp/docker-mailserver/dovecot-quotas.cf
|
||||||
|
assert_success
|
||||||
|
refute_output --partial 'quserremoved@domain.tld:12M'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'Dovecot should acknowledge quota configured for accounts' {
|
||||||
|
# sed -nE 's/.*STORAGE.*Limit=([0-9]+).*/\1/p' | numfmt --from-unit=1024 --to=iec --format '%.0f'
|
||||||
|
local CMD_GET_QUOTA="doveadm -f flow quota get -u 'user1@localhost.localdomain'"
|
||||||
|
|
||||||
|
# 4M == 4096 kiB (numfmt --to-unit=1024 --from=iec 4M)
|
||||||
|
_run_in_container_bash "${CMD_GET_QUOTA}"
|
||||||
|
assert_line --partial 'Type=STORAGE Value=0 Limit=4096'
|
||||||
|
|
||||||
|
# Setting a new limit for the user:
|
||||||
|
_run_in_container setup quota set 'user1@localhost.localdomain' 50M
|
||||||
|
assert_success
|
||||||
|
# 50M (50 * 1024^2) == 51200 kiB (numfmt --to-unit=1024 --from=iec 52428800)
|
||||||
|
run _repeat_until_success_or_timeout 20 _exec_in_container_bash "${CMD_GET_QUOTA} | grep -o 'Type=STORAGE Value=0 Limit=51200'"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
# Deleting quota resets it to default global quota limit (`plugin/quota_rule`):
|
||||||
|
_run_in_container setup quota del 'user1@localhost.localdomain'
|
||||||
|
assert_success
|
||||||
|
run _repeat_until_success_or_timeout 20 _exec_in_container_bash "${CMD_GET_QUOTA} | grep -o 'Type=STORAGE Value=0 Limit=4096'"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'should receive a warning mail from Dovecot when quota is exceeded' {
|
||||||
|
# skip 'disabled as it fails randomly: https://github.com/docker-mailserver/docker-mailserver/pull/2511'
|
||||||
|
|
||||||
|
# Prepare
|
||||||
|
_add_mail_account_then_wait_until_ready 'quotauser@otherdomain.tld'
|
||||||
|
|
||||||
|
# Actual tests
|
||||||
|
_run_in_container setup quota set quotauser@otherdomain.tld 10k
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
# wait until quota has been updated
|
||||||
|
run _repeat_until_success_or_timeout 20 _exec_in_container_bash "doveadm -f flow quota get -u 'quotauser@otherdomain.tld' | grep -o 'Type=STORAGE Value=0 Limit=10'"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
# dovecot and postfix has been restarted
|
||||||
|
_wait_for_service postfix
|
||||||
|
_wait_for_service dovecot
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# send some big emails
|
||||||
|
_send_email 'email-templates/quota-exceeded' '0.0.0.0 25'
|
||||||
|
_send_email 'email-templates/quota-exceeded' '0.0.0.0 25'
|
||||||
|
_send_email 'email-templates/quota-exceeded' '0.0.0.0 25'
|
||||||
|
# check for quota warn message existence
|
||||||
|
run _repeat_until_success_or_timeout 20 _exec_in_container grep -R 'Subject: quota warning' /var/mail/otherdomain.tld/quotauser/new/
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run _repeat_until_success_or_timeout 20 sh -c "docker logs ${CONTAINER_NAME} | grep 'Quota exceeded (mailbox for user is full)'"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
# ensure only the first big message and the warn message are present (other messages are rejected: mailbox is full)
|
||||||
|
_run_in_container sh -c 'ls /var/mail/otherdomain.tld/quotauser/new/ | wc -l'
|
||||||
|
assert_success
|
||||||
|
assert_output "2"
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
_run_in_container setup email del -y quotauser@otherdomain.tld
|
||||||
|
assert_success
|
||||||
|
}
|
|
@ -17,7 +17,6 @@ function setup_file() {
|
||||||
local CONTAINER_ARGS_ENV_CUSTOM=(
|
local CONTAINER_ARGS_ENV_CUSTOM=(
|
||||||
--env ENABLE_AMAVIS=1
|
--env ENABLE_AMAVIS=1
|
||||||
--env AMAVIS_LOGLEVEL=2
|
--env AMAVIS_LOGLEVEL=2
|
||||||
--env ENABLE_QUOTAS=1
|
|
||||||
--env ENABLE_SRS=1
|
--env ENABLE_SRS=1
|
||||||
--env PERMIT_DOCKER=host
|
--env PERMIT_DOCKER=host
|
||||||
--env PFLOGSUMM_TRIGGER=logrotate
|
--env PFLOGSUMM_TRIGGER=logrotate
|
||||||
|
@ -244,198 +243,6 @@ zip
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "quota: setquota user must be existing" {
|
|
||||||
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
|
||||||
|
|
||||||
_run_in_container_bash "setquota quota_user 50M"
|
|
||||||
assert_failure
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 50M"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container_bash "setquota username@fulldomain 50M"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
_run_in_container_bash "delmailuser -y quota_user@domain.tld"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "quota: setquota <quota> must be well formatted" {
|
|
||||||
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
|
||||||
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 26GIGOTS"
|
|
||||||
assert_failure
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 123"
|
|
||||||
assert_failure
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld M"
|
|
||||||
assert_failure
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld -60M"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 10B"
|
|
||||||
assert_success
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 10k"
|
|
||||||
assert_success
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 10M"
|
|
||||||
assert_success
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 10G"
|
|
||||||
assert_success
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 10T"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
|
|
||||||
_run_in_container_bash "delmailuser -y quota_user@domain.tld"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "quota: delquota user must be existing" {
|
|
||||||
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
|
||||||
|
|
||||||
_run_in_container_bash "delquota uota_user@domain.tld"
|
|
||||||
assert_failure
|
|
||||||
_run_in_container_bash "delquota quota_user"
|
|
||||||
assert_failure
|
|
||||||
_run_in_container_bash "delquota dontknowyou@domain.tld"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
_run_in_container_bash "setquota quota_user@domain.tld 10T"
|
|
||||||
assert_success
|
|
||||||
_run_in_container_bash "delquota quota_user@domain.tld"
|
|
||||||
assert_success
|
|
||||||
_run_in_container_bash "grep -i 'quota_user@domain.tld' /tmp/docker-mailserver/dovecot-quotas.cf"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
_run_in_container_bash "delmailuser -y quota_user@domain.tld"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "quota: delquota allow when no quota for existing user" {
|
|
||||||
_add_mail_account_then_wait_until_ready 'quota_user@domain.tld'
|
|
||||||
|
|
||||||
_run_in_container_bash "grep -i 'quota_user@domain.tld' /tmp/docker-mailserver/dovecot-quotas.cf"
|
|
||||||
assert_failure
|
|
||||||
|
|
||||||
_run_in_container_bash "delquota quota_user@domain.tld"
|
|
||||||
assert_success
|
|
||||||
_run_in_container_bash "delquota quota_user@domain.tld"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container_bash "delmailuser -y quota_user@domain.tld"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "quota: dovecot quota present in postconf" {
|
|
||||||
_run_in_container_bash "postconf | grep 'check_policy_service inet:localhost:65265'"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@test "quota: dovecot mailbox max size must be equal to postfix mailbox max size" {
|
|
||||||
postfix_mailbox_size=$(_exec_in_container_bash "postconf | grep -Po '(?<=mailbox_size_limit = )[0-9]+'")
|
|
||||||
run echo "${postfix_mailbox_size}"
|
|
||||||
refute_output ""
|
|
||||||
|
|
||||||
# dovecot relies on virtual_mailbox_size by default
|
|
||||||
postfix_virtual_mailbox_size=$(_exec_in_container_bash "postconf | grep -Po '(?<=virtual_mailbox_limit = )[0-9]+'")
|
|
||||||
assert_equal "${postfix_virtual_mailbox_size}" "${postfix_mailbox_size}"
|
|
||||||
|
|
||||||
postfix_mailbox_size_mb=$(( postfix_mailbox_size / 1000000))
|
|
||||||
|
|
||||||
dovecot_mailbox_size_mb=$(_exec_in_container_bash "doveconf | grep -oP '(?<=quota_rule \= \*\:storage=)[0-9]+'")
|
|
||||||
run echo "${dovecot_mailbox_size_mb}"
|
|
||||||
refute_output ""
|
|
||||||
|
|
||||||
assert_equal "${postfix_mailbox_size_mb}" "${dovecot_mailbox_size_mb}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@test "quota: dovecot message max size must be equal to postfix messsage max size" {
|
|
||||||
postfix_message_size=$(_exec_in_container_bash "postconf | grep -Po '(?<=message_size_limit = )[0-9]+'")
|
|
||||||
run echo "${postfix_message_size}"
|
|
||||||
refute_output ""
|
|
||||||
|
|
||||||
postfix_message_size_mb=$(( postfix_message_size / 1000000))
|
|
||||||
|
|
||||||
dovecot_message_size_mb=$(_exec_in_container_bash "doveconf | grep -oP '(?<=quota_max_mail_size = )[0-9]+'")
|
|
||||||
run echo "${dovecot_message_size_mb}"
|
|
||||||
refute_output ""
|
|
||||||
|
|
||||||
assert_equal "${postfix_message_size_mb}" "${dovecot_message_size_mb}"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "quota: quota directive is removed when mailbox is removed" {
|
|
||||||
_add_mail_account_then_wait_until_ready 'quserremoved@domain.tld'
|
|
||||||
|
|
||||||
_run_in_container_bash "setquota quserremoved@domain.tld 12M"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container_bash 'cat /tmp/docker-mailserver/dovecot-quotas.cf | grep -E "^quserremoved@domain.tld\:12M\$" | wc -l | grep 1'
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container_bash "delmailuser -y quserremoved@domain.tld"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container_bash 'cat /tmp/docker-mailserver/dovecot-quotas.cf | grep -E "^quserremoved@domain.tld\:12M\$"'
|
|
||||||
assert_failure
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "quota: dovecot applies user quota" {
|
|
||||||
_run_in_container_bash "doveadm quota get -u 'user1@localhost.localdomain' | grep 'User quota STORAGE'"
|
|
||||||
assert_output --partial "- 0"
|
|
||||||
|
|
||||||
_run_in_container_bash "setquota user1@localhost.localdomain 50M"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
# wait until quota has been updated
|
|
||||||
run _repeat_until_success_or_timeout 20 _exec_in_container_bash 'doveadm quota get -u user1@localhost.localdomain | grep -oP "(User quota STORAGE\s+[0-9]+\s+)51200(.*)"'
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container_bash "delquota user1@localhost.localdomain"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
# wait until quota has been updated
|
|
||||||
run _repeat_until_success_or_timeout 20 _exec_in_container_bash 'doveadm quota get -u user1@localhost.localdomain | grep -oP "(User quota STORAGE\s+[0-9]+\s+)-(.*)"'
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "quota: warn message received when quota exceeded" {
|
|
||||||
skip 'disabled as it fails randomly: https://github.com/docker-mailserver/docker-mailserver/pull/2511'
|
|
||||||
|
|
||||||
# create user
|
|
||||||
_add_mail_account_then_wait_until_ready 'quotauser@otherdomain.tld'
|
|
||||||
_run_in_container_bash 'setquota quotauser@otherdomain.tld 10k'
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
# wait until quota has been updated
|
|
||||||
run _repeat_until_success_or_timeout 20 _exec_in_container_bash 'doveadm quota get -u quotauser@otherdomain.tld | grep -oP \"(User quota STORAGE\s+[0-9]+\s+)10(.*)\"'
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
# dovecot and postfix has been restarted
|
|
||||||
_wait_for_service postfix
|
|
||||||
_wait_for_service dovecot
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
# send some big emails
|
|
||||||
_send_email 'email-templates/quota-exceeded' '0.0.0.0 25'
|
|
||||||
_send_email 'email-templates/quota-exceeded' '0.0.0.0 25'
|
|
||||||
_send_email 'email-templates/quota-exceeded' '0.0.0.0 25'
|
|
||||||
|
|
||||||
# check for quota warn message existence
|
|
||||||
run _repeat_until_success_or_timeout 20 _exec_in_container_bash 'grep \"Subject: quota warning\" /var/mail/otherdomain.tld/quotauser/new/ -R'
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
run _repeat_until_success_or_timeout 20 sh -c "docker logs mail | grep 'Quota exceeded (mailbox for user is full)'"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
# ensure only the first big message and the warn message are present (other messages are rejected: mailbox is full)
|
|
||||||
_run_in_container sh -c 'ls /var/mail/otherdomain.tld/quotauser/new/ | wc -l'
|
|
||||||
assert_success
|
|
||||||
assert_output "2"
|
|
||||||
|
|
||||||
_run_in_container_bash "delmailuser -y quotauser@otherdomain.tld"
|
|
||||||
assert_success
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# PERMIT_DOCKER mynetworks
|
# PERMIT_DOCKER mynetworks
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue