From 7d56dbb7554990c04d574d158ea77fda31608291 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 6 Jan 2012 21:42:25 -0800 Subject: [PATCH] Uploaded files now use temporary files rather than StringIO --- config/default.rb | 1 + lib/vagrant/communication/ssh.rb | 1 - lib/vagrant/config/ssh.rb | 1 + lib/vagrant/guest/debian.rb | 7 ++++++- lib/vagrant/guest/redhat.rb | 7 ++++++- lib/vagrant/provisioners/chef.rb | 20 ++++++++++++++++---- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/config/default.rb b/config/default.rb index 4ea69bd06..0ae59f90f 100644 --- a/config/default.rb +++ b/config/default.rb @@ -5,6 +5,7 @@ Vagrant::Config.run do |config| config.vagrant.ssh_session_cache = false config.ssh.username = "vagrant" + config.ssh.password = "vagrant" config.ssh.host = "127.0.0.1" config.ssh.guest_port = 22 config.ssh.max_tries = 100 diff --git a/lib/vagrant/communication/ssh.rb b/lib/vagrant/communication/ssh.rb index a40f19035..d4176dde5 100644 --- a/lib/vagrant/communication/ssh.rb +++ b/lib/vagrant/communication/ssh.rb @@ -153,7 +153,6 @@ module Vagrant ch2.on_request("exit-status") do |ch3, data| exit_status = data.read_long - yield :exit_status, exit_status if block_given? end # Set the terminal diff --git a/lib/vagrant/config/ssh.rb b/lib/vagrant/config/ssh.rb index 9f9287cc9..ad3214630 100644 --- a/lib/vagrant/config/ssh.rb +++ b/lib/vagrant/config/ssh.rb @@ -2,6 +2,7 @@ module Vagrant module Config class SSHConfig < Base attr_accessor :username + attr_accessor :password attr_accessor :host attr_accessor :port attr_accessor :guest_port diff --git a/lib/vagrant/guest/debian.rb b/lib/vagrant/guest/debian.rb index 95dd437c6..b1f59051f 100644 --- a/lib/vagrant/guest/debian.rb +++ b/lib/vagrant/guest/debian.rb @@ -1,4 +1,5 @@ require 'set' +require 'tempfile' require 'vagrant/util/template_renderer' @@ -27,7 +28,11 @@ module Vagrant # Perform the careful dance necessary to reconfigure # the network interfaces - vm.channel.upload(StringIO.new(entries.join("\n")), "/tmp/vagrant-network-entry") + temp = Tempfile.new("vagrant") + temp.write(entries.join("\n")) + temp.close + + vm.channel.upload(temp.path, "/tmp/vagrant-network-entry") # Bring down all the interfaces we're reconfiguring. By bringing down # each specifically, we avoid reconfiguring eth0 (the NAT interface) so diff --git a/lib/vagrant/guest/redhat.rb b/lib/vagrant/guest/redhat.rb index 5be274b28..56f783ce3 100644 --- a/lib/vagrant/guest/redhat.rb +++ b/lib/vagrant/guest/redhat.rb @@ -26,7 +26,12 @@ module Vagrant # temporary location. entry = TemplateRenderer.render("guests/redhat/network_#{network[:type]}", :options => network) - vm.channel.upload(StringIO.new(entry), "/tmp/vagrant-network-entry_#{network[:interface]}") + + temp = Tempfile.new("vagrant") + temp.write(entry) + temp.close + + vm.channel.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}") end # Bring down all the interfaces we're reconfiguring. By bringing down diff --git a/lib/vagrant/provisioners/chef.rb b/lib/vagrant/provisioners/chef.rb index 679c36163..c4fddcbfd 100644 --- a/lib/vagrant/provisioners/chef.rb +++ b/lib/vagrant/provisioners/chef.rb @@ -1,3 +1,5 @@ +require 'tempfile' + module Vagrant module Provisioners # This class is a base class where the common functionality shared between @@ -49,8 +51,13 @@ module Vagrant :no_proxy => config.no_proxy }.merge(template_vars)) - env[:vm].channel.upload(StringIO.new(config_file), - File.join(config.provisioning_path, filename)) + # Create a temporary file to store the data so we + # can upload it + temp = Tempfile.new("vagrant") + temp.write(config_file) + temp.close + + env[:vm].channel.upload(temp.path, File.join(config.provisioning_path, filename)) end def setup_json @@ -72,8 +79,13 @@ module Vagrant json = data.to_json - env[:vm].channel.upload(StringIO.new(json), - File.join(config.provisioning_path, "dna.json")) + # Create a temporary file to store the data so we + # can upload it + temp = Tempfile.new("vagrant") + temp.write(json) + temp.close + + env[:vm].channel.upload(temp.path, File.join(config.provisioning_path, "dna.json")) end end