diff options
-rw-r--r-- | lib/chef/api_client/registration.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb index e61ef4a160..27e1f18c17 100644 --- a/lib/chef/api_client/registration.rb +++ b/lib/chef/api_client/registration.rb @@ -70,15 +70,15 @@ class Chef end def assert_destination_writable! - if !File.exists?(File.dirname(destination)) + abs_path = File.expand_path(destination) + if !File.exists?(File.dirname(abs_path)) begin - FileUtils.mkdir_p(File.dirname(destination)) + FileUtils.mkdir_p(File.dirname(abs_path)) rescue Errno::EACCES - raise Chef::Exceptions::CannotWritePrivateKey, "I can't write your private key to #{abs_path} - check permissions?" + raise Chef::Exceptions::CannotWritePrivateKey, "I can't create the configuration directory at #{File.dirname(abs_path)} - check permissions?" end end - if (File.exists?(destination) && !File.writable?(destination)) || !File.writable?(File.dirname(destination)) - abs_path = File.expand_path(destination) + if (File.exists?(abs_path) && !File.writable?(abs_path)) || !File.writable?(File.dirname(abs_path)) raise Chef::Exceptions::CannotWritePrivateKey, "I can't write your private key to #{abs_path} - check permissions?" end end |