aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorSteven Dake <stdake@cisco.com>2015-11-10 04:15:34 -0500
committerSteven Dake <stdake@cisco.com>2015-11-11 18:42:07 -0500
commit09e9b1be33b0f0b3ee75f9545e6430877b6e0264 (patch)
tree0b2923453ae6863e2ec2cba35b970b5bb02dd0a6 /docker
parentf9ccb1c8829cef551b875c7c387530e7980414a7 (diff)
downloadkolla-09e9b1be33b0f0b3ee75f9545e6430877b6e0264.tar.gz
kolla-09e9b1be33b0f0b3ee75f9545e6430877b6e0264.zip
Move the mariadb expect code to a script
Atleast in a script, sudo can be made to only allow the script to run from the mysql process in the future, versus all the proceesses being able to be executed as root presently. Change-Id: I030b57086e37e4dc8f668f98c04335d94ab9d2b0 Partially-Implements: blueprint drop-root
Diffstat (limited to 'docker')
-rw-r--r--docker/mariadb/Dockerfile.j24
-rw-r--r--docker/mariadb/extend_start.sh21
-rw-r--r--docker/mariadb/security_reset.expect21
3 files changed, 25 insertions, 21 deletions
diff --git a/docker/mariadb/Dockerfile.j2 b/docker/mariadb/Dockerfile.j2
index fbc699290..a840d9b8d 100644
--- a/docker/mariadb/Dockerfile.j2
+++ b/docker/mariadb/Dockerfile.j2
@@ -29,6 +29,8 @@ RUN apt-get install -y --no-install-recommends \
{% endif %}
COPY extend_start.sh /usr/local/bin/kolla_extend_start
-RUN chmod 755 /usr/local/bin/kolla_extend_start
+COPY security_reset.expect /usr/local/bin/kolla_security_reset
+RUN chmod 755 /usr/local/bin/kolla_extend_start \
+ && chmod 755 /usr/local/bin/kolla_security_reset
{{ include_footer }}
diff --git a/docker/mariadb/extend_start.sh b/docker/mariadb/extend_start.sh
index 6fa450675..8a8699b88 100644
--- a/docker/mariadb/extend_start.sh
+++ b/docker/mariadb/extend_start.sh
@@ -5,26 +5,7 @@ function bootstrap_db {
# Waiting for deamon
sleep 10
- expect -c '
- set timeout 10
- spawn mysql_secure_installation
- expect "Enter current password for root (enter for none):"
- send "\r"
- expect "Set root password?"
- send "y\r"
- expect "New password:"
- send "'"${DB_ROOT_PASSWORD}"'\r"
- expect "Re-enter new password:"
- send "'"${DB_ROOT_PASSWORD}"'\r"
- expect "Remove anonymous users?"
- send "y\r"
- expect "Disallow root login remotely?"
- send "n\r"
- expect "Remove test database and access to it?"
- send "y\r"
- expect "Reload privilege tables now?"
- send "y\r"
- expect eof'
+ kolla_security_reset
mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;"
mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;"
diff --git a/docker/mariadb/security_reset.expect b/docker/mariadb/security_reset.expect
new file mode 100644
index 000000000..7c720136f
--- /dev/null
+++ b/docker/mariadb/security_reset.expect
@@ -0,0 +1,21 @@
+#!/usr/bin/expect -f
+
+set timeout 10
+spawn mysql_secure_installation
+expect "Enter current password for root (enter for none):"
+send "\r"
+expect "Set root password?"
+send "y\r"
+expect "New password:"
+send "$env(DB_ROOT_PASSWORD)\r"
+expect "Re-enter new password:"
+send "$env(DB_ROOT_PASSWORD)\r"
+expect "Remove anonymous users?"
+send "y\r"
+expect "Disallow root login remotely?"
+send "n\r"
+expect "Remove test database and access to it?"
+send "y\r"
+expect "Reload privilege tables now?"
+send "y\r"
+expect eof