{"action":"created","issue":{"url":"https://api.github.com/repos/drush-ops/drush/issues/1145","labels_url":"https://api.github.com/repos/drush-ops/drush/issues/1145/labels{/name}","comments_url":"https://api.github.com/repos/drush-ops/drush/issues/1145/comments","events_url":"https://api.github.com/repos/drush-ops/drush/issues/1145/events","html_url":"https://github.com/drush-ops/drush/issues/1145","id":56510656,"number":1145,"title":"\"Unable to copy\" if drush make fails to set mtime of copied file","user":{"login":"xurizaemon","id":105608,"avatar_url":"https://avatars.githubusercontent.com/u/105608?v=3","gravatar_id":"","url":"https://api.github.com/users/xurizaemon","html_url":"https://github.com/xurizaemon","followers_url":"https://api.github.com/users/xurizaemon/followers","following_url":"https://api.github.com/users/xurizaemon/following{/other_user}","gists_url":"https://api.github.com/users/xurizaemon/gists{/gist_id}","starred_url":"https://api.github.com/users/xurizaemon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xurizaemon/subscriptions","organizations_url":"https://api.github.com/users/xurizaemon/orgs","repos_url":"https://api.github.com/users/xurizaemon/repos","events_url":"https://api.github.com/users/xurizaemon/events{/privacy}","received_events_url":"https://api.github.com/users/xurizaemon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/drush-ops/drush/labels/area-make","name":"area-make","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-04T10:44:37Z","updated_at":"2015-03-24T18:08:38Z","closed_at":"2015-03-24T18:08:38Z","body":"## Motivation\r\n\r\n_drush_recursive_copy() fails if mtime preservation is unsuccessful; PHP touch() [won't touch a file if not owned by the current user](http://php.net/manual/de/function.touch.php#86781) and this can prevent drush make etc from succeeding where it otherwise could.\r\n\r\nIn [d.o#1914470](https://www.drupal.org/node/1914470) Drush introduced preserving mtime of copied files, and fails _drush_recursive_copy() if the touch() to set mtime is not successful.\r\n\r\nThe outcome is that PHP's touch() behaviour causes inconsistency between how Drush behaves and how other UNIX tools behave; two users who can otherwise operate on the same files by virtue of regular FS permissions are not able to use Drush make to update a shared codebase.\r\n\r\n## Proposed resolution\r\n\r\nTry to preserve mtime, but don't bail out if it fails. (Alternatively, exec UNIX touch instead of PHP touch()?)\r\n\r\n## Demonstration\r\n\r\nUsers _chris_ and _gemma_ share primary group `www-editors` and are collaborating on a shared codebase. When the files are writable but not owned by the current user, downloading a module to overwrite works using `drush dl` but not when using `drush make`.\r\n\r\nConfirm that users share a primary group:\r\n```\r\nchris:/tmp$ groups\r\nwww-editors chris\r\n$ groups gemma\r\ngemma : www-editors gemma\r\n```\r\n\r\nDownload a couple of Drupal codebases as user _chris_.\r\n```\r\nchris:/tmp$ drush dl drupal --drupal-project-rename=example1\r\nProject drupal (7.34) downloaded to /tmp/example1.                                                                                                                       [success]\r\n\r\nchris:/tmp$ drush dl drupal --drupal-project-rename=example2\r\nProject drupal (7.34) downloaded to /tmp/example2.                                                                                                                       [success]\r\n```\r\n\r\nEnsure they are group-writable.\r\n```\r\nchris:/tmp$ chmod -R g+rw example[12]\r\n```\r\n\r\nDownload Views module to both example sites as user _chris_.\r\n```\r\nchris:/tmp$ cd example1\r\nchris@fudge:/tmp/example1$ drush dl views\r\nProject views (7.x-3.8) downloaded to /tmp/example1/sites/all/modules/views.                                                                                             [success]\r\nProject views contains 2 modules: views_ui, views.\r\n\r\nchris:/tmp/example1$ cd ../example2\r\nchris:/tmp/example2$ drush dl views\r\nProject views (7.x-3.8) downloaded to /tmp/example2/sites/all/modules/views.                                                                                             [success]\r\nProject views contains 2 modules: views_ui, views.\r\n```\r\n\r\nSwitch to user _gemma_.\r\n```\r\nchris:/tmp$ sudo su - gemma\r\ngemma:/tmp$ cd /tmp\r\n```\r\nConfirm _gemma_ should be able to write to these codebases.\r\n```\r\ngemma:/tmp$ ls -lAF example[12]/INSTALL.txt\r\n-rw-rw-r-- 1 chris www-editors 17995 Nov 20 09:24 example1/INSTALL.txt\r\n-rw-rw-r-- 1 chris www-editors 17995 Nov 20 09:24 example2/INSTALL.txt\r\ngemma:/tmp$ ls -lAF example[12]/sites/all/modules/\r\nexample1/sites/all/modules/:\r\ntotal 8\r\n-rw-rw-r--  1 chris www-editors  952 Nov 20 09:24 README.txt\r\ndrwxrwxr-x 14 chris www-editors 4096 Feb  5 10:21 views/\r\n\r\nexample2/sites/all/modules/:\r\ntotal 8\r\n-rw-rw-r--  1 chris www-editors  952 Nov 20 09:24 README.txt\r\ndrwxrwxr-x 14 chris www-editors 4096 Feb  5 10:22 views/\r\n```\r\nIn example1, use `drush dl` to fetch Views. _gemma_ is able to overwrite Views belonging to _chris_.\r\n```\r\ngemma:/tmp$ cd example1\r\ngemma:/tmp/example1$ drush dl views\r\nInstall location /tmp/example1/sites/all/modules/views already exists. Do you want to overwrite it? (y/n): y\r\nProject views (7.x-3.8) downloaded to /tmp/example1/sites/all/modules/views.                                                                                             [success]\r\nProject views contains 2 modules: views_ui, views.\r\n```\r\nIn example2, use `drush make` to fetch Views. _gemma_ is able to overwrite Views belonging to _chris_, but the make command bails out from `_drush_recursive_copy()` because `touch()` returns FALSE on detecting gemma is not the file owner.\r\n```\r\ngemma:/tmp$ cd ../example2\r\ngemma:/tmp/example2$ cat ../views.make\r\napi = 2\r\ncore = 7.x\r\n\r\nprojects[views][type] = module\r\nprojects[views][download][type] = git\r\nprojects[views][download][url] = http://git.drupal.org/project/views.git\r\nprojects[views][download][revision] = 7.x-3.x\r\n\r\ngemma:/tmp$ drush make --no-core ../views.make\r\nMake new site in the current directory? (y/n): y\r\nBeginning to build ../views.make.                                                                                                                                        [ok]\r\nviews cloned from http://git.drupal.org/project/views.git.                                                                                                               [ok]\r\nChecked out revision 7.x-3.x.                                                                                                                                            [ok]\r\nUnable to copy /tmp/make_tmp_1423085150_54d28e5e6daea/__build__/sites/all to ./sites/all.                                                                                [error]\r\nCannot move build into place.\r\n```\r\nIt's not obvious from the final output why example1 works and example2 fails, and even reading the code where it fails isn't clear unless the user knows that PHP `touch()` does not behave like UNIX `touch` if the current user is not the file owner."},"comment":{"url":"https://api.github.com/repos/drush-ops/drush/issues/comments/85626542","html_url":"https://github.com/drush-ops/drush/issues/1145#issuecomment-85626542","issue_url":"https://api.github.com/repos/drush-ops/drush/issues/1145","id":85626542,"user":{"login":"jonhattan","id":482058,"avatar_url":"https://avatars.githubusercontent.com/u/482058?v=3","gravatar_id":"","url":"https://api.github.com/users/jonhattan","html_url":"https://github.com/jonhattan","followers_url":"https://api.github.com/users/jonhattan/followers","following_url":"https://api.github.com/users/jonhattan/following{/other_user}","gists_url":"https://api.github.com/users/jonhattan/gists{/gist_id}","starred_url":"https://api.github.com/users/jonhattan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonhattan/subscriptions","organizations_url":"https://api.github.com/users/jonhattan/orgs","repos_url":"https://api.github.com/users/jonhattan/repos","events_url":"https://api.github.com/users/jonhattan/events{/privacy}","received_events_url":"https://api.github.com/users/jonhattan/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T18:08:38Z","updated_at":"2015-03-24T18:08:38Z","body":"Nice detective work"}}