fix setting of passwords in case mysql-access-hosts list gets changed, fixes #1407

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2014-04-14 14:35:12 +02:00
parent d73e5f8dc7
commit 69ec85ef19
2 changed files with 8 additions and 3 deletions

View File

@@ -63,8 +63,9 @@ class DbManagerMySQL {
* @param string $username
* @param string $password
* @param string $access_host
* @param bool $p_encrypted optional, whether the password is encrypted or not, default false
*/
public function grantPrivilegesTo($username = null, $password = null, $access_host = null) {
public function grantPrivilegesTo($username = null, $password = null, $access_host = null, $p_encrypted = false) {
// grant privileges
$stmt = Database::prepare("
GRANT ALL PRIVILEGES ON `" . $username . "`.*
@@ -72,7 +73,11 @@ class DbManagerMySQL {
");
Database::pexecute($stmt, array("username" => $username, "host" => $access_host));
// set passoword
$stmt = Database::prepare("SET PASSWORD FOR :username@:host = PASSWORD(:password)");
if ($p_encrypted) {
$stmt = Database::prepare("SET PASSWORD FOR :username@:host = :password");
} else {
$stmt = Database::prepare("SET PASSWORD FOR :username@:host = PASSWORD(:password)");
}
Database::pexecute($stmt, array("username" => $username, "host" => $access_host, "password" => $password));
}

View File

@@ -67,7 +67,7 @@ function correctMysqlUsers($mysql_access_host_array) {
$mysql_access_host = trim($mysql_access_host);
if (!in_array($mysql_access_host, $users[$username]['hosts'])) {
$dbm->getManager()->grantPrivilegesTo($username, $password, $mysql_access_host);
$dbm->getManager()->grantPrivilegesTo($username, $password, $mysql_access_host, true);
}
}