fix permissions of global mysql-user for customers; fixes #1286
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -734,7 +734,7 @@ opcache.validate_timestamps'),
|
||||
('panel', 'settings_mode', '0'),
|
||||
('panel', 'menu_collapsed', '1'),
|
||||
('panel', 'version', '2.2.5'),
|
||||
('panel', 'db_version', '202411200');
|
||||
('panel', 'db_version', '202412030');
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `panel_tasks`;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Database\DbManager;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\Install\Update;
|
||||
use Froxlor\Settings;
|
||||
@@ -209,3 +210,37 @@ if (Froxlor::isDatabaseVersion('202409280')) {
|
||||
|
||||
Froxlor::updateToDbVersion('202411200');
|
||||
}
|
||||
|
||||
if (Froxlor::isDatabaseVersion('202411200')) {
|
||||
|
||||
Update::showUpdateStep("Adjusting customer mysql global user");
|
||||
// get all customers that are not deactivated and that have at least one database (hence a global database-user)
|
||||
$customers = Database::query("
|
||||
SELECT DISTINCT c.loginname, c.allowed_mysqlserver
|
||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` c
|
||||
LEFT JOIN `" . TABLE_PANEL_DATABASES . "` d ON c.customerid = d.customerid
|
||||
WHERE c.deactivated = '0' AND d.id IS NOT NULL
|
||||
");
|
||||
while ($customer = $customers->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$current_allowed_mysqlserver = !empty($customer['allowed_mysqlserver']) ? json_decode($customer['allowed_mysqlserver'], true) : [];
|
||||
foreach ($current_allowed_mysqlserver as $dbserver) {
|
||||
// require privileged access for target db-server
|
||||
Database::needRoot(true, $dbserver, true);
|
||||
// get DbManager
|
||||
$dbm = new DbManager($this->logger());
|
||||
foreach (array_map('trim', explode(',', Settings::Get('system.mysql_access_host'))) as $mysql_access_host) {
|
||||
if ($dbm->getManager()->userExistsOnHost($customer['loginname'], $mysql_access_host)) {
|
||||
// deactivate temporarily
|
||||
$dbm->getManager()->disableUser($customer['loginname'], $mysql_access_host);
|
||||
// re-enable
|
||||
$dbm->getManager()->enableUser($customer['loginname'], $mysql_access_host, true);
|
||||
}
|
||||
}
|
||||
$dbm->getManager()->flushPrivileges();
|
||||
Database::needRoot(false);
|
||||
}
|
||||
}
|
||||
Update::lastStepStatus(0);
|
||||
|
||||
Froxlor::updateToDbVersion('202412030');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user