add grant host to db creation

This commit is contained in:
Ralf Becker 2008-11-18 19:58:11 +00:00
parent bc59bd9fb8
commit 92c5157b90
3 changed files with 40 additions and 35 deletions

View File

@ -1164,8 +1164,9 @@ class egw_db
* @param string $adminname name of database administrator user (optional)
* @param string $adminpasswd password for the database administrator user (optional)
* @param string $charset default charset for the database
* @param string $grant_host='localhost' host/ip of the webserver
*/
function create_database($adminname = '', $adminpasswd = '', $charset='')
function create_database($adminname = '', $adminpasswd = '', $charset='', $grant_host='localhost')
{
$currentUser = $this->User;
$currentPassword = $this->Password;
@ -1186,7 +1187,7 @@ class egw_db
$create .= ' DEFAULT CHARACTER SET '.$this->Link_ID->charset2mysql[$charset].';';
}
$sqls[] = $create;
$sqls[] = "GRANT ALL ON `$currentDatabase`.* TO $currentUser@localhost IDENTIFIED BY ".$this->quote($currentPassword);
$sqls[] = "GRANT ALL ON `$currentDatabase`.* TO $currentUser@'$grant_host' IDENTIFIED BY ".$this->quote($currentPassword);
$meta_db = 'mysql';
break;
default:

View File

@ -113,6 +113,7 @@ abstract class setup_cmd extends admin_cmd
{
if (!is_object($GLOBALS['egw_setup']))
{
require_once(EGW_INCLUDE_ROOT.'/setup/inc/class.setup.inc.php');
$GLOBALS['egw_setup'] = new setup(true,true);
}
self::$egw_setup = $GLOBALS['egw_setup'];

View File

@ -40,9 +40,10 @@ class setup_cmd_database extends setup_cmd
* @param string $db_root=null
* @param string $db_root_pw=null
* @param string $sub_command='create_db' 'create_db', 'test_db', 'test_db_root'
* @param string $db_grant_host='localhost' host/ip of webserver for grant
*/
function __construct($domain,$db_type=null,$db_host=null,$db_port=null,$db_name=null,$db_user=null,$db_pass=null,
$db_root=null,$db_root_pw=null,$sub_command='create_db')
$db_root=null,$db_root_pw=null,$sub_command='create_db',$db_grant_host='localhost')
{
if (!is_array($domain))
{
@ -56,7 +57,8 @@ class setup_cmd_database extends setup_cmd
'db_pass' => $db_pass,
'db_root' => $db_root,
'db_root_pw' => $db_root_pw,
'sub_command' => $sub_command
'sub_command' => $sub_command,
'db_grant_host' => $db_grant_host,
);
}
//echo __CLASS__.'::__construct()'; _debug_array($domain);
@ -160,7 +162,7 @@ class setup_cmd_database extends setup_cmd
catch (egw_exception_wrong_userinput $e) {
// db or user not working --> connect as root and create it
try {
$this->test_db->create_database($this->db_root,$this->db_root_pw,$this->db_charset);
$this->test_db->create_database($this->db_root,$this->db_root_pw,$this->db_charset,$this->db_grant_host);
$this->connect();
}
catch(egw_exception_wrong_userinput $e) {
@ -216,6 +218,7 @@ class setup_cmd_database extends setup_cmd
'db_root_pw' => '', // not really a default
'db_meta' => $meta_db,
'db_charset' => 'utf-8',
'db_grant_host' => 'localhost',
);
}