diff --git a/eclass/mysql-multilib-r1.eclass b/eclass/mysql-multilib-r1.eclass index 3f7372c0f6337..ebf89f28f94f6 100644 --- a/eclass/mysql-multilib-r1.eclass +++ b/eclass/mysql-multilib-r1.eclass @@ -817,11 +817,29 @@ mysql-multilib-r1_pkg_config() { local maxtry=15 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then - MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password)" + local tmp_mysqld_password_source= + + for tmp_mysqld_password_source in mysql client; do + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." + MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval "${tmp_mysqld_password_source}" password)" + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" + MYSQL_ROOT_PASSWORD= + continue + fi + + einfo "Found password in '${tmp_mysqld_password_source}' section!" + break + fi + done + # Sometimes --show is required to display passwords in some implementations of my_print_defaults if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then - MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password --show)" + MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval "${tmp_mysqld_password_source}" password --show)" fi + + unset tmp_mysqld_password_source fi MYSQL_TMPDIR="$(mysql-multilib-r1_getoptval mysqld tmpdir)" # These are dir+prefix