clean redir pid with sudo only if port is < than 1024

This commit is contained in:
guerremdq 2014-04-29 00:02:16 -03:00
parent 697d8bde08
commit 0b1fffc6e3

View file

@ -13,9 +13,13 @@ module Vagrant
if redir_pids.any?
env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
redir_pids.each do |pid|
next unless is_redir_pid?(pid)
@logger.debug "Killing pid #{pid}"
system "sudo pkill -TERM -P #{pid}"
next unless is_redir_pid?(pid[0])
@logger.debug "Killing pid #{pid[0]}"
if pid[1]
system "sudo pkill -TERM -P #{pid[0]}"
else
system "pkill -TERM -P #{pid[0]}"
end
end
@logger.info "Removing redir pids files"
@ -31,7 +35,9 @@ module Vagrant
def redir_pids
@redir_pids = Dir[@env[:machine].data_dir.join('pids').to_s + "/redir_*.pid"].map do |file|
File.read(file).strip.chomp
port_number = file.split(/[^\d]/).join
privileged_port = true if Integer(port_number) > 1024
a = [ File.read(file).strip.chomp , privileged_port ]
end
end