summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Gervais2013-08-16 21:44:42 +0200
committerChristopher Gervais2013-08-16 21:44:42 +0200
commitef408bbbd4c272acedd2171fe65135bb733f49fa (patch)
tree9b87ed5360e5734e1f82f42369b5872b2cd9a531
parentae02d17840e6cd15844cfe594040b6fd6dc455d0 (diff)
Issue #2048653: Ensure mysql is secure before proceeding with hostmaster install.dev/2048653
-rw-r--r--install.hostmaster.inc23
1 files changed, 23 insertions, 0 deletions
diff --git a/install.hostmaster.inc b/install.hostmaster.inc
index e349b71..d847caf 100644
--- a/install.hostmaster.inc
+++ b/install.hostmaster.inc
@@ -4,6 +4,29 @@
* @file install the hostmaster system
*/
+/**
+ * Implements drush_COMMAND_pre_validate().
+ *
+ * Ensure the database cannot be accessed by anonymous users, as it will
+ * otherwise fail later in the install, and thus be harder to recover from.
+ *
+ * @see Provision_Service_db_mysql::grant_host().
+ */
+function drush_provision_hostmaster_install_pre_validate() {
+ $command = sprintf('mysql -u intntnllyInvalid -h %s -e "SELECT VERSION()"', drush_get_option('aegir_db_host', 'localhost'));
+ drush_shell_exec($command);
+
+ if (preg_match("/Access denied for user 'intntnllyInvalid'@'([^']*)'/", implode('', drush_shell_exec_output()), $match)) {
+ return;
+ }
+ elseif (preg_match("/Host '([^']*)' is not allowed to connect to/", implode('', drush_shell_exec_output()), $match)) {
+ return;
+ }
+ else {
+ return drush_set_error('PROVISION_DB_CONNECT_FAIL', dt('Dummy connection failed to fail. Either your MySQL permissions are too lax, or the response was not understood. See http://is.gd/Y6i4FO for more information. %msg', array('%msg' => join("\n", drush_shell_exec_output()))));
+ }
+}
+
function drush_provision_hostmaster_install_validate($site = NULL) {
// set defaults for this whole script
// those are settings that are not prompted to the user but still overridable