diff --git a/plugins/guests/darwin/cap/mount_smb_shared_folder.rb b/plugins/guests/darwin/cap/mount_smb_shared_folder.rb index 5f1cdaec4..d2bab0806 100644 --- a/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +++ b/plugins/guests/darwin/cap/mount_smb_shared_folder.rb @@ -20,6 +20,9 @@ module VagrantPlugins end smb_password = Shellwords.shellescape(options[:smb_password]) + # Ensure password is scrubbed + Vagrant::Util::CredentialScrubber.sensitive(smb_password) + mount_options = options[:mount_options]; mount_command = "mount -t smbfs " + (mount_options ? "-o '#{mount_options.join(",")}' " : "") + diff --git a/plugins/guests/linux/cap/mount_smb_shared_folder.rb b/plugins/guests/linux/cap/mount_smb_shared_folder.rb index f2a2cb7c3..dfc592639 100644 --- a/plugins/guests/linux/cap/mount_smb_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_smb_shared_folder.rb @@ -22,6 +22,8 @@ module VagrantPlugins # If a domain is provided in the username, separate it username, domain = (options[:smb_username] || '').split('@', 2) smb_password = options[:smb_password] + # Ensure password is scrubbed + Vagrant::Util::CredentialScrubber.sensitive(smb_password) options[:mount_options] ||= [] if machine.env.host.capability?(:smb_mount_options) @@ -61,9 +63,8 @@ SCRIPT end end if status != 0 || no_such_device - clean_command = mount_command.gsub(smb_password, "PASSWORDHIDDEN") raise Vagrant::Errors::LinuxMountFailed, - command: clean_command, + command: mount_command, output: stderr end end diff --git a/plugins/guests/windows/cap/mount_shared_folder.rb b/plugins/guests/windows/cap/mount_shared_folder.rb index 4a313849b..f1088f6b8 100644 --- a/plugins/guests/windows/cap/mount_shared_folder.rb +++ b/plugins/guests/windows/cap/mount_shared_folder.rb @@ -18,6 +18,10 @@ module VagrantPlugins end def self.mount_smb_shared_folder(machine, name, guestpath, options) + if !options[:smb_password].to_s.empty? + # Ensure password is scrubbed + Vagrant::Util::CredentialScrubber.sensitive(options[:smb_password]) + end machine.communicate.execute("cmdkey /add:#{options[:smb_host]} /user:#{options[:smb_username]} /pass:#{options[:smb_password]}", {shell: :powershell, elevated: true}) mount_shared_folder(machine, name, guestpath, "\\\\#{options[:smb_host]}\\") end