scripts: disallow alias = account (#3270)

This commit is contained in:
Georg Lauterbach 2023-04-17 19:22:50 +02:00 committed by GitHub
parent 4b937fda5b
commit 3f22cbce01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -74,6 +74,10 @@ function _arg_expect_mail_account
function _account_should_not_exist_yet function _account_should_not_exist_yet
{ {
__account_already_exists && _exit_with_error "'${MAIL_ACCOUNT}' already exists" __account_already_exists && _exit_with_error "'${MAIL_ACCOUNT}' already exists"
if [[ -f ${DATABASE_VIRTUAL} ]] && grep -q "^${MAIL_ACCOUNT}" "${DATABASE_VIRTUAL}"
then
_exit_with_error "'${MAIL_ACCOUNT}' is already defined as an alias"
fi
} }
# Also used by delmailuser, setquota, delquota # Also used by delmailuser, setquota, delquota

View file

@ -25,6 +25,10 @@ function _manage_virtual_aliases
case "${ACTION}" in case "${ACTION}" in
# Associate RECIPIENT to MAIL_ALIAS: # Associate RECIPIENT to MAIL_ALIAS:
( 'update' ) ( 'update' )
if [[ -f ${DATABASE_ACCOUNTS} ]] && grep -q "^${MAIL_ALIAS}" "${DATABASE_ACCOUNTS}"
then
_exit_with_error "'${MAIL_ALIAS}' is already defined as an account"
fi
_db_entry_add_or_append "${DATABASE_VIRTUAL}" "${MAIL_ALIAS}" "${RECIPIENT}" _db_entry_add_or_append "${DATABASE_VIRTUAL}" "${MAIL_ALIAS}" "${RECIPIENT}"
;; ;;