guests/darwin: Shellescape guest path for rsync

This commit is contained in:
Seth Vargo 2016-06-25 15:23:28 -04:00
parent 619c7a5b26
commit d1a071d403
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
1 changed files with 7 additions and 4 deletions

View File

@ -1,3 +1,5 @@
require "shellwords"
module VagrantPlugins
module GuestDarwin
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]}' '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
"find #{guest_path} '(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
"xargs -0 chown #{opts[:owner]}:#{opts[:group]}")
end
end