Merge pull request #7712 from mwrock/executor
fix #7489 preventing winrm connection leakage
This commit is contained in:
commit
6e6b35f1c5
|
@ -56,12 +56,16 @@ module VagrantPlugins
|
|||
def powershell(command, &block)
|
||||
# Ensure an exit code
|
||||
command += "\r\nif ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }"
|
||||
session.create_executor do |executor|
|
||||
execute_with_rescue(executor.method("run_powershell_script"), command, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def cmd(command, &block)
|
||||
session.create_executor do |executor|
|
||||
execute_with_rescue(executor.method("run_cmd"), command, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def wql(query, &block)
|
||||
retryable(tries: @config.max_tries, on: @@exceptions_to_retry_on, sleep: @config.retry_delay) do
|
||||
|
@ -172,10 +176,6 @@ module VagrantPlugins
|
|||
@session ||= new_session
|
||||
end
|
||||
|
||||
def executor
|
||||
@executor ||= session.create_executor
|
||||
end
|
||||
|
||||
def endpoint
|
||||
case @config.transport.to_sym
|
||||
when :ssl
|
||||
|
|
|
@ -6,7 +6,7 @@ require Vagrant.source_root.join("plugins/communicators/winrm/config")
|
|||
describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
||||
include_context "unit"
|
||||
|
||||
let(:session) { double("winrm_session", create_executor: executor) }
|
||||
let(:session) { double("winrm_session") }
|
||||
let(:executor) { double("command_executor") }
|
||||
let(:port) { config.transport == :ssl ? 5986 : 5985 }
|
||||
let(:config) {
|
||||
|
@ -22,6 +22,8 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
|||
end
|
||||
}
|
||||
|
||||
before { allow(session).to receive(:create_executor).and_yield(executor) }
|
||||
|
||||
subject do
|
||||
described_class.new('localhost', port, config).tap do |comm|
|
||||
allow(comm).to receive(:new_session).and_return(session)
|
||||
|
|
Loading…
Reference in New Issue