1
0
mirror of https://github.com/docker-mailserver/docker-mailserver.git synced 2025-08-08 23:06:49 +02:00

fix: Avoid alias being used as regex during dovecot dummy account userdb detection (#4222)

Applies alternative approach previously suggested by @polarathene and adds test cases to prevent future regressions
This commit is contained in:
pitilux
2024-10-12 00:34:20 +02:00
committed by GitHub
parent 26a44995a9
commit 34eb54ac39
4 changed files with 32 additions and 2 deletions

View File

@ -135,7 +135,8 @@ function _create_dovecot_alias_dummy_accounts() {
fi
DOVECOT_USERDB_LINE="${ALIAS}:${REAL_ACC[1]}:${DMS_VMAIL_UID}:${DMS_VMAIL_GID}::/var/mail/${REAL_DOMAINNAME}/${REAL_USERNAME}/home::${REAL_ACC[2]:-}"
if grep -qi "^${ALIAS}:" "${DOVECOT_USERDB_FILE}"; then
# Match a full line with `-xF` to avoid regex patterns introducing false positives matching `ALIAS`:
if grep -qixF "${DOVECOT_USERDB_LINE}" "${DOVECOT_USERDB_FILE}"; then
_log 'warn' "Alias '${ALIAS}' will not be added to '${DOVECOT_USERDB_FILE}' twice"
else
echo "${DOVECOT_USERDB_LINE}" >>"${DOVECOT_USERDB_FILE}"