From d0098bc59da18deedeec4ed0e9e7e45379186b4d Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 28 Jul 2016 13:42:15 +0200 Subject: [PATCH] Ticket 3432. Custom dbgrant origin for remote installations --- pandora_console/install.php | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/pandora_console/install.php b/pandora_console/install.php index 13cafd8b6e..bc2557d5d8 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -58,6 +58,14 @@ window.document.step2_form.db_action.options[window.document.step2_form.db_action.length-1].selected=1; ChangeDBDrop(window.document.step2_form.db_action); } + function CheckDBhost(value){ + if (( value != "localhost") && ( value != "127.0.0.1")) { + document.getElementById('tr_dbgrant').style["display"] = "block"; + } + else { + document.getElementById('tr_dbgrant').style["display"] = "none"; + } + }
@@ -697,23 +705,24 @@ function install_step3() { DB Hostname
- + DB Name (pandora by default)
"; - if ($_SERVER['SERVER_ADDR'] == 'localhost' || $_SERVER['SERVER_ADDR'] == '127.0.0.1') { + + // the field dbgrant is only shown when the DB host is different from 127.0.0.1 or localhost + echo " + DB Host Access
+ + + "; + - echo "DB Host Access
- Ignored if DB Hostname is localhost - "; - } else { - - echo " - Drop Database if exists
- "; - } + echo " Drop Database if exists
+ + "; echo "Full path to HTTP publication directory
For example /var/www/pandora_console/ @@ -845,9 +854,9 @@ function install_step4() { } $random_password = random_name (8); - $host = 'localhost'; - if ($dbhost != 'localhost') - $host = $dbgrant; + $host = $dbhost; // set default granted origin to the origin of the queries + if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) + $host = $dbgrant; // if the granted origin is different from local machine, set the valid origin $step5 = mysql_query ("GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host IDENTIFIED BY '".$random_password."'"); mysql_query ("FLUSH PRIVILEGES");