From 8e7a297fb51bb49686b59af9cfb78a8f94709c54 Mon Sep 17 00:00:00 2001 From: matthewcodes Date: Wed, 28 Oct 2015 16:39:19 +0000 Subject: [PATCH 1/2] Fix for interpolated strings being used for username and passwords, this fix was made in commit 1dd081d but was removed by 1152b4e. This was causing passwords with $ in them to stop working as the dollar sign was getting stripped out --- plugins/communicators/winrm/communicator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/communicators/winrm/communicator.rb b/plugins/communicators/winrm/communicator.rb index b14b28efa..0131678a5 100644 --- a/plugins/communicators/winrm/communicator.rb +++ b/plugins/communicators/winrm/communicator.rb @@ -214,7 +214,7 @@ module VagrantPlugins "#{command}; exit $LASTEXITCODE".encode('UTF-16LE', 'UTF-8')) "powershell -executionpolicy bypass -file \"#{guest_script_path}\" " + - "-username \"#{shell.username}\" -password \"#{shell.password}\" " + + "-username \'#{shell.username}\' -password \'#{shell.password}\' " + "-encoded_command \"#{wrapped_encoded_command}\"" end From cbb03a02d4b42e350ed92f73ced05f3046100ae8 Mon Sep 17 00:00:00 2001 From: matthewcodes Date: Wed, 28 Oct 2015 16:46:43 +0000 Subject: [PATCH 2/2] Updating tests to check for single quote --- test/unit/plugins/communicators/winrm/communicator_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/plugins/communicators/winrm/communicator_test.rb b/test/unit/plugins/communicators/winrm/communicator_test.rb index e98f646b3..29c775463 100644 --- a/test/unit/plugins/communicators/winrm/communicator_test.rb +++ b/test/unit/plugins/communicators/winrm/communicator_test.rb @@ -88,7 +88,7 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do expect(shell).to receive(:upload).with(kind_of(String), "c:/tmp/vagrant-elevated-shell.ps1") expect(shell).to receive(:powershell) do |cmd| expect(cmd).to eq("powershell -executionpolicy bypass -file \"c:/tmp/vagrant-elevated-shell.ps1\" " + - "-username \"vagrant\" -password \"password\" -encoded_command \"ZABpAHIAOwAgAGUAeABpAHQAIAAkAEwAQQBTAFQARQBYAEkAVABDAE8ARABFAA==\"") + "-username \'vagrant\' -password \'password\' -encoded_command \"ZABpAHIAOwAgAGUAeABpAHQAIAAkAEwAQQBTAFQARQBYAEkAVABDAE8ARABFAA==\"") end.and_return({ exitcode: 0 }) expect(subject.execute("dir", { elevated: true })).to eq(0) end