diff options
author | Thom May <thom@chef.io> | 2018-02-19 15:18:35 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2018-02-19 15:21:04 +0000 |
commit | cfa0d0e6ac5bd2fbb747084763ab80dc62c8dc17 (patch) | |
tree | c5236c306f3fdc663487fed996e1c40163903a3b /lib/chef/api_client | |
parent | ab46256c6119dd5a2394e424c2b20dcd1f3ccd47 (diff) | |
download | chef-cfa0d0e6ac5bd2fbb747084763ab80dc62c8dc17.tar.gz |
fix crash when unable to make config dirtm/fix_registration_message
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/api_client')
-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 |