Use an array instead of map
This commit is contained in:
parent
2b9173e15a
commit
02a351841e
|
@ -139,7 +139,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
if ssh_info[:forward_env]
|
||||
command_options += ["-o", "SendEnv=" + ssh_info[:forward_env].keys().join(" ")]
|
||||
command_options += ["-o", "SendEnv=#{ssh_info[:forward_env].join(" ")}"]
|
||||
end
|
||||
|
||||
# Configurables -- extra_args should always be last due to the way the
|
||||
|
@ -179,8 +179,8 @@ module Vagrant
|
|||
|
||||
# Forward configured environment variables.
|
||||
if ssh_info[:forward_env]
|
||||
ssh_info[:forward_env].each do |host_var, guest_var|
|
||||
process.environment[guest_var] = ENV[guest_var]
|
||||
ssh_info[:forward_env].each do |key|
|
||||
process.environment[key] = ENV[key]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -328,28 +328,17 @@ module VagrantPlugins
|
|||
auth_methods << "publickey" if ssh_info[:private_key_path]
|
||||
auth_methods << "password" if ssh_info[:password]
|
||||
|
||||
# Build the environment
|
||||
env_revert = {}
|
||||
send_env_array = nil
|
||||
if ssh_info[:forward_agent]
|
||||
send_env_array = ssh_info[:forward_env].values()
|
||||
ssh_info[:forward_env].each do |host_var, guest_var|
|
||||
env_revert[guest_var] = ENV[guest_var]
|
||||
ENV[guest_var] = ENV[host_var]
|
||||
end
|
||||
end
|
||||
|
||||
# Build the options we'll use to initiate the connection via Net::SSH
|
||||
common_connect_opts = {
|
||||
auth_methods: auth_methods,
|
||||
config: false,
|
||||
forward_agent: ssh_info[:forward_agent],
|
||||
forward_env: ssh_info[:forward_env],
|
||||
keys: ssh_info[:private_key_path],
|
||||
keys_only: true,
|
||||
paranoid: false,
|
||||
password: ssh_info[:password],
|
||||
port: ssh_info[:port],
|
||||
send_env: send_env_array,
|
||||
timeout: 15,
|
||||
user_known_hosts_file: [],
|
||||
verbose: :debug,
|
||||
|
@ -442,11 +431,6 @@ module VagrantPlugins
|
|||
# This is raised if a private key type that Net-SSH doesn't support
|
||||
# is used. Show a nicer error.
|
||||
raise Vagrant::Errors::SSHKeyTypeNotSupported
|
||||
ensure
|
||||
# TODO: will this leak?
|
||||
env_revert.each do |guest_var, guest_value|
|
||||
ENV[guest_var] = guest_value
|
||||
end
|
||||
end
|
||||
|
||||
@connection = connection
|
||||
|
|
|
@ -67,8 +67,13 @@ is enabled. Defaults to false.
|
|||
|
||||
<hr>
|
||||
|
||||
`config.ssh.forward_env` - A hash of host environment variable names to guest
|
||||
environment variable names.
|
||||
`config.ssh.forward_env` - An array of host environment variables to forward to
|
||||
the guest. If you are familiar with OpenSSH, this corresponds to the `SendEnv`
|
||||
paramter.
|
||||
|
||||
```ruby
|
||||
config.ssh.forward_env = ["CUSTOM_VAR"]
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
|
|
Loading…
Reference in New Issue