From 00d73eabdad95f9cf4b1a2ef42b3ed1d8fbf16f4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 13 Mar 2014 09:47:34 -0700 Subject: [PATCH] guests/linux: rsync only chown if invalid user/group [GH-3186] --- CHANGELOG.md | 2 ++ plugins/guests/linux/cap/rsync.rb | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fe81b11b..7f41c1b7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ BUG FIXES: - core: Downloads with user/password use the curl `-u` flag. [GH-3183] - core: `vagrant help` no longer loads the Vagrantfile. [GH-3180] - guests/darwin: Fix an exception when configuring networks. [GH-3143] + - guests/linux: Only chown folders/files in rsync if they don't + have the proper owner. [GH-3186] - hosts/linux: Unusual sed delimiter to avoid conflicts. [GH-3167] - providers/virtualbox: Make more internal interactions with VBoxManage retryable to avoid spurious VirtualBox errors. [GH-2831] diff --git a/plugins/guests/linux/cap/rsync.rb b/plugins/guests/linux/cap/rsync.rb index 46e6d48a4..a1d3c7ad7 100644 --- a/plugins/guests/linux/cap/rsync.rb +++ b/plugins/guests/linux/cap/rsync.rb @@ -6,18 +6,20 @@ module VagrantPlugins machine.communicate.test("which rsync") end - def self.rsync_pre(machine, folder_opts) + def self.rsync_pre(machine, opts) username = machine.ssh_info[:username] machine.communicate.tap do |comm| - comm.sudo("mkdir -p '#{folder_opts[:guestpath]}'") - comm.sudo("chown -R #{username} '#{folder_opts[:guestpath]}'") + comm.sudo("mkdir -p '#{opts[:guestpath]}'") + comm.sudo("find '#{opts[:guestpath]}' ! -user vagrant -print0 | " + + "xargs -0 -r chown -v #{username}:") end end def self.rsync_post(machine, opts) machine.communicate.tap do |comm| - comm.sudo("chown -R #{opts[:owner]}:#{opts[:group]} '#{opts[:guestpath]}'") + comm.sudo("find '#{opts[:guestpath]}' ! -user vagrant -print0 | " + + "xargs -0 -r chown -v #{opts[:owner]}:#{opts[:group]}") end end end