diff --git a/lib/vagrant-lxc/action/clear_forwarded_ports.rb b/lib/vagrant-lxc/action/clear_forwarded_ports.rb index e8cf7c1..64b4105 100644 --- a/lib/vagrant-lxc/action/clear_forwarded_ports.rb +++ b/lib/vagrant-lxc/action/clear_forwarded_ports.rb @@ -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 diff --git a/spec/unit/action/clear_forwarded_ports_spec.rb b/spec/unit/action/clear_forwarded_ports_spec.rb index 182ac3c..7f98e23 100644 --- a/spec/unit/action/clear_forwarded_ports_spec.rb +++ b/spec/unit/action/clear_forwarded_ports_spec.rb @@ -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