adjust permissions for customer global mysql user to access existing databases
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
use Froxlor\Database\Database;
|
||||
use Froxlor\Database\DbManager;
|
||||
use Froxlor\Froxlor;
|
||||
use Froxlor\FroxlorLogger;
|
||||
use Froxlor\Install\Update;
|
||||
use Froxlor\Settings;
|
||||
|
||||
@@ -227,7 +228,7 @@ if (Froxlor::isDatabaseVersion('202411200')) {
|
||||
// require privileged access for target db-server
|
||||
Database::needRoot(true, $dbserver, true);
|
||||
// get DbManager
|
||||
$dbm = new DbManager($this->logger());
|
||||
$dbm = new DbManager(FroxlorLogger::getInstanceOf());
|
||||
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
|
||||
|
||||
@@ -334,7 +334,7 @@ class DbManagerMySQL
|
||||
Database::pexecute($sel_stmt, ['cid' => $cust['customerid']]);
|
||||
while ($dbdata = $sel_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$stmt = Database::prepare("
|
||||
GRANT CREATE ON `" . $dbdata['databasename'] . "`.* TO :username@:host
|
||||
GRANT ALL ON `" . $dbdata['databasename'] . "`.* TO :username@:host
|
||||
");
|
||||
Database::pexecute($stmt, [
|
||||
"username" => $username,
|
||||
@@ -348,6 +348,7 @@ class DbManagerMySQL
|
||||
* grant "CREATE" for prefix user to all existing databases of that customer
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $database
|
||||
* @param string $access_host
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
@@ -355,7 +356,7 @@ class DbManagerMySQL
|
||||
public function grantCreateToDb(string $username, string $database, string $access_host)
|
||||
{
|
||||
$stmt = Database::prepare("
|
||||
GRANT CREATE ON `" . $database . "`.* TO :username@:host
|
||||
GRANT ALL ON `" . $database . "`.* TO :username@:host
|
||||
");
|
||||
Database::pexecute($stmt, [
|
||||
"username" => $username,
|
||||
|
||||
Reference in New Issue
Block a user