diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2020-08-25 22:50:12 +0200 |
---|---|---|
committer | Sylvain Desbureaux <sylvain.desbureaux@orange.com> | 2020-10-16 07:35:15 +0000 |
commit | df44d8757fcaf8579ebd45cede1d6bfc99dd727d (patch) | |
tree | 830fec846acdb92a9534fdc3a484939a48eaba74 /kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d | |
parent | 7c18bb5ae08838bc97f31a612cf4689d80a614e6 (diff) |
[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 <marat.salakhutdinov@bell.ca>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Change-Id: Ifce3265df154a510606e0a082c7041536e2ec303
Diffstat (limited to 'kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d')
2 files changed, 14 insertions, 0 deletions
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}'; |