Skip to content

Commit

Permalink
Fix issue with unknown terminal type output for sudo commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Feb 17, 2011
1 parent e6f2406 commit 77a1b9a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 0.7.3 (unreleased)


- Fix issue with unknown terminal type output for sudo commands.

## 0.7.2 (February 8, 2011)

Expand Down
7 changes: 5 additions & 2 deletions lib/vagrant/provisioners/chef_solo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ def run_chef_solo
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
Expand Down
6 changes: 6 additions & 0 deletions lib/vagrant/ssh/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def test?(command)
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"
Expand Down Expand Up @@ -85,6 +88,9 @@ def setup_channel_callbacks(channel, command, options, block)

# 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

Expand Down

0 comments on commit 77a1b9a

Please sign in to comment.