From 70625962366c00c7c91415ba6c695e7cd1a3e198 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Tue, 10 Nov 2020 12:54:53 +0100 Subject: [PATCH] Fix MariaDB connections issues * allow new unix_socket auth system * add socket path in /etc/mysql/conf.d/my.cnf --- install | 2 +- requirements.txt | 2 +- wo/cli/plugins/stack_pref.py | 34 +++++++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/install b/install index 2a1bf8d..935041d 100755 --- a/install +++ b/install @@ -713,7 +713,7 @@ wo_woconf() { echo -e '\n[letsencrypt]\n\nkeylength = "ec-384"' >>/etc/wo/wo.conf fi if ! grep -q "php" /etc/wo/wo.conf; then - echo -e '\n[php]\n\nversion = 7.3' >>/etc/wo/wo.conf + echo -e '\n[php]\n\nversion = 7.4' >>/etc/wo/wo.conf fi fi } diff --git a/requirements.txt b/requirements.txt index 9a33f07..95cf74c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ cement==2.10.12 pystache>=0.5.4 pynginxconfig>=0.3.4 -PyMySQL>=0.10.0 +PyMySQL>=0.10.1 psutil>=5.7.2 sh>=1.12.14 SQLAlchemy>=1.3.18 diff --git a/wo/cli/plugins/stack_pref.py b/wo/cli/plugins/stack_pref.py index bc4e755..ac3079e 100644 --- a/wo/cli/plugins/stack_pref.py +++ b/wo/cli/plugins/stack_pref.py @@ -51,6 +51,7 @@ def pre_pref(self, apt_packages): [client] user = root password = {chars} + socket = /run/mysqld/mysqld.sock """.format(chars=chars) config = configparser.ConfigParser() config.read_string(mysql_config) @@ -939,16 +940,11 @@ def post_pref(self, apt_packages, packages, upgrade=False): config = configparser.ConfigParser() config.read('/etc/mysql/conf.d/my.cnf.tmp') chars = config['client']['password'] - WOShellExec.cmd_exec( - self, - 'mysql -e "ALTER USER root@localhost ' - 'IDENTIFIED VIA mysql_native_password;"') WOShellExec.cmd_exec( self, 'mysql -e "SET PASSWORD = ' - 'PASSWORD(\'{0}\');"'.format(chars)) - WOShellExec.cmd_exec( - self, 'mysql -e "flush privileges;"') + 'PASSWORD(\'{0}\'); flush privileges;"' + .format(chars)) WOFileUtils.mvfile( self, '/etc/mysql/conf.d/my.cnf.tmp', '/etc/mysql/conf.d/my.cnf') @@ -956,6 +952,30 @@ def post_pref(self, apt_packages, packages, upgrade=False): Log.error(self, "Unable to set MySQL password") WOGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git") + elif os.path.exists('/etc/mysql/conf.d/my.cnf'): + if ((WOAptGet.is_installed( + self, 'mariadb-server-10.5')) and + not (WOFileUtils.grepcheck( + self, '/etc/mysql/conf.d/my.cnf', 'socket'))): + try: + config = configparser.ConfigParser() + config.read('/etc/mysql/conf.d/my.cnf') + chars = config['client']['password'] + WOShellExec.cmd_exec( + self, + 'mysql -e "ALTER USER root@localhost ' + 'IDENTIFIED VIA unix_socket OR ' + 'mysql_native_password; ' + 'SET PASSWORD = PASSWORD(\'{0}\'); ' + 'flush privileges;"'.format(chars)) + WOFileUtils.textappend( + self, '/etc/mysql/conf.d/my.cnf', + 'socket = /run/mysqld/mysqld.sock') + except CommandExecutionError: + Log.error(self, "Unable to set MySQL password") + WOGit.add(self, ["/etc/mysql"], + msg="Adding MySQL into Git") + Log.wait(self, "Tuning MariaDB configuration") if not os.path.isfile("/etc/mysql/my.cnf.default-pkg"): WOFileUtils.copyfile(self, "/etc/mysql/my.cnf",