Fix MariaDB connections issues

* allow new unix_socket auth system
* add socket path in /etc/mysql/conf.d/my.cnf
This commit is contained in:
VirtuBox
2020-11-10 12:54:53 +01:00
parent 78cd626d75
commit 7062596236
3 changed files with 29 additions and 9 deletions

View File

@@ -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
}

View File

@@ -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

View File

@@ -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",