From 864f1b7506cfc4897d9e1ab68028b07489ec77c3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 4 Feb 2013 21:17:12 -0800 Subject: [PATCH] Pass a proper Pathname for SSHExec to check key perms --- lib/vagrant/action/builtin/ssh_exec.rb | 8 ++++++-- test/unit/vagrant/action/builtin/ssh_exec_test.rb | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/action/builtin/ssh_exec.rb b/lib/vagrant/action/builtin/ssh_exec.rb index 372707b07..222427912 100644 --- a/lib/vagrant/action/builtin/ssh_exec.rb +++ b/lib/vagrant/action/builtin/ssh_exec.rb @@ -1,3 +1,5 @@ +require "pathname" + require "vagrant/util/ssh" module Vagrant @@ -26,8 +28,10 @@ module Vagrant # not yet ready for SSH, so we raise this exception. raise Errors::SSHNotReady if info.nil? - # Check the SSH key permissions - SSH.check_key_permissions(info[:private_key_path]) + if info[:private_key_path] + # Check the SSH key permissions + SSH.check_key_permissions(Pathname.new(info[:private_key_path])) + end # Exec! SSH.exec(info, env[:ssh_opts]) diff --git a/test/unit/vagrant/action/builtin/ssh_exec_test.rb b/test/unit/vagrant/action/builtin/ssh_exec_test.rb index a6ea69f47..f06686b8f 100644 --- a/test/unit/vagrant/action/builtin/ssh_exec_test.rb +++ b/test/unit/vagrant/action/builtin/ssh_exec_test.rb @@ -30,8 +30,10 @@ describe Vagrant::Action::Builtin::SSHExec do end it "should check key permissions then exec" do + machine_ssh_info[:private_key_path] = "/foo" + ssh_klass.should_receive(:check_key_permissions). - with(machine_ssh_info[:private_key_path]). + with(Pathname.new(machine_ssh_info[:private_key_path])). once. ordered