From cced76264559764b0c8017ee6df9f7a8c25ab417 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Thu, 11 Oct 2012 20:14:59 -0400 Subject: [PATCH] Fix Windows shell provisioning Resolves [GH-1036] [GH-1164] [GH-1181] Ported fixes from patches to 1-0-stable --- plugins/communicators/ssh/communicator.rb | 3 ++- plugins/provisioners/shell/provisioner.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 55513759f..0360c89e8 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -94,7 +94,8 @@ module VagrantPlugins @logger.debug("Uploading: #{from} to #{to}") scp_connect do |scp| - scp.upload!(from, to) + # Open file read only to fix issue [GH-1036] + scp.upload!(File.open(from, "r"), to) end rescue RuntimeError => e # Net::SCP raises a runtime error for this so the only way we have diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index 19a4c1096..51db5e4a0 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -60,6 +60,10 @@ module VagrantPlugins # Otherwise we have an inline script, we need to Tempfile it, # and handle it specially... file = Tempfile.new('vagrant-shell') + # Unless you set binmode, on a Windows host the shell script will + # have CRLF line endings instead of LF line endings, causing havoc + # when the guest executes it. This fixes [GH-1181]. + file.binmode begin file.write(config.inline) file.fsync