diff --git a/lib/vagrant/config/ssh.rb b/lib/vagrant/config/ssh.rb index da504051a..4341bfbea 100644 --- a/lib/vagrant/config/ssh.rb +++ b/lib/vagrant/config/ssh.rb @@ -11,6 +11,11 @@ module Vagrant attr_writer :private_key_path attr_accessor :forward_agent attr_accessor :forward_x11 + attr_accessor :sudo_shell + + def initialize + @sudo_shell = "bash" + end def private_key_path File.expand_path(@private_key_path, env.root_path) diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 86ca5bde9..33709e7ca 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -79,7 +79,7 @@ module Vagrant :user_known_hosts_file => [], :paranoid => false, :config => false)) do |ssh| - yield SSH::Session.new(ssh) + yield SSH::Session.new(ssh, env) end end rescue Errno::ECONNREFUSED diff --git a/lib/vagrant/ssh/session.rb b/lib/vagrant/ssh/session.rb index ea62906fd..123bb213a 100644 --- a/lib/vagrant/ssh/session.rb +++ b/lib/vagrant/ssh/session.rb @@ -7,9 +7,11 @@ module Vagrant include Util::Retryable attr_reader :session + attr_reader :env - def initialize(session) + def initialize(session, env) @session = session + @env = env end # Executes a given command and simply returns true/false if the @@ -32,7 +34,7 @@ module Vagrant # of `sudo`. def sudo!(commands, options=nil, &block) 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 [commands].flatten.each do |command| ch2.send_data "#{command}\n" diff --git a/test/vagrant/ssh/session_test.rb b/test/vagrant/ssh/session_test.rb index 070ba2dbb..8c6880e41 100644 --- a/test/vagrant/ssh/session_test.rb +++ b/test/vagrant/ssh/session_test.rb @@ -3,9 +3,10 @@ require "test_helper" class SshSessionTest < Test::Unit::TestCase setup do @session = mock("session") + @env = vagrant_env @klass = Vagrant::SSH::Session - @instance = @klass.new(@session) + @instance = @klass.new(@session, @env) end context "exec!" do