1 |
commit: 0fc8e4b963a0c1a2df778b426a479093c398679c |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 26 18:48:50 2016 +0000 |
4 |
Commit: Brian Evans <grknight <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 27 16:44:03 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/mysql.git/commit/?id=0fc8e4b9 |
7 |
|
8 |
mysql-multilib-r1.eclass: Fix password reading from my.cnf |
9 |
|
10 |
We are reading multiple sections from my.cnf at once from my.cnf when |
11 |
looking for the password for the mysql root user in |
12 |
mysql-multilib-r1_pkg_config(). |
13 |
|
14 |
If each section has set a password option this will result in the following |
15 |
invalid password value (with "set -x"): |
16 |
|
17 |
++ local extra_options= |
18 |
++ //usr/bin/my_print_defaults client mysql |
19 |
++ sed -n '/^--password=/s,--password=,,gp' |
20 |
+ MYSQL_ROOT_PASSWORD='***** |
21 |
*****' |
22 |
+ [[ ***** |
23 |
***** == \*\*\*\*\* ]] |
24 |
+ set +x |
25 |
|
26 |
Like you can see the two passwords are concatenated via newline in one |
27 |
string which is not what we want. |
28 |
|
29 |
With this commit we will no longer read all sections at once instead we |
30 |
read section per section. We are now also telling the user where we are |
31 |
looking for the password and where we found one. In addition this commit |
32 |
adds a sanity check for newline to catch scenarios where the user for |
33 |
example has inadvertently set multiple password options in one section |
34 |
which we can't handle: In that case it is better to prompt for a password |
35 |
like no password was set in my.cnf instead of initializing mysqld with a |
36 |
mysql root password the user is not expecting. |
37 |
|
38 |
Gentoo-Bug: https://bugs.gentoo.org/510724 |
39 |
|
40 |
eclass/mysql-multilib-r1.eclass | 22 ++++++++++++++++++++-- |
41 |
1 file changed, 20 insertions(+), 2 deletions(-) |
42 |
|
43 |
diff --git a/eclass/mysql-multilib-r1.eclass b/eclass/mysql-multilib-r1.eclass |
44 |
index 3f7372c..ebf89f2 100644 |
45 |
--- a/eclass/mysql-multilib-r1.eclass |
46 |
+++ b/eclass/mysql-multilib-r1.eclass |
47 |
@@ -817,11 +817,29 @@ mysql-multilib-r1_pkg_config() { |
48 |
local maxtry=15 |
49 |
|
50 |
if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
51 |
- MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password)" |
52 |
+ local tmp_mysqld_password_source= |
53 |
+ |
54 |
+ for tmp_mysqld_password_source in mysql client; do |
55 |
+ einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." |
56 |
+ MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval "${tmp_mysqld_password_source}" password)" |
57 |
+ if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then |
58 |
+ if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then |
59 |
+ ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" |
60 |
+ MYSQL_ROOT_PASSWORD= |
61 |
+ continue |
62 |
+ fi |
63 |
+ |
64 |
+ einfo "Found password in '${tmp_mysqld_password_source}' section!" |
65 |
+ break |
66 |
+ fi |
67 |
+ done |
68 |
+ |
69 |
# Sometimes --show is required to display passwords in some implementations of my_print_defaults |
70 |
if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then |
71 |
- MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password --show)" |
72 |
+ MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval "${tmp_mysqld_password_source}" password --show)" |
73 |
fi |
74 |
+ |
75 |
+ unset tmp_mysqld_password_source |
76 |
fi |
77 |
MYSQL_TMPDIR="$(mysql-multilib-r1_getoptval mysqld tmpdir)" |
78 |
# These are dir+prefix |