From df44d8757fcaf8579ebd45cede1d6bfc99dd727d Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Tue, 25 Aug 2020 22:50:12 +0200 Subject: [SO] Fix SQL DB user creation when password contains special chars SO uses custom scripts to create DBs and users. Those scripts were not escaping properly special characters that may appear in our auto-generated passwords. Fix this issue by adding special characters escaping to those scripts. Issue-ID: OOM-2328 Reported-by: Marat Salakhutdinov Signed-off-by: Krzysztof Opasiak Change-Id: Ifce3265df154a510606e0a082c7041536e2ec303 --- .../config/docker-entrypoint-initdb.d/98-create-so-user.sh | 7 +++++++ .../config/docker-entrypoint-initdb.d/99-create-so-admin.sh | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'kubernetes/so') diff --git a/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/98-create-so-user.sh b/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/98-create-so-user.sh index a8f772b947..05b1ff70cf 100755 --- a/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/98-create-so-user.sh +++ b/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/98-create-so-user.sh @@ -23,6 +23,13 @@ echo "Creating so user . . ." 1>/tmp/mariadb-so-user.log 2>&1 +prepare_password() +{ + echo "$1" | sed -e "s/'/\\\\'/g; s/\"/\\\\\"/g" +} + +DB_PASSWORD=`prepare_password $DB_PASSWORD` + mysql -uroot -p$MYSQL_ROOT_PASSWORD << EOF || exit 1 DROP USER IF EXISTS '${DB_USER}'; CREATE USER '${DB_USER}'; diff --git a/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/99-create-so-admin.sh b/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/99-create-so-admin.sh index adb28fe8e6..593739e1cf 100755 --- a/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/99-create-so-admin.sh +++ b/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/99-create-so-admin.sh @@ -23,6 +23,13 @@ echo "Creating so admin user . . ." 1>/tmp/mariadb-so-admin.log 2>&1 +prepare_password() +{ + echo "$1" | sed -e "s/'/\\\\'/g; s/\"/\\\\\"/g" +} + +DB_ADMIN_PASSWORD=`prepare_password $DB_ADMIN_PASSWORD` + mysql -uroot -p$MYSQL_ROOT_PASSWORD << EOF || exit 1 DROP USER IF EXISTS '${DB_ADMIN}'; CREATE USER '${DB_ADMIN}'; -- cgit 1.2.3-korg