From f534560782636691771e7f07756512c243a27bac Mon Sep 17 00:00:00 2001 From: dpeca Date: Fri, 22 Mar 2019 01:09:39 +0100 Subject: [PATCH] Allow custom $MAX_DBUSER_LEN echo "MAX_DBUSER_LEN=80" >> /usr/local/vesta/conf/vesta.conf --- func/main.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/func/main.sh b/func/main.sh index ded0eb4b..464b9727 100644 --- a/func/main.sh +++ b/func/main.sh @@ -650,8 +650,12 @@ is_date_format_valid() { # Database user validator is_dbuser_format_valid() { exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|/|\|\"|'|;|%|\`| ]" - if [ 17 -le ${#1} ]; then - check_result $E_INVALID "mysql username can be up to 16 characters long" + my_max_dbuser_len=16 + if [ ! -z "$MAX_DBUSER_LEN" ]; then + my_max_dbuser_len=$MAX_DBUSER_LEN + fi + if [ ${#1} -ge $my_max_dbuser_len ]; then + check_result $E_INVALID "mysql username can be up to $my_max_dbuser_len characters long" fi if [[ "$1" =~ $exclude ]]; then check_result $E_INVALID "invalid $2 format :: $1"