action/clear_forwarded_ports: Fix privileged port detection and simplify code [GH-259]
This commit is contained in:
parent
84bdb5cb22
commit
a0fe2f9cf0
2 changed files with 4 additions and 5 deletions
|
@ -35,9 +35,8 @@ module Vagrant
|
|||
|
||||
def redir_pids
|
||||
@redir_pids = Dir[@env[:machine].data_dir.join('pids').to_s + "/redir_*.pid"].map do |file|
|
||||
port_number = file.split(/[^\d]/).join
|
||||
privileged_port = true if Integer(port_number) > 1024
|
||||
a = [ File.read(file).strip.chomp , privileged_port ]
|
||||
port_number = File.basename(file).split(/[^\d]/).join
|
||||
[ File.read(file).strip.chomp , Integer(port_number) <= 1024 ]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ describe Vagrant::LXC::Action::ClearForwardedPorts do
|
|||
|
||||
context 'with a valid redir pid' do
|
||||
it 'kills known processes' do
|
||||
expect(subject).to have_received(:system).with("sudo pkill -TERM -P #{pid}")
|
||||
expect(subject).to have_received(:system).with("pkill -TERM -P #{pid}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe Vagrant::LXC::Action::ClearForwardedPorts do
|
|||
let(:pid_cmd) { 'sudo ls' }
|
||||
|
||||
it 'does not kill the process' do
|
||||
expect(subject).not_to have_received(:system).with("sudo pkill -TERM -P #{pid}")
|
||||
expect(subject).not_to have_received(:system).with("pkill -TERM -P #{pid}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue