From 3e22f424e62bae376f9686166cf8d60727600f49 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sun, 8 Jun 2014 23:27:25 -0300 Subject: [PATCH] driver: Escape synced folders with spaces Fix GH-291 --- CHANGELOG.md | 5 +++++ lib/vagrant-lxc/driver.rb | 2 ++ spec/unit/driver_spec.rb | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9bbdf0..82fb244 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ IMPROVEMENTS: [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) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 9ae5662..d921829 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -84,6 +84,8 @@ module Vagrant end 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"] end diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index c268071..c3f0b6f 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -160,7 +160,8 @@ describe Vagrant::LXC::Driver do describe 'folder sharing' do 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(: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(:expected_guest_path) { "vagrant" } 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" ] 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