Jeff Bonhag 4b7d55afaa Fixup paths to work with server-side Bash
This commit normalizes our Windows paths to use `/` instead of `\`.
These paths are compatible with both cmd and PowerShell, and are
required if the server-side shell is set to Bash.

The OpenSSH server executes all commands inside a default login shell
which cannot be controlled by the Vagrant configuration. So what ends up
getting executed on the server side looks something like this:

    "c:\\program files\\git\\bin\\bash.exe" -c "C:\\Windows\\Temp\\vagrant-ssh20200130-41670-1w5nsjy.bat"

By flipping the direction of the directory slashes, we end up with:

    "c:\\program files\\git\\bin\\bash.exe" -c "C:/Windows/Temp/vagrant-ssh20200130-43415-f1d5n2.bat"

This works whether the server-side shell is set to cmd, powershell, or
bash.
2020-03-04 15:08:03 -08:00

39 lines
1005 B
Ruby

require File.expand_path("../../../kernel_v2/config/ssh", __FILE__)
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%"'
else
@export_command_template = '$env:%ENV_KEY%="%ENV_VALUE%"'
end
end
super
end
def to_s
"WINSSH"
end
# Remove configuration options from regular SSH that are
# not used within this communicator
undef :forward_x11
undef :pty
end
end
end