folders/rsync: Shellescape guest paths
This allows users to have spaces or other special characters in destination paths on the guest.
This commit is contained in:
parent
1c0d0b8b9d
commit
7f1947fec2
|
@ -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]}")
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue