Merge pull request #10487 from chrisroberts/f-powershell-encode

Use Base64#strict_encode64 instead of Base64#urlsafe_encode64 for PowerShell
This commit is contained in:
Chris Roberts 2018-12-07 16:28:37 -08:00 committed by GitHub
commit 2c62ab9441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -217,14 +217,14 @@ module Vagrant
stderr = File.join(dpath, "stderr.txt") stderr = File.join(dpath, "stderr.txt")
script = "& #{arg_list} ; exit $LASTEXITCODE;" script = "& #{arg_list} ; exit $LASTEXITCODE;"
script_content = Base64.urlsafe_encode64(script.encode("UTF-16LE", "UTF-8")) script_content = Base64.strict_encode64(script.encode("UTF-16LE", "UTF-8"))
# Wrap so we can redirect output to read later # Wrap so we can redirect output to read later
wrapper = "$p = Start-Process -FilePath powershell -ArgumentList @('-NoLogo', '-NoProfile', " \ wrapper = "$p = Start-Process -FilePath powershell -ArgumentList @('-NoLogo', '-NoProfile', " \
"'-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', '#{script_content}') " \ "'-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', '#{script_content}') " \
"-PassThru -WindowStyle Hidden -Wait -RedirectStandardOutput '#{stdout}' -RedirectStandardError '#{stderr}'; " \ "-PassThru -WindowStyle Hidden -Wait -RedirectStandardOutput '#{stdout}' -RedirectStandardError '#{stderr}'; " \
"if($p){ exit $p.ExitCode; }else{ exit 1 }" "if($p){ exit $p.ExitCode; }else{ exit 1 }"
wrapper_content = Base64.urlsafe_encode64(wrapper.encode("UTF-16LE", "UTF-8")) wrapper_content = Base64.strict_encode64(wrapper.encode("UTF-16LE", "UTF-8"))
powerup = "$p = Start-Process -FilePath powershell -ArgumentList @('-NoLogo', '-NoProfile', " \ powerup = "$p = Start-Process -FilePath powershell -ArgumentList @('-NoLogo', '-NoProfile', " \
"'-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', '#{wrapper_content}') " \ "'-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', '#{wrapper_content}') " \