[DRE-commits] [vagrant-libvirt] 08/17: Make SSH for forwarded ports write to /dev/null

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:56:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.15
in repository vagrant-libvirt.

commit a7275aab03b853242fdc3e7a1097c04d73416632
Author: Brian Pitts <brian at polibyte.com>
Date:   Thu Jan 30 18:13:38 2014 -0600

    Make SSH for forwarded ports write to /dev/null
    
    If ssh inherits stdout from vagrant, then when you pipe vagrants output
    to another program ssh will also use that pipe. The receiving program
    will hang waiting on ssh to exit. To make reasoning about things easier,
    I have ruby start ssh directly instead of via a shell. Then I have
    spawn set stdin/stdout to /dev/null.
---
 lib/vagrant-libvirt/action/forward_ports.rb | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/vagrant-libvirt/action/forward_ports.rb b/lib/vagrant-libvirt/action/forward_ports.rb
index 165b69c..f976361 100644
--- a/lib/vagrant-libvirt/action/forward_ports.rb
+++ b/lib/vagrant-libvirt/action/forward_ports.rb
@@ -82,11 +82,12 @@ module VagrantPlugins
             -L #{host_ip}:#{host_port}:#{guest_ip}:#{guest_port}
             -N
           ).join(' ')
-          ssh_cmd = "ssh $(vagrant ssh-config #{machine}"\
-              "| awk '{print \" -o \"$1\"=\"$2}') #{params} 2>/dev/null"
+          # TODO get options without shelling out
+          options = `vagrant ssh-config #{machine} | awk '{printf " -o "$1"="$2}'`
+          ssh_cmd = "ssh #{options} #{params}"
 
           @logger.debug "Forwarding port with `#{ssh_cmd}`"
-          spawn ssh_cmd
+          spawn(ssh_cmd,  [:out, :err] => '/dev/null')
         end
 
         def store_ssh_pid(host_port, ssh_pid)
@@ -124,7 +125,7 @@ module VagrantPlugins
             ssh_pids.each do |pid|
               next unless ssh_pid?(pid)
               @logger.debug "Killing pid #{pid}"
-              system "pkill -TERM -P #{pid}"
+              system "kill #{pid}"
             end
 
             @logger.info 'Removing ssh pid files'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list