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 VagrantPlugins
|
||||||
module GuestLinux
|
module GuestLinux
|
||||||
module Cap
|
module Cap
|
||||||
|
@ -11,9 +13,8 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_pre(machine, opts)
|
def self.rsync_pre(machine, opts)
|
||||||
machine.communicate.tap do |comm|
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
comm.sudo("mkdir -p '#{opts[:guestpath]}'")
|
machine.communicate.sudo("mkdir -p #{guest_path}")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.rsync_post(machine, opts)
|
def self.rsync_post(machine, opts)
|
||||||
|
@ -21,8 +22,10 @@ module VagrantPlugins
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guest_path = Shellwords.escape(opts[:guestpath])
|
||||||
|
|
||||||
machine.communicate.sudo(
|
machine.communicate.sudo(
|
||||||
"find '#{opts[:guestpath]}' " +
|
"find #{guest_path} " +
|
||||||
"'!' -type l -a " +
|
"'!' -type l -a " +
|
||||||
"'(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
"'(' ! -user #{opts[:owner]} -or ! -group #{opts[:group]} ')' -print0 | " +
|
||||||
"xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}")
|
"xargs -0 -r chown #{opts[:owner]}:#{opts[:group]}")
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
require "vagrant/util/platform"
|
require "vagrant/util/platform"
|
||||||
require "vagrant/util/subprocess"
|
require "vagrant/util/subprocess"
|
||||||
|
|
||||||
|
@ -43,6 +45,9 @@ module VagrantPlugins
|
||||||
guestpath = machine.guest.capability(:rsync_scrub_guestpath, opts)
|
guestpath = machine.guest.capability(:rsync_scrub_guestpath, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Shellescape
|
||||||
|
guestpath = Shellwords.escape(guestpath)
|
||||||
|
|
||||||
if Vagrant::Util::Platform.windows?
|
if Vagrant::Util::Platform.windows?
|
||||||
# rsync for Windows expects cygwin style paths, always.
|
# rsync for Windows expects cygwin style paths, always.
|
||||||
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
|
||||||
|
|
Loading…
Reference in New Issue