Commit 01da2ef6 authored by anarcat's avatar anarcat

check for user creation capability on verify, by juampy, closes 1261006

parent e53e73b3
......@@ -25,6 +25,8 @@ function db_drush_help($section) {
return dt('Unable to connect to database server.');
case 'error:PROVISION_CREATE_DB_FAILED' :
return dt('Unable to create new databases.');
case 'error:PROVISION_CREATE_DB_USER_FAILED' :
return dt('Unable to create new database users.');
case 'error:PROVISION_DROP_DB_FAILED' :
return dt('Unable to drop database.');
}
......@@ -57,6 +59,9 @@ class provisionService_db extends provisionService {
return TRUE;
}
/**
* Verifies database connection and commands
*/
function verify_server_cmd() {
if ($this->connect()) {
if ($this->can_create_database()) {
......@@ -65,6 +70,12 @@ class provisionService_db extends provisionService {
else {
drush_set_error('PROVISION_CREATE_DB_FAILED');
}
if ($this->can_grant_privileges()) {
drush_log(dt('Provision can create database users.'), 'message');;
}
else {
drush_set_error('PROVISION_CREATE_DB_USER_FAILED');
}
} else {
drush_set_error('PROVISION_CONNECT_DB_FAILED');
}
......
......@@ -34,6 +34,18 @@ class provisionService_db_mysql extends provisionService_db_pdo {
}
return FALSE;
}
/**
* Verifies that Aegir can grant privileges to a user on a database
*
* @return
* boolean TRUE if the check was successful
*/
function can_grant_privileges() {
$test = drush_get_option('aegir_db_prefix', 'site_');
$status = $this->grant($test, $test . 'user', $test . 'password', $test . 'host');
return $status;
}
function grant($name, $username, $password, $host = '') {
......
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