0

Currently I'm struggling with permission issues in my Drupal installation on a Drupal-VM (Vagrant + Virtual Box on Windows). I'm syncing with rsync which leads to owner and group vagrant of synced files and folders. Because apache is running with user www-data files cannot be written in in the public temp folder sites/default/files, which is owned by vagrant:vagrant. That's why I'm trying to change the group of synced files to www-data. How do I accomplish this?

My Environment

Vagrant 1.9.1
VirtualBox 5.1.14 r112924

My OS

Microsoft Windows [Version 10.0.14393]

Summary

I've already tried the following settings in config.yml:

vagrant_synced_folders: - local_path: C:\#\myproject destination: /var/www/myproject.dev type: rsync create: true options_override: group: www-data

or

vagrant_synced_folders: - local_path: C:\#\myproject destination: /var/www/myproject.dev type: rsync create: true group: www-data

These don't take effect after vagrant reload. When I check .vagrant/machines/mydrupalvmbox/virtualbox/syncedfolders group is still vagrant. Changing the group in this temp file and doing a vagrant rsync results the correct group for rsynced files and directories. But after vagrant reload those temp settings are gone and group vagrant is back again.

I've also tried to change the group via rsync_args with no success:

vagrant_synced_folders: - local_path: C:\#\myproject destination: /var/www/myproject.dev type: rsync create: true options_override: rsync__args: [ "--verbose", "--archive", "--delete", "--chmod=gu=rwX,o=rX", "--group", # required for the following command "--groupmap=*:www-data" ]

I get an error: Error: rsync: --groupmap=*:www-data: unknown option.

So what's the right setting?

Philipp Michael
  • 954
  • 1
  • 11
  • 22

2 Answers2

1

which version of rsync are you running ?

The groupmap option has been included in version 3.1.0 (see https://rsync.samba.org/ftp/rsync/src/rsync-3.1.0-NEWS)

- Added the --usermap/--groupmap/--chown options for manipulating file
  ownership during the copy.

upgrade your rsync version (if you're using cygwing, upgrade cygwin/rsync) and make sure you get an up-to-date version

rsync --version
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • I'm using version 3.0.8, so I will try to update. But the rsync__args way seems to complicated. Is there a way to set the general vagrant `group` setting for rsync? Because when I fill in the target group in `.vagrant/machines/mydrupalvmbox/virtualbox/syncedfolders`, files are synced with the right group. – Philipp Michael Mar 08 '17 at 10:44
0

In Drupal VM you have to use rsync__group inside of options_override:

vagrant_synced_folders:
  - local_path: C:\#\myproject
  // [...]
  options_override:
    rsync__group: www-data

See related issue: https://github.com/geerlingguy/drupal-vm/issues/1199

This might work in other vagrant boxes too.

Philipp Michael
  • 954
  • 1
  • 11
  • 22