Database credentials using $_SERVER directive in settings.php are NULL, db_url has bad syntax, drushrc.php is incomplete
mig5 - November 4, 2009 - 10:05
| Project: | Provision |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Latest components from HEAD are writing this to the settings.php of the main aegir site on Verify task after install:
<?php
$databases['default']['default'] = array(
'driver' => urldecode($_SERVER['db_type']),
'database' => urldecode($_SERVER['db_name']),
'username' => urldecode($_SERVER['db_user']),
'password' => urldecode($_SERVER['db_passwd']),
'host' => urldecode($_SERVER['db_host']),
);
$db_url = "$_SERVER[db_type]://$_SERVER[db_user]:$_SERVER[db_passwd]@$_SERVER[db_host]/$_SERVER[db_name]";
?>First of all I think the lack of quotation marks in the $db_url is a problem anyway.
the relevant variables here, are in drushrc.php as follows:
<?php
$_SERVER['db_type'] = 'mysqli';
$_SERVER['db_host'] = 'localhost';
$_SERVER['db_user'] = 'aegir';
$_SERVER['db_passwd'] = 'ikillkittens';
$_SERVER['db_name'] = 'aegir';
?>However there is no < ?php tag, and no further drush-ish configuration!
Adding the < ?php tag and then doing a 'require('drushrc.php');' at the start of the settings.php provides the appropriate variables to Drupal to establish the db connection.. until then the variables are simply NULL
Wondering what the best way to fix this is.. clearly this is from the security-related stuff.. I'm a bit rusty after my holiday :)

#1
And of course the correct $db_url is
<?php$db_url = $_SERVER['db_type']."://".$_SERVER['db_user'].":".$_SERVER['db_passwd']."@".$_SERVER['db_host']."/".$_SERVER['db_name'];
?>
#2
no the string will work..
did you run the update function which re-verifies all your site
verify has special handling for this.
also. we are generating php code which is only processed when the site is loaded
#3
Per IRC discussion this is on a fresh install, including that of the server itself.
The Import task completes, of the main aegir site, but the Verify task fails after writing the settings.php. This means the vhost config, which apparently holds these settings now, has not yet been rewritten, so it's still a customised version of the apache2.txt from the Hostmaster package per the INSTALL.txt.
I presume this failed Verify task is also the reason for the malformed drushrc.php that *only* has the $_SERVER database parameters.
#4
Similar problem affects installation of new sites on a fresh 6.14 platform. Despite the 'rollback', it doesn't remove the site data either, probably coz it can't bootstrap it due to the dodgy configs
Task starts processingRunning: /usr/bin/php /var/aegir/drush/drush.php --root='/var/aegir/drupal-6.14' 'provision' 'install' 'a1.mig5-forge.net' --backend
The external command could not be executed due to an application error.
Drush bootstrap phase : _drush_bootstrap_drush()
Drush bootstrap phase : _drush_bootstrap_drupal_root()
Loading drushrc "/var/aegir/drupal-6.14/drushrc.php" into "drupal" scope.
Initialized Drupal 6.14 root directory at /var/aegir/drupal-6.14
Found command: provision install
Initializing drush commandfile: provision_apache
Undefined index: base_url
Initializing drush commandfile: provision_drupal
Initializing drush commandfile: provision_mysql
Undefined index: db_url
Including /var/aegir/.drush/provision/web_server/install.provision.inc
Including /var/aegir/.drush/provision/platform/install.provision.inc
Including /var/aegir/.drush/provision/db_server/install.provision.inc
(mig5 snipping irrelevancies here)
Granting privileges to site_73@localhost on site_73
Created site_73 database
Generate settings.php file
Changed permissions of settings.php to 0440
Change group ownership of settings.php to www-data
Drush bootstrap phase : _drush_bootstrap_drupal_site()
Initialized Drupal site a1.mig5-forge.net at sites/a1.mig5-forge.net
Including version specific file : /var/aegir/.drush/provision/platform/drupal/install_6.inc
Drush bootstrap phase : _drush_bootstrap_drupal_configuration()
Undefined index: db_type
Undefined index: db_name
Undefined index: db_user
Undefined index: db_passwd
Undefined index: db_host
Undefined index: db_type
Undefined index: db_user
Undefined index: db_passwd
Undefined index: db_host
Undefined index: db_name
parse_url(://:@/): Unable to parse URL
Drush command could not be completed.
Output from failed command : Fatal error: Unsupported operand types in /var/aegir/drush/includes/environment.inc on line 603
An error occurred at function : drush_hosting_hosting_task
Changes for drush_hosting_hosting_task module have been rolled back.
Command dispatch complete
Timer 'page' is 0.988 sec.
#5
This was a simple error, Adrian has fixed in CVS, and also he committed a fix that allowed the Install task to work where it didn't in #4
#6
Automatically closed -- issue fixed for 2 weeks with no activity.