diff --git a/plugins/synced_folders/smb/errors.rb b/plugins/synced_folders/smb/errors.rb index f660b46e5..14704b9bb 100644 --- a/plugins/synced_folders/smb/errors.rb +++ b/plugins/synced_folders/smb/errors.rb @@ -6,6 +6,10 @@ module VagrantPlugins error_namespace("vagrant_sf_smb.errors") end + class SMBNotSupported < SMBError + error_key(:not_supported) + end + class DefineShareFailed < SMBError error_key(:define_share_failed) end diff --git a/plugins/synced_folders/smb/synced_folder.rb b/plugins/synced_folders/smb/synced_folder.rb index dcbb903c6..29a60982a 100644 --- a/plugins/synced_folders/smb/synced_folder.rb +++ b/plugins/synced_folders/smb/synced_folder.rb @@ -6,6 +6,8 @@ require "log4r" require "vagrant/util/platform" require "vagrant/util/powershell" +require_relative "errors" + module VagrantPlugins module SyncedFolderSMB class SyncedFolder < Vagrant.plugin("2", :synced_folder) @@ -13,7 +15,6 @@ module VagrantPlugins super @logger = Log4r::Logger.new("vagrant::synced_folders::smb") - @creds = {} end def usable?(machine, raise_error=false) @@ -23,7 +24,7 @@ module VagrantPlugins return true if machine.env.host.capability?(:smb_installed) && machine.env.host.capability(:smb_installed) return false if !raise_error - raise Vagrant::Errors::SMBNotSupported + raise Errors::SMBNotSupported end def prepare(machine, folders, opts) @@ -53,13 +54,13 @@ module VagrantPlugins data[:smb_password] ||= smb_password # Register password as sensitive - Vagrant::Util::CredentialScrubber.sensitive(smb_password) + Vagrant::Util::CredentialScrubber.sensitive(data[:smb_password]) end machine.env.host.capability(:smb_prepare, machine, folders, opts) end - def enable(machine, folders, nfsopts) + def enable(machine, folders, opts) machine.ui.output(I18n.t("vagrant_sf_smb.mounting")) # Make sure that this machine knows this dance @@ -99,10 +100,7 @@ module VagrantPlugins ssh_info = machine.ssh_info folders.each do |id, data| - data = data.dup data[:smb_host] ||= host_ip - data[:smb_username] ||= @creds[:username] - data[:smb_password] ||= @creds[:password] # Default the owner/group of the folder to the SSH user data[:owner] ||= ssh_info[:username] diff --git a/templates/locales/synced_folder_smb.yml b/templates/locales/synced_folder_smb.yml index 736640054..65c82de35 100644 --- a/templates/locales/synced_folder_smb.yml +++ b/templates/locales/synced_folder_smb.yml @@ -1,5 +1,9 @@ en: vagrant_sf_smb: + not_supported: |- + It appears your machine doesn't support SMB, or there is not an + adapter to enable SMB on this machine for Vagrant. Ensure SMB + host functionality is available on this machine and try again. mounting: |- Mounting SMB shared folders... mounting_single: |-