aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2020-08-25 22:50:12 +0200
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>2020-10-16 07:35:15 +0000
commitdf44d8757fcaf8579ebd45cede1d6bfc99dd727d (patch)
tree830fec846acdb92a9534fdc3a484939a48eaba74 /kubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d
parent7c18bb5ae08838bc97f31a612cf4689d80a614e6 (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')
-rwxr-xr-xkubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/98-create-so-user.sh7
-rwxr-xr-xkubernetes/so/components/so-mariadb/resources/config/docker-entrypoint-initdb.d/99-create-so-admin.sh7
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}';