Fix issue with unknown terminal type output for sudo commands

This commit is contained in:
Mitchell Hashimoto 2011-02-16 16:23:08 -08:00
parent e6f2406694
commit 77a1b9a6ef
3 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,6 @@
## 0.7.3 (unreleased)
- Fix issue with unknown terminal type output for sudo commands.
## 0.7.2 (February 8, 2011)

View File

@ -65,8 +65,11 @@ module Vagrant
env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
vm.ssh.execute do |ssh|
ssh.sudo!(commands) do |channel, type, data|
ssh.check_exit_status(data, commands) if type == :exit_status
env.ui.info("#{data}: #{type}") if type != :exit_status
if type == :exit_status
ssh.check_exit_status(data, commands)
else
env.ui.info("#{data}: #{type}")
end
end
end
end

View File

@ -35,6 +35,9 @@ module Vagrant
def sudo!(commands, options=nil, &block)
channel = session.open_channel do |ch|
ch.exec("sudo #{env.config.ssh.sudo_shell} -l") do |ch2, success|
# Set the terminal
ch2.send_data "export TERM=vt100\n"
# Output each command as if they were entered on the command line
[commands].flatten.each do |command|
ch2.send_data "#{command}\n"
@ -85,6 +88,9 @@ module Vagrant
# Output stdout data to the block
channel.on_data do |ch2, data|
# This clears the screen, we want to filter it out.
data.gsub!("\e[H", "")
block.call(ch2, :stdout, data)
end