driver: Escape synced folders with spaces

Fix GH-291
This commit is contained in:
Fabio Rehm 2014-06-08 23:27:25 -03:00
parent 212d31543e
commit 3e22f424e6
3 changed files with 16 additions and 1 deletions

View file

@ -6,6 +6,11 @@ IMPROVEMENTS:
[GH-294]: https://github.com/fgrehm/vagrant-lxc/pull/294 [GH-294]: https://github.com/fgrehm/vagrant-lxc/pull/294
BUG FIXES:
- Escape space characters for synced folders [[GH-291]]
[GH-291]: https://github.com/fgrehm/vagrant-lxc/issues/291
## [1.0.0.alpha.2](https://github.com/fgrehm/vagrant-lxc/compare/v1.0.0.alpha.1...v1.0.0.alpha.2) (May 13, 2014) ## [1.0.0.alpha.2](https://github.com/fgrehm/vagrant-lxc/compare/v1.0.0.alpha.1...v1.0.0.alpha.2) (May 13, 2014)

View file

@ -84,6 +84,8 @@ module Vagrant
end end
mount_options = Array(mount_options || ['bind']) mount_options = Array(mount_options || ['bind'])
host_path = host_path.to_s.gsub(' ', '\\\040')
guest_path = guest_path.gsub(' ', '\\\040')
@customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"] @customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"]
end end

View file

@ -160,7 +160,8 @@ describe Vagrant::LXC::Driver do
describe 'folder sharing' do describe 'folder sharing' do
let(:shared_folder) { {guestpath: '/vagrant', hostpath: '/path/to/host/dir'} } let(:shared_folder) { {guestpath: '/vagrant', hostpath: '/path/to/host/dir'} }
let(:ro_rw_folder) { {guestpath: '/vagrant/ro_rw', hostpath: '/path/to/host/dir', mount_options: ['ro', 'rw']} } let(:ro_rw_folder) { {guestpath: '/vagrant/ro_rw', hostpath: '/path/to/host/dir', mount_options: ['ro', 'rw']} }
let(:folders) { [shared_folder, ro_rw_folder] } let(:with_space_folder) { {guestpath: '/tmp/with space', hostpath: '/path/with space'} }
let(:folders) { [shared_folder, ro_rw_folder, with_space_folder] }
let(:rootfs_path) { Pathname('/path/to/rootfs') } let(:rootfs_path) { Pathname('/path/to/rootfs') }
let(:expected_guest_path) { "vagrant" } let(:expected_guest_path) { "vagrant" }
let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) } let(:sudo_wrapper) { double(Vagrant::LXC::SudoWrapper, run: true) }
@ -189,5 +190,12 @@ describe Vagrant::LXC::Driver do
"#{ro_rw_folder[:hostpath]} vagrant/ro_rw none ro,rw 0 0" "#{ro_rw_folder[:hostpath]} vagrant/ro_rw none ro,rw 0 0"
] ]
end end
it 'supports directories with spaces' do
expect(subject.customizations).to include [
'mount.entry',
"/path/with\\040space tmp/with\\040space none bind 0 0"
]
end
end end
end end