? 418302-copy-setttings-156.patch ? copy-settings-418302-154.patch ? sites/default/files ? sites/default/settings.php Index: includes/file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.226 diff -u -p -r1.226 file.inc --- includes/file.inc 22 Aug 2010 13:52:58 -0000 1.226 +++ includes/file.inc 30 Aug 2010 20:18:49 -0000 @@ -826,6 +826,22 @@ function file_unmanaged_copy($source, $d } /** + * Determines whether the owners of two files are identical. This works only on + * the local filesystem, not with stream wrapper URIs. + * + * @param $source + * A source file or directory. + * @param destination + * A destination file or directory. This must already exist. + * + * @return + * TRUE if the owners are identical, FALSE if they are not. + */ +function file_owners_identical($source, $destination) { + return fileowner($source) == fileowner($destination); +} + +/** * Given a relative path, construct a URI into Drupal's default files location. */ function file_build_uri($path) { Index: includes/install.core.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.core.inc,v retrieving revision 1.27 diff -u -p -r1.27 install.core.inc --- includes/install.core.inc 22 Aug 2010 15:31:18 -0000 1.27 +++ includes/install.core.inc 30 Aug 2010 20:18:49 -0000 @@ -1550,7 +1550,7 @@ function install_check_requirements($ins $exists = FALSE; // Verify that the directory exists. if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) { - // Check to make sure a settings.php already exists. + // Check if a settings.php file already exists. $file = $settings_file; if (drupal_verify_install_file($settings_file, FILE_EXIST)) { // If it does, make sure it is writable. @@ -1569,6 +1569,25 @@ function install_check_requirements($ins 'description' => st('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array('@drupal' => drupal_install_profile_distribution_name(), '%default-file' => $default_settings_file)), ); } + // If default.settings.php is readable and settings.php does not exist yet, + // we can try to copy it. + // @todo We should probably be using something like file_unmanaged_copy($default_settings_file, $settings_file, FILE_EXISTS_ERROR)) + // here, but it doesn't work at the moment. + elseif (!$exists && drupal_verify_install_file($conf_path, FILE_EXIST|FILE_WRITABLE, 'dir') && @copy($default_settings_file, $settings_file)) { + // Check if the copy was successfully performed and the owners of + // default.settings.php and the copied settings.php are identical. + // Additionally, make sure the settings file is writable. + if (file_owners_identical($default_settings_file, $settings_file)) { + $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE); + $exists = TRUE; + } + // If the file owners are not identical, delete the settings file. + // Otherwise, users on shared hosts might not be able to edit their + // settings file later on. The user will have to create it on their own. + else { + file_unmanaged_delete($settings_file); + } + } // If settings.php does not exist, throw an error. if (!$exists) { Index: modules/update/update.manager.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.manager.inc,v retrieving revision 1.24 diff -u -p -r1.24 update.manager.inc --- modules/update/update.manager.inc 29 Jul 2010 02:27:43 -0000 1.24 +++ modules/update/update.manager.inc 30 Aug 2010 20:18:49 -0000 @@ -416,7 +416,7 @@ function update_manager_update_ready_for // trying to install the code, there's no need to prompt for FTP/SSH // credentials. Instead, we instantiate a FileTransferLocal and invoke // update_authorize_run_update() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (file_owners_identical($project_real_location, conf_path())) { module_load_include('inc', 'update', 'update.authorize'); $filetransfer = new FileTransferLocal(DRUPAL_ROOT); update_authorize_run_update($filetransfer, $updates); @@ -593,7 +593,7 @@ function update_manager_install_form_sub // trying to install the code, there's no need to prompt for FTP/SSH // credentials. Instead, we instantiate a FileTransferLocal and invoke // update_authorize_run_install() directly. - if (fileowner($project_real_location) == fileowner(conf_path())) { + if (file_owners_identical($project_real_location, conf_path())) { module_load_include('inc', 'update', 'update.authorize'); $filetransfer = new FileTransferLocal(DRUPAL_ROOT); call_user_func_array('update_authorize_run_install', array_merge(array($filetransfer), $arguments));