Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.32
diff -u -p -r1.32 install.php
--- install.php	30 Dec 2006 09:06:22 -0000	1.32
+++ install.php	30 Dec 2006 09:13:06 -0000
@@ -17,6 +17,10 @@ require_once './includes/install.inc';
 function install_main() {
   global $profile, $install_locale;
   require_once './includes/bootstrap.inc';
+  $settings_file = './'. conf_path() .'/settings.php';
+  // If the settings file exists but is unreadable, try to change the
+  // permissions so that it is readable (i.e. the web server is the owner).
+  drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE);
   drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
   require_once './modules/system/system.install';
   require_once './includes/file.inc';
@@ -84,7 +88,6 @@ function install_main() {
   drupal_install_profile($profile, $modules);
 
   // Warn about settings.php permissions risk
-  $settings_file = './'. conf_path() .'/settings.php';
   if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE)) {
     drupal_set_message(st('All necessary changes to %file have been made, so you should now remove write permissions to this file. Failure to remove write permissions to this file is a security risk.', array('%file' => $settings_file)), 'error');
   }
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.143
diff -u -p -r1.143 bootstrap.inc
--- includes/bootstrap.inc	21 Dec 2006 22:20:19 -0000	1.143
+++ includes/bootstrap.inc	30 Dec 2006 09:13:06 -0000
@@ -235,7 +235,18 @@ function drupal_unset_globals() {
 function conf_init() {
   global $db_url, $db_prefix, $base_url, $base_path, $base_root, $conf, $installed_profile;
   $conf = array();
-  include_once './'. conf_path() .'/settings.php';
+  // Include using @ to avoid an error if settings.php is unreadable.
+  @include_once './'. conf_path() .'/settings.php';
+
+  if (!isset($db_url)) {
+    // settings.php was unreadable or does not exist.
+    $settings = './'. conf_path() .'/settings.php';
+    drupal_maintenance_theme();
+    drupal_set_title('Cannot read settings');
+    print theme('maintenance_page', '<p>The configuration file '. theme('placeholder', $settings) . (file_exists($settings)? ' is unreadable. Please add read permissions to the file using chmod or another file utility.' : ' does not exist. Please check that all files were downloaded and copied correctly.') .'</p>
+<p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>');
+    exit;
+  }
 
   if (isset($base_url)) {
     // Parse fixed base URL from settings.php.
Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.30
diff -u -p -r1.30 install.inc
--- includes/install.inc	8 Dec 2006 11:54:04 -0000	1.30
+++ includes/install.inc	30 Dec 2006 09:13:06 -0000
@@ -391,20 +391,21 @@ function drupal_verify_install_file($fil
 
   // Verify file permissions.
   if (isset($mask)) {
-    $masks = array(FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+    // File must exist for any of the other checks to make sense.
+    if ($mask & FILE_EXIST) {
+      if (!file_exists($file)) {
+        if ($type == 'dir') {
+          drupal_install_mkdir($file, $mask);
+        }
+        if (!file_exists($file)) {
+          return FALSE;
+        }
+      }
+    }
+    $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
     foreach ($masks as $current_mask) {
       if ($mask & $current_mask) {
         switch ($current_mask) {
-          case FILE_EXIST:
-            if (!file_exists($file)) {
-              if ($type == 'dir') {
-                drupal_install_mkdir($file, $mask);
-              }
-              if (!file_exists($file)) {
-                $return = FALSE;
-              }
-            }
-            break;
           case FILE_READABLE:
             if (!is_readable($file) && !drupal_install_fix_file($file, $mask)) {
               $return = FALSE;
