From d845e73138f8cbb09ce4169ac1bab44db304dbd3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 15 Apr 2010 02:36:46 -0700 Subject: [PATCH] Fork-and-wait SSH on Mac OS X 10.5 [closes GH-51] --- lib/vagrant/ssh.rb | 11 +++++++++-- lib/vagrant/util/platform.rb | 12 ++++++++++++ test/vagrant/ssh_test.rb | 18 +++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 lib/vagrant/util/platform.rb diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 8df293028..c68c93e40 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -18,7 +18,7 @@ module Vagrant # of options which override the configuration values. def connect(opts={}) if Mario::Platform.windows? - error_and_exit(:ssh_unavailable_windows, + error_and_exit(:ssh_unavailable_windows, :key_path => env.config.ssh.private_key_path, :ssh_port => port(opts)) end @@ -29,7 +29,14 @@ module Vagrant end check_key_permissions(options[:private_key_path]) - Kernel.exec "ssh -p #{port(opts)} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i #{options[:private_key_path]} #{options[:username]}@#{options[:host]}".strip + + # Some hackery going on here. On Mac OS X Leopard (10.5), exec fails + # (GH-51). As a workaround, we fork and wait. On all other platforms, + # we simply exec. + pid = nil + pid = fork if Util::Platform.leopard? + Kernel.exec "ssh -p #{port(opts)} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i #{options[:private_key_path]} #{options[:username]}@#{options[:host]}".strip if pid.nil? + Process.wait(pid) if pid end # Opens an SSH connection to this environment's virtual machine and yields diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb new file mode 100644 index 000000000..80c4849c9 --- /dev/null +++ b/lib/vagrant/util/platform.rb @@ -0,0 +1,12 @@ +module Vagrant + module Util + # This class just contains some platform checking code. + class Platform + class <