summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-05-27 19:47:26 -0400
committerPaul Arthur <paul.arthur@flowerysong.com>2013-05-27 19:53:25 -0400
commit4caafd37a6782d463241ee6d1b4cfe6b9d7f1805 (patch)
tree762ded05668825457d01717d193a1cbe9516b767 /lib
parenteac07ede274d19840574da4b6a4593b7d632e711 (diff)
downloadampache-4caafd37a6782d463241ee6d1b4cfe6b9d7f1805.tar.gz
ampache-4caafd37a6782d463241ee6d1b4cfe6b9d7f1805.tar.bz2
ampache-4caafd37a6782d463241ee6d1b4cfe6b9d7f1805.zip
install: Fix GRANT for non-localhost servers
If we're not connecting locally, tell MySQL to allow our new user to connect from any host. Previously we restricted them to connecting from the database host, which is clearly wrong. It would be slightly better to properly restrict it to the Ampache host, but let's not overcomplicate the install and confuse the users.
Diffstat (limited to 'lib')
-rw-r--r--lib/install.lib.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/install.lib.php b/lib/install.lib.php
index 899e4925..d1352aa6 100644
--- a/lib/install.lib.php
+++ b/lib/install.lib.php
@@ -156,12 +156,12 @@ function install_insert_db($db_user = null, $db_pass = null, $overwrite = false)
// Check to see if we should create a user here
if (strlen($db_user) && strlen($db_pass)) {
$db_host = Config::get('database_hostname');
- if (strpos($db_host, '/') === 0) {
- $db_host = 'localhost';
- }
$sql = 'GRANT ALL PRIVILEGES ON `' . Dba::escape($database) . '`.* TO ' .
- "'" . Dba::escape($db_user) . "'@'" . Dba::escape($db_host) . "' " .
- "IDENTIFIED BY '" . Dba::escape($db_pass) . "' WITH GRANT OPTION";
+ "'" . Dba::escape($db_user) . "'";
+ if ($db_host == 'localhost' || strpos($db_host, '/') === 0) {
+ $sql .= "@'localhost'";
+ }
+ $sql .= "IDENTIFIED BY '" . Dba::escape($db_pass) . "' WITH GRANT OPTION";
if (!Dba::write($sql)) {
Error::add('general', sprintf(T_('Error: Unable to Insert %1$s with permissions to %2$s on %3$s %4$s'), $db_user, $database, $hostname, Dba::error()));
return false;