Mark passwords as sensitive within guest capabilities

This commit is contained in:
Chris Roberts 2017-12-21 12:49:34 -08:00
parent 88d2b3676f
commit 2caf109a03
3 changed files with 10 additions and 2 deletions

View File

@ -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(",")}' " : "") +

View File

@ -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

View File

@ -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