adjust sql-queries for db-mgmt to be more compatible with mysql-dbms, fixes #1316, #1324, #1326

This commit is contained in:
Michael Kaufmann
2025-04-17 14:56:55 +02:00
parent 6068daece2
commit 76793c8992
11 changed files with 32 additions and 33 deletions

View File

@@ -777,7 +777,7 @@ class Customers extends ApiCommand implements ResourceEntity
if ($mysqls != 0) {
foreach ($allowed_mysqlserver as $dbserver) {
// require privileged access for target db-server
Database::needRoot(true, $dbserver, true);
Database::needRoot(true, $dbserver, false);
// get DbManager
$dbm = new DbManager($this->logger());
// give permission to the user on every access-host we have

View File

@@ -176,7 +176,7 @@ class DbManager
*/
public function createDatabase(string $loginname = null, string $password = null, int $dbserver = 0, int $last_accnumber = 0, string $global_user = "")
{
Database::needRoot(true, $dbserver, true);
Database::needRoot(true, $dbserver, false);
// check whether we shall create a random username
if (strtoupper(Settings::Get('customer.mysqlprefix')) == 'RANDOM') {
@@ -211,7 +211,7 @@ class DbManager
}
$this->getManager()->flushPrivileges();
Database::needRoot(false);
Database::needRoot();
$this->log->logAction(FroxlorLogger::USR_ACTION, LOG_INFO, "created database '" . $username . "'");

View File

@@ -115,12 +115,9 @@ class DbManagerMySQL
$grants = "SELECT, INSERT, UPDATE, DELETE, DROP, INDEX, ALTER";
}
$stmt = Database::prepare("
GRANT " . $grants . " ON `" . $username . ($grant_access_prefix ? '%' : '') . "`.* TO :username@:host
GRANT " . $grants . " ON `" . $username . ($grant_access_prefix ? '%' : '') . "`.* TO `" . $username . "`@`" . $access_host . "`
");
Database::pexecute($stmt, [
"username" => $username,
"host" => $access_host
]);
Database::pexecute($stmt);
if ($grant_access_prefix) {
$this->grantCreateToCustomerDbs($username, $access_host);
@@ -340,12 +337,9 @@ class DbManagerMySQL
Database::needRoot(true, $currentDbServer, false);
while ($dbdata = $sel_stmt->fetch(\PDO::FETCH_ASSOC)) {
$stmt = Database::prepare("
GRANT ALL ON `" . $dbdata['databasename'] . "`.* TO :username@:host
GRANT ALL ON `" . $dbdata['databasename'] . "`.* TO `" . $username . "`@`" . $access_host . "`
");
Database::pexecute($stmt, [
"username" => $username,
"host" => $access_host
]);
Database::pexecute($stmt);
}
}
}
@@ -361,12 +355,12 @@ class DbManagerMySQL
*/
public function grantCreateToDb(string $username, string $database, string $access_host)
{
$stmt = Database::prepare("
GRANT ALL ON `" . $database . "`.* TO :username@:host
");
Database::pexecute($stmt, [
"username" => $username,
"host" => $access_host
]);
// only grant permission if the user exists
if ($this->userExistsOnHost($username, $access_host)) {
$stmt = Database::prepare("
GRANT ALL ON `" . $database . "`.* TO `" . $username . "`@`" . $access_host . "`
");
Database::pexecute($stmt);
}
}
}

View File

@@ -2599,6 +2599,7 @@ try_fallback = true;
allow_username_mismatch = true;
path = "/var/lib/rspamd/dkim/$domain.$selector.key";
selector_map = "/etc/rspamd/dkim_selectors.map";
use_esld = false;
]]>
</content>
</file>

View File

@@ -4168,6 +4168,7 @@ try_fallback = true;
allow_username_mismatch = true;
path = "/var/lib/rspamd/dkim/$domain.$selector.key";
selector_map = "/etc/rspamd/dkim_selectors.map";
use_esld = false;
]]>
</content>
</file>

View File

@@ -3391,6 +3391,7 @@ try_fallback = true;
allow_username_mismatch = true;
path = "/var/lib/rspamd/dkim/$domain.$selector.key";
selector_map = "/etc/rspamd/dkim_selectors.map";
use_esld = false;
]]>
</content>
</file>

View File

@@ -3381,6 +3381,7 @@ try_fallback = true;
allow_username_mismatch = true;
path = "/var/lib/rspamd/dkim/$domain.$selector.key";
selector_map = "/etc/rspamd/dkim_selectors.map";
use_esld = false;
]]>
</content>
</file>

View File

@@ -2054,6 +2054,7 @@ try_fallback = true;
allow_username_mismatch = true;
path = "/var/lib/rspamd/dkim/$domain.$selector.key";
selector_map = "/etc/rspamd/dkim_selectors.map";
use_esld = false;
]]>
</content>
</file>