mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-06-27 11:19:15 +02:00
scripts: perform additional checks when updating/adding/deletting accounts (#4033)
* normalize accounts to lowercase * update CHANGELOG * add test to verify bug fix works correctly
This commit is contained in:
parent
4119849284
commit
b222035112
3 changed files with 25 additions and 0 deletions
|
@ -13,6 +13,7 @@ function _manage_accounts() {
|
|||
local PASSWD=${4}
|
||||
|
||||
_arg_expect_mail_account
|
||||
_arg_check_mail_account
|
||||
|
||||
case "${ACTION}" in
|
||||
( 'create' | 'update' )
|
||||
|
@ -69,6 +70,15 @@ function _arg_expect_mail_account() {
|
|||
[[ ${MAIL_ACCOUNT} =~ .*\@.* ]] || { __usage ; _exit_with_error "'${MAIL_ACCOUNT}' should include the domain (eg: user@example.com)" ; }
|
||||
}
|
||||
|
||||
# Checks the mail account string, e.g. on uppercase letters.
|
||||
function _arg_check_mail_account() {
|
||||
if grep -q -E '[[:upper:]]+' <<< "${MAIL_ACCOUNT}"; then
|
||||
local MAIL_ACCOUNT_NORMALIZED=${MAIL_ACCOUNT,,}
|
||||
_log 'warn' "Mail account '${MAIL_ACCOUNT}' has uppercase letters and will be normalized to '${MAIL_ACCOUNT_NORMALIZED}'"
|
||||
MAIL_ACCOUNT=${MAIL_ACCOUNT_NORMALIZED}
|
||||
fi
|
||||
}
|
||||
|
||||
function _account_should_not_exist_yet() {
|
||||
__account_already_exists && _exit_with_error "'${MAIL_ACCOUNT}' already exists"
|
||||
if [[ -f ${DATABASE_VIRTUAL} ]] && grep -q "^${MAIL_ACCOUNT}" "${DATABASE_VIRTUAL}"; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue