aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes
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
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')
-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}';
ding */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0
.. Copyright 2017 Huawei Technologies Co., Ltd.

Workspace and Development Tools
===============================

We recognize that there are different ways to set up a workspace and different tools that may be chosen.  This is just one way to set things up.

Suggested Directory Structure
------------------------------
*NOTE*: You may have different versions of eclipse and java.

	onap
	
		.m2
		
		apache-maven-3.3.9
		
		camunda-modeler
		
		eclipse-jee-neon-3-linux-gtk-x86_64
		
		jdk1.8.0_131
		
		workspace
		
			SO
				chef-repo
				
				docker-config
				
				libs
				
				so
				
				so-config
				
Java
-----
Download the latest Java_8_SE_Development_Kit_ from Oracle.   Select a Linux x64 package.

Unpack it.

.. _Java_8_SE_Development_Kit: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Maven
------

Download the Apache_Maven_3.3.9_ binary.  NOTE: 3.3.9 is the recommended version, even though much higher versions are available.

Unpack it.

.. _Apache_Maven_3.3.9: https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/

Create an .m2 directory for maven and put settings.xml_ in it.  Edit the local repository path in settings.xml to make it correct for your environment.  Everything else should be OK.

.. _settings.xml: https://wiki.onap.org/download/attachments/15997820/settings.xml?version=1&modificationDate=1506156303000&api=v2

Camunda Modeler
---------------

Download the Camunda_Modeler_.  Select the Linux x64 package.
Unpack it.

.. _Camunda_Modeler: https://camunda.org/download/modeler/

Eclipse
-------

Download Eclipse_for_Linux_.  Select the 64-bit Eclipse IDE for Java EE Developers.  Oxygen seems to be the latest version. These instructions were written for Neon.
Unpack it.

.. _Eclipse_for_Linux:  https://www.eclipse.org/downloads/eclipse-packages/?osType=linux

In the eclipse directory, edit eclipse.ini

	Add (or change) the -vm setting so that it points to your JDK.
	
	Adjust the maximum heap space (2GB is recommended).
	
	Example:
	
.. image:: images/Workspace_and_Development_Tools.png	
	
Eclipse Settings
----------------

**Configure eclipse to use your external maven 3.3.9 installation:**
	Go to Window→Preferences→Maven→Installations
	
	Click "Add" and browse to your apache-maven-3.3.9 directory.  Click "OK" to select it.
	
	Click "Finish"
	
.. image:: images/Workspace_and_Development_Tools_2.png

Make sure the external installation is selected:

.. image:: images/Workspace_and_Development_Tools_3.png

**Configure eclipse to use your settings.xml**
	Go to Window→Preferences→Maven→User Settings
	
	Type the full path to your settings.xml file into the "User Settings" box and click "OK".
	
.. image:: images/Workspace_and_Development_Tools_4.png