Make upload directory for winssh communicator configurable

Fixes #8731
This commit is contained in:
Chris Roberts 2017-07-07 09:36:42 -07:00
parent 4f7938726e
commit bcc09e10e6
4 changed files with 16 additions and 2 deletions

View File

@ -33,7 +33,7 @@ module VagrantPlugins
tfile = Tempfile.new('vagrant-ssh')
remote_ext = shell == "powershell" ? "ps1" : "bat"
remote_name = "C:\\Windows\\Temp\\#{File.basename(tfile.path)}.#{remote_ext}"
remote_name = "#{machine_config_ssh.upload_directory}\\#{File.basename(tfile.path)}.#{remote_ext}"
if shell == "powershell"
base_cmd = "powershell -File #{remote_name}"

View File

@ -4,9 +4,17 @@ module VagrantPlugins
module CommunicatorWinSSH
class Config < VagrantPlugins::Kernel_V2::SSHConfig
attr_accessor :upload_directory
def initialize
super
@upload_directory = UNSET_VALUE
end
def finalize!
@shell = "cmd" if @shell == UNSET_VALUE
@sudo_command = "%c" if @sudo_command == UNSET_VALUE
@upload_directory = "C:\\Windows\\Temp" if @upload_directory == UNSET_VALUE
if @export_command_template == UNSET_VALUE
if @shell == "cmd"
@export_command_template = 'set %ENV_KEY%="%ENV_VALUE%"'

View File

@ -22,7 +22,8 @@ describe VagrantPlugins::CommunicatorWinSSH::Communicator do
double("winssh",
insert_key: false,
export_command_template: export_command_template,
shell: 'cmd'
shell: 'cmd',
upload_directory: "C:\\Windows\\Temp"
)
end
# Configuration mock

View File

@ -161,3 +161,8 @@ config.winssh.export_command_template = '$env:%ENV_KEY%="%ENV_VALUE%"'
with `sudo`. This defaults to `%c` (assumes vagrant user is an administator
and needs no escalation). The `%c` will be replaced by the command that is
being executed.
<hr>
`config.winssh.upload_directory` - The upload directory used on the guest
to store scripts for execute. This is set to `C:\Windows\Temp` by default.