clean redir pid with sudo only if port is < than 1024
This commit is contained in:
parent
697d8bde08
commit
0b1fffc6e3
1 changed files with 10 additions and 4 deletions
|
@ -13,9 +13,13 @@ module Vagrant
|
||||||
if redir_pids.any?
|
if redir_pids.any?
|
||||||
env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
|
env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
|
||||||
redir_pids.each do |pid|
|
redir_pids.each do |pid|
|
||||||
next unless is_redir_pid?(pid)
|
next unless is_redir_pid?(pid[0])
|
||||||
@logger.debug "Killing pid #{pid}"
|
@logger.debug "Killing pid #{pid[0]}"
|
||||||
system "sudo pkill -TERM -P #{pid}"
|
if pid[1]
|
||||||
|
system "sudo pkill -TERM -P #{pid[0]}"
|
||||||
|
else
|
||||||
|
system "pkill -TERM -P #{pid[0]}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@logger.info "Removing redir pids files"
|
@logger.info "Removing redir pids files"
|
||||||
|
@ -31,7 +35,9 @@ module Vagrant
|
||||||
|
|
||||||
def redir_pids
|
def redir_pids
|
||||||
@redir_pids = Dir[@env[:machine].data_dir.join('pids').to_s + "/redir_*.pid"].map do |file|
|
@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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue