From f3daf5fad74628ed605746a748a026d99bf881ed Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 21 Jun 2017 07:03:15 -0700 Subject: [PATCH 1/2] Rebuild command and arguments before exec on Windows Flat command can cause issues with arguments. Creating new string instances from arguments forces common encoding of all strings used for exec. Fixes #8690 --- lib/vagrant/util/safe_exec.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/vagrant/util/safe_exec.rb b/lib/vagrant/util/safe_exec.rb index f7f5bdb81..b494fc00a 100644 --- a/lib/vagrant/util/safe_exec.rb +++ b/lib/vagrant/util/safe_exec.rb @@ -41,14 +41,11 @@ module Vagrant end else if Vagrant::Util::Platform.windows? - @@logger.debug("Converting command and arguments to single string for exec") - @@logger.debug("Command: `#{command.inspect}` Args: `#{args.inspect}`") - full_command = "#{command} #{args.join(" ")}" - @@logger.debug("Converted command: #{full_command}") - Kernel.exec(full_command) - else - Kernel.exec(command, *args) + # Re-generate strings to ensure common encoding + command = "#{command}".force_encoding("UTF-8") + args = args.map{|arg| "#{arg}".force_encoding("UTF-8") } end + Kernel.exec(command, *args) end rescue *rescue_from # We retried already, raise the issue and be done From f341945a29721fac987a852b7dbe5aada8f73bb7 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 27 Jun 2017 19:10:18 -0700 Subject: [PATCH 2/2] Include debug logging of string conversions --- lib/vagrant/util/safe_exec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vagrant/util/safe_exec.rb b/lib/vagrant/util/safe_exec.rb index b494fc00a..53f0b2597 100644 --- a/lib/vagrant/util/safe_exec.rb +++ b/lib/vagrant/util/safe_exec.rb @@ -42,8 +42,11 @@ module Vagrant else if Vagrant::Util::Platform.windows? # Re-generate strings to ensure common encoding + @@logger.debug("Converting command and arguments to common UTF-8 encoding for exec.") + @@logger.debug("Command: `#{command.inspect}` Args: `#{args.inspect}`") command = "#{command}".force_encoding("UTF-8") args = args.map{|arg| "#{arg}".force_encoding("UTF-8") } + @@logger.debug("Converted - Command: `#{command.inspect}` Args: `#{args.inspect}`") end Kernel.exec(command, *args) end