synced_folders/smb: verify PowerShell v3 is running or later [GH-3257]
This commit is contained in:
parent
32d86ca42b
commit
a1d9121852
|
@ -7,6 +7,7 @@ IMPROVEMENTS:
|
|||
to convey actual meaning.
|
||||
- commands/plugin: Listing plugins now has machine-readable output. [GH-3293]
|
||||
- guests/omnios: Mount NFS capability [GH-3282]
|
||||
- synced\_folders/smb: Verify PowerShell v3 or later is running. [GH-3257]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
|
|
|
@ -31,6 +31,22 @@ module Vagrant
|
|||
|
||||
Subprocess.execute(*command, &block)
|
||||
end
|
||||
|
||||
# Returns the version of PowerShell that is installed.
|
||||
#
|
||||
# @return [String]
|
||||
def self.version
|
||||
command = [
|
||||
"powershell",
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"$PSVersionTable.PSVersion.Major"
|
||||
].flatten
|
||||
|
||||
r = Subprocess.execute(*command)
|
||||
return nil if r.exit_code != 0
|
||||
return r.stdout.chomp
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,10 @@ module VagrantPlugins
|
|||
error_key(:powershell_error)
|
||||
end
|
||||
|
||||
class PowershellVersion < SMBError
|
||||
error_Key(:powershell_version)
|
||||
end
|
||||
|
||||
class WindowsHostRequired < SMBError
|
||||
error_key(:windows_host_required)
|
||||
end
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Write-Output $PSVersionTable.PSVersion.Major
|
|
@ -27,6 +27,15 @@ module VagrantPlugins
|
|||
return false
|
||||
end
|
||||
|
||||
psv = Vagrant::Util::PowerShell.version.to_i
|
||||
if psv < 3
|
||||
if raise_error
|
||||
raise Errors::PowershellVersion,
|
||||
version: psv.to_s
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@ en:
|
|||
Error:
|
||||
|
||||
%{stderr}
|
||||
powershell_version: |-
|
||||
PowerShell version 3 or later is required for SMB synced folders
|
||||
to work on Windows. You have version: '%{version}'. Please update
|
||||
your PowerShell installation.
|
||||
windows_admin_required: |-
|
||||
SMB shared folders require running Vagrant with administrative
|
||||
privileges. This is a limitation of Windows, since creating new
|
||||
|
|
Loading…
Reference in New Issue