Skip to content
Snippets Groups Projects

Issue #3186332: Create mysql user grants for @'::1'

Open Joe Price requested to merge issue/provision-3186332:3186332-ipv6-extra-host into 7.x-3.x
1 file
+ 25
0
Compare changes
  • Side-by-side
  • Inline
@@ -61,6 +61,10 @@ class Provision_Service_db_mysql extends Provision_Service_db_pdo {
@@ -61,6 +61,10 @@ class Provision_Service_db_mysql extends Provision_Service_db_pdo {
$extra_host = "127.0.0.1";
$extra_host = "127.0.0.1";
$success_extra_host = $this->query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s` IDENTIFIED BY '%s'", $name, $username, $extra_host, $password);
$success_extra_host = $this->query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s` IDENTIFIED BY '%s'", $name, $username, $extra_host, $password);
}
}
 
if ($host != "::1") {
 
$extra_host = "::1";
 
$success_extra_host = $this->query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s` IDENTIFIED BY '%s'", $name, $username, $extra_host, $password);
 
}
// Issue: https://github.com/omega8cc/provision/issues/2
// Issue: https://github.com/omega8cc/provision/issues/2
return $this->query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s` IDENTIFIED BY '%s'", $name, $username, $host, $password);
return $this->query("GRANT ALL PRIVILEGES ON `%s`.* TO `%s`@`%s` IDENTIFIED BY '%s'", $name, $username, $host, $password);
}
}
@@ -108,6 +112,27 @@ class Provision_Service_db_mysql extends Provision_Service_db_pdo {
@@ -108,6 +112,27 @@ class Provision_Service_db_mysql extends Provision_Service_db_pdo {
$success_extra_host = $this->query("DROP USER `%s`@`%s`", $username, $extra_host) && $success_extra_host;
$success_extra_host = $this->query("DROP USER `%s`@`%s`", $username, $extra_host) && $success_extra_host;
}
}
}
}
 
if ($host != "::1") {
 
$extra_host = "::1";
 
$success_extra_host = $this->query("REVOKE ALL PRIVILEGES ON `%s`.* FROM `%s`@`%s`", $name, $username, $extra_host);
 
 
// check if there are any privileges left for the user
 
$grants = $this->query("SHOW GRANTS FOR `%s`@`%s`", $username, $extra_host);
 
$grant_found = FALSE;
 
if ($grants) {
 
while ($grant = $grants->fetch()) {
 
// those are empty grants: just the user line
 
if (!preg_match("/^GRANT USAGE ON /", array_pop($grant))) {
 
// real grant, we shouldn't remove the user
 
$grant_found = TRUE;
 
break;
 
}
 
}
 
}
 
if (!$grant_found) {
 
$success_extra_host = $this->query("DROP USER `%s`@`%s`", $username, $extra_host) && $success_extra_host;
 
}
 
}
return $success;
return $success;
}
}
Loading