From 42c639aa540753507a5aec2eae7d76e63a164041 Mon Sep 17 00:00:00 2001 From: WhatTheServer Date: Fri, 16 Apr 2021 23:26:10 -0400 Subject: [PATCH] Update install.py Add /root/.my.cnf for root/sudo passwordless mysql management support --- install/install.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/install/install.py b/install/install.py index c1fae0769..b8fa342ff 100755 --- a/install/install.py +++ b/install/install.py @@ -391,6 +391,24 @@ class preFlightsChecks: ### Put correct mysql passwords in settings file! + # This allows root/sudo users to be able to work with MySQL/MariaDB without hunting down the password like + # all the other control panels allow + # reference: https://oracle-base.com/articles/mysql/mysql-password-less-logins-using-option-files + mysql_my_root_cnf = '/root/.my.cnf' + mysql_root_pass_file = """ + [client] + user=root + password="%s" + """ % password + + with open(mysql_root_pass_file, 'w') as f: + f.write(mysql_root_pass_file) + os.chmod(mysql_root_pass_file, 0o600) + command = 'chown root:root %s' % mysql_root_pass_file + subprocess.call(shlex.split(command)) + + logging.InstallLog.writeToFile("Updating /root/.my.cnf!") + logging.InstallLog.writeToFile("Updating settings.py!") path = self.cyberPanelPath + "/CyberCP/settings.py"