From 392269a8eb4b691e64cd3ba8ff13c36dc2a754f0 Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Wed, 30 Apr 2014 19:35:02 -0700 Subject: [PATCH 1/2] Default the WinRM shell provisioner to privileged (elevated) --- plugins/provisioners/shell/provisioner.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index fab9f8920..d3f22a8d0 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -96,12 +96,10 @@ module VagrantPlugins exec_path.gsub!('/', '\\') exec_path = "c:#{exec_path}" if exec_path.start_with?("\\") - command = <<-EOH - $old = Get-ExecutionPolicy; - Set-ExecutionPolicy Unrestricted -force; - #{exec_path}#{args}; - Set-ExecutionPolicy $old -force - EOH + # For PowerShell scripts bypass the execution policy + command = "#{exec_path}#{args}" + command = "powershell -executionpolicy bypass -file #{command}" if + File.extname(exec_path).downcase == '.ps1' if config.path @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running", @@ -112,7 +110,7 @@ module VagrantPlugins end # Execute it with sudo - comm.sudo(command) do |type, data| + comm.sudo(command, elevated: config.privileged) do |type, data| handle_comm(type, data) end end From cc905d7923c0cfc9bef88ddebbfe6a176eefc822 Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Wed, 30 Apr 2014 19:39:37 -0700 Subject: [PATCH 2/2] Fix remote/downloaded shell scripts The temporary shell script that we downloaded the script too was being deleted twice, thus causing an error on the secondary delete. --- plugins/provisioners/shell/provisioner.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index d3f22a8d0..17034fa7b 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -141,8 +141,6 @@ module VagrantPlugins ensure download_path.delete if download_path.file? end - - download_path.delete elsif config.path # Just yield the path to that file... root_path = @machine.env.root_path