diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e43589ab..094fda9a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ BUG FIXES: public/private networks. [GH-3207] - guests/linux: If SMB folder mounting fails, the password will no longer be shown in plaintext in the output. [GH-3203] + - guests/linux: SMB mount works with passwords with symbols. [GH-3202] - providers/hyperv: Check for PowerShell features. [GH-3398] - synced\_folders/smb: Only set the chmod properly by default on Windows if it isn't already set. [GH-3394] diff --git a/plugins/guests/linux/cap/mount_smb_shared_folder.rb b/plugins/guests/linux/cap/mount_smb_shared_folder.rb index ffafe1e3e..ae6d50d04 100644 --- a/plugins/guests/linux/cap/mount_smb_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_smb_shared_folder.rb @@ -1,3 +1,5 @@ +require "shellwords" + module VagrantPlugins module GuestLinux module Cap @@ -23,10 +25,12 @@ module VagrantPlugins mount_gid_old = "`id -g #{options[:group]}`" end + smb_password = Shellwords.shellescape(options[:smb_password]) + options[:mount_options] ||= [] options[:mount_options] << "sec=ntlm" options[:mount_options] << "username=#{options[:smb_username]}" - options[:mount_options] << "pass='#{options[:smb_password]}'" + options[:mount_options] << "pass='#{smb_password}'" # First mount command uses getent to get the group mount_options = "-o uid=#{mount_uid},gid=#{mount_gid}" @@ -62,7 +66,7 @@ module VagrantPlugins attempts += 1 if attempts > 10 command = mount_commands.join("\n") - command.gsub!(options[:smb_password], "PASSWORDHIDDEN") + command.gsub!(smb_password, "PASSWORDHIDDEN") raise Vagrant::Errors::LinuxMountFailed, command: command