When running drush make --prepare-install ..., the command correctly creates the files directory (chmod 0777) and settings.php (chmod 0666).

However, after the build is complete, it is moved from /tmp to the 'live' directory by make_move_build(). That function eventually calls drush_copy_dir(), which in turn calls _drush_recursive_copy(), which contains the following code:

  // Preserve execute permission.
  if (!is_link($src) && !drush_is_windows()) {
    // Get execute bits of $src.
    $execperms = fileperms($src) & 0111;
    // Apply execute permissions if any.
    if ($execperms > 0) {
      $perms = fileperms($dest) | $execperms;
      chmod($dest, $perms);
    }
  }

So basically drush make --prepare-install ... sets writable flags on 'files' and 'settings.php', only to have the chmod undone by _drush_recursive_copy later on. :)

Comments

jonhattan’s picture

Version: 7.x-5.x-dev » 8.x-6.x-dev

This code is ok. Indeed it does what it says: preserve execution bits after a copy operation. See #1168812: Respect filesystem permissions for reference. Comments #6,#17, #22 and on.

--prepare-install should change permissions on final destination.

jonhattan’s picture

Status: Active » Fixed

Fixed in 65144bd and backported to Drush 5.

kristiaanvandeneynde’s picture

Thanks!

Shouldn't the last two lines be deleted here then?
Otherwise you chmod the pertaining items three times (+w, -w, +w).

/**
 * Prepare a Drupal installation, copying default.settings.php to settings.php.
 */
function make_prepare_install($build_path) {
  $default = make_tmp() . '/__build__/sites/default';
  drush_copy_dir($default . DIRECTORY_SEPARATOR . 'default.settings.php', $default . DIRECTORY_SEPARATOR . 'settings.php', TRUE);
  drush_mkdir($default . '/files');
  chmod($default . DIRECTORY_SEPARATOR . 'settings.php', 0666);
  chmod($default . DIRECTORY_SEPARATOR . 'files', 0777);
}
jonhattan’s picture

No, its fine as it is. We need to fully build in tmp. It is needed by --tar option, and also for tests. To adding a conditional for this two lines doesn't worth it IMO.

kristiaanvandeneynde’s picture

All right, good fix then :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.