core: accept passwords in ssh_info
This commit is contained in:
parent
32d8b507c1
commit
e115322e78
|
@ -280,6 +280,7 @@ module Vagrant
|
||||||
info[:host] = @config.ssh.host if @config.ssh.host
|
info[:host] = @config.ssh.host if @config.ssh.host
|
||||||
info[:port] = @config.ssh.port if @config.ssh.port
|
info[:port] = @config.ssh.port if @config.ssh.port
|
||||||
info[:username] = @config.ssh.username if @config.ssh.username
|
info[:username] = @config.ssh.username if @config.ssh.username
|
||||||
|
info[:password] = @config.ssh.password if @config.ssh.password
|
||||||
|
|
||||||
# We also set some fields that are purely controlled by Varant
|
# We also set some fields that are purely controlled by Varant
|
||||||
info[:forward_agent] = @config.ssh.forward_agent
|
info[:forward_agent] = @config.ssh.forward_agent
|
||||||
|
@ -291,7 +292,7 @@ module Vagrant
|
||||||
# Set the private key path. If a specific private key is given in
|
# Set the private key path. If a specific private key is given in
|
||||||
# the Vagrantfile we set that. Otherwise, we use the default (insecure)
|
# the Vagrantfile we set that. Otherwise, we use the default (insecure)
|
||||||
# private key, but only if the provider didn't give us one.
|
# private key, but only if the provider didn't give us one.
|
||||||
if !info[:private_key_path]
|
if !info[:private_key_path] && !info[:password]
|
||||||
if @config.ssh.private_key_path
|
if @config.ssh.private_key_path
|
||||||
info[:private_key_path] = @config.ssh.private_key_path
|
info[:private_key_path] = @config.ssh.private_key_path
|
||||||
else
|
else
|
||||||
|
@ -300,6 +301,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
# Setup the keys
|
# Setup the keys
|
||||||
|
info[:private_key_path] ||= []
|
||||||
if !info[:private_key_path].is_a?(Array)
|
if !info[:private_key_path].is_a?(Array)
|
||||||
info[:private_key_path] = [info[:private_key_path]]
|
info[:private_key_path] = [info[:private_key_path]]
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,12 +5,14 @@ module VagrantPlugins
|
||||||
attr_accessor :port
|
attr_accessor :port
|
||||||
attr_accessor :private_key_path
|
attr_accessor :private_key_path
|
||||||
attr_accessor :username
|
attr_accessor :username
|
||||||
|
attr_accessor :password
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@host = UNSET_VALUE
|
@host = UNSET_VALUE
|
||||||
@port = UNSET_VALUE
|
@port = UNSET_VALUE
|
||||||
@private_key_path = UNSET_VALUE
|
@private_key_path = UNSET_VALUE
|
||||||
@username = UNSET_VALUE
|
@username = UNSET_VALUE
|
||||||
|
@password = UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
|
@ -18,6 +20,7 @@ module VagrantPlugins
|
||||||
@port = nil if @port == UNSET_VALUE
|
@port = nil if @port == UNSET_VALUE
|
||||||
@private_key_path = nil if @private_key_path == UNSET_VALUE
|
@private_key_path = nil if @private_key_path == UNSET_VALUE
|
||||||
@username = nil if @username == UNSET_VALUE
|
@username = nil if @username == UNSET_VALUE
|
||||||
|
@password = nil if @password == UNSET_VALUE
|
||||||
|
|
||||||
if @private_key_path && !@private_key_path.is_a?(Array)
|
if @private_key_path && !@private_key_path.is_a?(Array)
|
||||||
@private_key_path = [@private_key_path]
|
@private_key_path = [@private_key_path]
|
||||||
|
|
|
@ -279,7 +279,7 @@ describe Vagrant::Machine do
|
||||||
let(:provider_ssh_info) { {} }
|
let(:provider_ssh_info) { {} }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
provider.should_receive(:ssh_info).and_return(provider_ssh_info)
|
provider.stub(:ssh_info).and_return(provider_ssh_info)
|
||||||
end
|
end
|
||||||
|
|
||||||
[:host, :port, :username].each do |type|
|
[:host, :port, :username].each do |type|
|
||||||
|
@ -373,6 +373,15 @@ describe Vagrant::Machine do
|
||||||
instance.ssh_info[:private_key_path].should ==
|
instance.ssh_info[:private_key_path].should ==
|
||||||
[instance.env.default_private_key_path.to_s]
|
[instance.env.default_private_key_path.to_s]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not set any default private keys if a password is specified" do
|
||||||
|
provider_ssh_info[:private_key_path] = nil
|
||||||
|
instance.config.ssh.private_key_path = nil
|
||||||
|
instance.config.ssh.password = ""
|
||||||
|
|
||||||
|
expect(instance.ssh_info[:private_key_path]).to be_empty
|
||||||
|
expect(instance.ssh_info[:password]).to eql("")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue