diff options
author | Thom May <thom@may.lt> | 2018-02-19 18:09:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-19 18:09:18 +0000 |
commit | 121718365ee4b092e9057ffaf367e3ed0475c33f (patch) | |
tree | b1becdaa1bd6b87b9015d88c9669041a5a886711 | |
parent | 3ee91155637400efeb2886a99fc8afddc0dc247a (diff) | |
parent | cfa0d0e6ac5bd2fbb747084763ab80dc62c8dc17 (diff) | |
download | chef-121718365ee4b092e9057ffaf367e3ed0475c33f.tar.gz |
Merge pull request #6868 from chef/tm/fix_registration_message
[Registration] fix crash when unable to make config dir
-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 |