Commit 34941d1c authored by Adrian Rossouw's avatar Adrian Rossouw

Use the mysql 'current_user()' function to determine the hostname part of the...

 Use the mysql 'current_user()' function to determine the hostname part of the grant for new accounts.

This is more flexible and less brittle than trying to determine the correct information and pass it to the server.
parent a60f1caa
......@@ -261,15 +261,7 @@ function _provision_mysql_suggest_db_name($url) {
*
*/
function _provision_mysql_grant_host($db_host, $web_ip, $web_host) {
// The database hostname is localhost, not defined or on the same ip/host as the webserver.
if (in_array($db_host, array('127.0.0.1', 'localhost', '', $web_ip, $web_host))) {
$grant = 'localhost';
}
// if we have the web ip, use that first.
elseif ($web_ip) {
$grant = $web_ip;
} else {
$grant = gethostbyname($web_host);
}
return $grant;
$result = provision_db_result(provision_db_query("select current_user()"));
preg_match('/^.*@(.*)$/', $result, $matches);
return $matches[1];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment