diff --git a/plugins/guests/linux/cap/rsync.rb b/plugins/guests/linux/cap/rsync.rb index 424d20f46..bd3d6f9b1 100644 --- a/plugins/guests/linux/cap/rsync.rb +++ b/plugins/guests/linux/cap/rsync.rb @@ -1,3 +1,5 @@ +require "shellwords" + module VagrantPlugins module GuestLinux module Cap @@ -11,9 +13,8 @@ module VagrantPlugins end def self.rsync_pre(machine, opts) - machine.communicate.tap do |comm| - comm.sudo("mkdir -p '#{opts[:guestpath]}'") - end + guest_path = Shellwords.escape(opts[:guestpath]) + machine.communicate.sudo("mkdir -p #{guest_path}") end def self.rsync_post(machine, opts) @@ -21,8 +22,10 @@ module VagrantPlugins return end + guest_path = Shellwords.escape(opts[:guestpath]) + machine.communicate.sudo( - "find '#{opts[:guestpath]}' " + + "find #{guest_path} " + "'!' -type l -a " + "'(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " + "xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}") diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index aa6cb710b..46d7643c5 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -1,3 +1,5 @@ +require "shellwords" + require "vagrant/util/platform" require "vagrant/util/subprocess" @@ -43,6 +45,9 @@ module VagrantPlugins guestpath = machine.guest.capability(:rsync_scrub_guestpath, opts) end + # Shellescape + guestpath = Shellwords.escape(guestpath) + if Vagrant::Util::Platform.windows? # rsync for Windows expects cygwin style paths, always. hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)