From 40a1d2faf306d29c891be5474c747aee9c00f77c Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 26 Apr 2018 08:45:05 -0700 Subject: [PATCH] Default SMB version to 2.0 for linux guest mounts Fixes #8959 --- plugins/hosts/windows/cap/smb.rb | 6 ++++++ plugins/hosts/windows/plugin.rb | 2 +- test/unit/plugins/hosts/windows/cap/smb_test.rb | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/hosts/windows/cap/smb.rb b/plugins/hosts/windows/cap/smb.rb index 17fae3d69..639cd2b53 100644 --- a/plugins/hosts/windows/cap/smb.rb +++ b/plugins/hosts/windows/cap/smb.rb @@ -17,6 +17,12 @@ module VagrantPlugins true end + # Required options for mounting a share hosted on Windows + # NOTE: Windows deprecated smb 1.0 so a minimum of 2.0 must be enabled + def self.smb_mount_options(env) + ["vers=2.0"] + end + def self.smb_validate_password(env, machine, username, password) script_path = File.expand_path("../../scripts/check_credentials.ps1", __FILE__) args = [] diff --git a/plugins/hosts/windows/plugin.rb b/plugins/hosts/windows/plugin.rb index ffe1e3a17..78d9239e1 100644 --- a/plugins/hosts/windows/plugin.rb +++ b/plugins/hosts/windows/plugin.rb @@ -46,7 +46,7 @@ module VagrantPlugins Cap::SMB end - host_capability("windows", "smb_cleanup") do + host_capability("windows", "smb_mount_options") do require_relative "cap/smb" Cap::SMB end diff --git a/test/unit/plugins/hosts/windows/cap/smb_test.rb b/test/unit/plugins/hosts/windows/cap/smb_test.rb index c904bc205..a1822e643 100644 --- a/test/unit/plugins/hosts/windows/cap/smb_test.rb +++ b/test/unit/plugins/hosts/windows/cap/smb_test.rb @@ -34,6 +34,14 @@ Description : Not Vagrant Owned allow(subject).to receive(:sleep) end + describe ".smb_mount_options" do + it "should provide smb version of at least 2" do + result = subject.smb_mount_options(nil) + ver = result.detect{|i| i.start_with?("vers") }.to_s.split("=", 2).last.to_s.to_i + expect(ver).to be >= 2 + end + end + describe ".smb_installed" do context "when powershell version is greater than 2" do it "is valid installation" do