Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsync does not respect ownership in certain cases. #3196

Closed
drpebcak opened this issue Mar 13, 2014 · 10 comments
Closed

rsync does not respect ownership in certain cases. #3196

drpebcak opened this issue Mar 13, 2014 · 10 comments

Comments

@drpebcak
Copy link

On an initial vagrant up, my synced folders act as expected - they are rysnced and chowned to deploy:users

config.vm.synced_folder '.', '/vagrant', type: 'rsync',
                                             rsync__exclude: '.git/',
                                             rsync__args: %w(--progress --perms --archive -z)
config.vm.synced_folder '/srv', '/srv', type: 'rsync', owner: 'deploy', group: 'users',
                                        rsync__exclude: '.git/',
                                        rsync__args: %w(--progress --perms --archive -z)

But after that, running vagrant reload or vagrant rsync gives this error (warning, EXTREMELY long error): https://gist.github.com/drpebcak/9537952

Essentially what it is doing is taking all my files and chowning them back to vagrant:vagrant, even though I don't want that!

@drpebcak
Copy link
Author

Incidentally, looks like if I prevent the folders from syncing initially, and then run vagrant rsync it doesn't pay attention to the values I set for ownership (it syncs them as vagrant:vagrant).

@drpebcak
Copy link
Author

Looks like I'm a stupid idiot who doesn't understand proper use of the --perms flag!

@drpebcak drpebcak reopened this Mar 14, 2014
@drpebcak
Copy link
Author

I'm really just too eager. This still happens even without the --perms flag (guess that means I did know what it was doing!).

@drpebcak
Copy link
Author

So there seems to be multiple problems with the way rsync-auto is implemented...

There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /srv/
Guest path: /srv
Command: rsync --progress --omit-dir-times --archive -z -e ssh -p 2222 -o StrictHostKeyChecking=no -i '/Users/tprice/.vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ /srv/ vagrant@127.0.0.1:/srv
Error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
36:b1:fe:51:83:71:61:3c:2b:46:f5:fd:04:0a:65:79.
Please contact your system administrator.
Add correct host key in /Users/tprice/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/tprice/.ssh/known_hosts:114
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
rsync: failed to set times on "/srv/restapi/etc": Operation not permitted (1)
rsync: failed to set times on "/srv/restapi/log": Operation not permitted (1)
rsync: failed to set times on "/srv/restapi/htdocs/images": Operation not permitted (1)
rsync: failed to set times on "/srv/sockets/config": Operation not permitted (1)
rsync: failed to set times on "/srv/sockets/log": Operation not permitted (1)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-42/rsync/main.c(992) [sender=2.6.9]

rsync-auto doesn't seem to obey the flags I specified for each folder with rsync__args, nor does it play well with the owner: and group: settings.

@drpebcak
Copy link
Author

I figured out a portion of this problem - OSX seems to come with an old version of rsync that tries to set times on symlinks, which fails miserably. I installed a newer version from brew and that rsync-auto problem went away.

However, I still receive the error message about remote host identification changing when I do a reload, and all my files get the ownership of vagrant:vagrant.

There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /srv/
Guest path: /srv
Command: rsync --progress --omit-dir-times --archive -z -l -t -e ssh -p 2222 -o StrictHostKeyChecking=no -i '/Users/tprice/.vagrant.d/insecure_private_key' --exclude .vagrant/ --exclude .git/ /srv/ vagrant@127.0.0.1:/srv
Error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
e3:17:c5:1f:4e:91:10:3f:3d:c5:af:d2:6a:bf:18:6d.
Please contact your system administrator.
Add correct host key in /Users/tprice/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/tprice/.ssh/known_hosts:114
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
rsync: failed to set times on "/srv/restapi/etc": Operation not permitted (1)
rsync: failed to set times on "/srv/restapi/log": Operation not permitted (1)
rsync: failed to set times on "/srv/restapi/htdocs/images": Operation not permitted (1)
rsync: failed to set times on "/srv/sockets/config": Operation not permitted (1)
rsync: failed to set times on "/srv/sockets/log": Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1236) [sender=3.1.0]

@thedavidmeister
Copy link

I've also seen this, where rsync sets file/folder permissions to vagrant:vagrant and so my provision scripts are fighting against rsync. The workaround for me was to stick all the folders I needed to enforce the permissions on behind a symlink but I don't think this is a good general solution.

@mitchellh
Copy link
Contributor

You have to set the owner/group options on the synced_folder and it will chown to this after it syncs. This was fixed in 1.5.2

@manuelderuiter
Copy link

This issue still exists with Vagrant 1.6.2 in conjunction with rsync-auto.

Platform: Windows 7 x86_64
Vagrant version: 1.6.2
Rsync version: 3.0.9 (host and client)
Vagrant file:

shared_folder_path = "./code/"
target_code_path = "/var/www/"

config.vm.synced_folder shared_folder_path, target_code_path,
    type: "rsync",
    owner: "tomcat7",
    group: "tomcat7"

vagrant rsync sets the permissions (tomcat7:tomcat7) correct while rsync-auto chowns all the files to vagrant:vagrant. It looks like rsync-auto is ignoring the owner/group options.

Also tried killing the vagrant box and provisioned it again, but same result.

@SiliconValet
Copy link

Still having the issue on OSX, Vagrant 1.6.3. Initi

@thedavidmeister
Copy link

It's only "fixed" if you also set "chown: false" in the rsync config. It's in the docs for 1.6+

@ghost ghost locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants