Can now configure what shell to sudo with (default: bash)
This commit is contained in:
parent
c1373f4eca
commit
3c45df0a88
|
@ -11,6 +11,11 @@ module Vagrant
|
||||||
attr_writer :private_key_path
|
attr_writer :private_key_path
|
||||||
attr_accessor :forward_agent
|
attr_accessor :forward_agent
|
||||||
attr_accessor :forward_x11
|
attr_accessor :forward_x11
|
||||||
|
attr_accessor :sudo_shell
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@sudo_shell = "bash"
|
||||||
|
end
|
||||||
|
|
||||||
def private_key_path
|
def private_key_path
|
||||||
File.expand_path(@private_key_path, env.root_path)
|
File.expand_path(@private_key_path, env.root_path)
|
||||||
|
|
|
@ -79,7 +79,7 @@ module Vagrant
|
||||||
:user_known_hosts_file => [],
|
:user_known_hosts_file => [],
|
||||||
:paranoid => false,
|
:paranoid => false,
|
||||||
:config => false)) do |ssh|
|
:config => false)) do |ssh|
|
||||||
yield SSH::Session.new(ssh)
|
yield SSH::Session.new(ssh, env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Errno::ECONNREFUSED
|
rescue Errno::ECONNREFUSED
|
||||||
|
|
|
@ -7,9 +7,11 @@ module Vagrant
|
||||||
include Util::Retryable
|
include Util::Retryable
|
||||||
|
|
||||||
attr_reader :session
|
attr_reader :session
|
||||||
|
attr_reader :env
|
||||||
|
|
||||||
def initialize(session)
|
def initialize(session, env)
|
||||||
@session = session
|
@session = session
|
||||||
|
@env = env
|
||||||
end
|
end
|
||||||
|
|
||||||
# Executes a given command and simply returns true/false if the
|
# Executes a given command and simply returns true/false if the
|
||||||
|
@ -32,7 +34,7 @@ module Vagrant
|
||||||
# of `sudo`.
|
# of `sudo`.
|
||||||
def sudo!(commands, options=nil, &block)
|
def sudo!(commands, options=nil, &block)
|
||||||
channel = session.open_channel do |ch|
|
channel = session.open_channel do |ch|
|
||||||
ch.exec("sudo bash -l") do |ch2, success|
|
ch.exec("sudo #{env.config.ssh.sudo_shell} -l") do |ch2, success|
|
||||||
# Output each command as if they were entered on the command line
|
# Output each command as if they were entered on the command line
|
||||||
[commands].flatten.each do |command|
|
[commands].flatten.each do |command|
|
||||||
ch2.send_data "#{command}\n"
|
ch2.send_data "#{command}\n"
|
||||||
|
|
|
@ -3,9 +3,10 @@ require "test_helper"
|
||||||
class SshSessionTest < Test::Unit::TestCase
|
class SshSessionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@session = mock("session")
|
@session = mock("session")
|
||||||
|
@env = vagrant_env
|
||||||
|
|
||||||
@klass = Vagrant::SSH::Session
|
@klass = Vagrant::SSH::Session
|
||||||
@instance = @klass.new(@session)
|
@instance = @klass.new(@session, @env)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "exec!" do
|
context "exec!" do
|
||||||
|
|
Loading…
Reference in New Issue