diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-02-12 10:53:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-12 10:53:07 -0800 |
commit | 39480c70b777f381dc7fd7c7f36a477be876105f (patch) | |
tree | b0eea38db27cd43b8721b080b555a11647c84fa7 | |
parent | 5ee26a158a8921e8e1b355d179fe07ec65d55db3 (diff) | |
parent | ea68edc855e43f2c6c07eab046b81d273111f72e (diff) | |
download | chef-39480c70b777f381dc7fd7c7f36a477be876105f.tar.gz |
Merge pull request #6429 from jseely/master
Fix issue #2351, chef-client doesn't make /etc/chef if the directory …
-rw-r--r-- | lib/chef/api_client/registration.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb index e8ab0149e8..e61ef4a160 100644 --- a/lib/chef/api_client/registration.rb +++ b/lib/chef/api_client/registration.rb @@ -19,6 +19,7 @@ require "chef/config" require "chef/server_api" require "chef/exceptions" +require "fileutils" class Chef class ApiClient @@ -69,6 +70,13 @@ class Chef end def assert_destination_writable! + if !File.exists?(File.dirname(destination)) + begin + FileUtils.mkdir_p(File.dirname(destination)) + rescue Errno::EACCES + raise Chef::Exceptions::CannotWritePrivateKey, "I can't write your private key to #{abs_path} - check permissions?" + end + end if (File.exists?(destination) && !File.writable?(destination)) || !File.writable?(File.dirname(destination)) abs_path = File.expand_path(destination) raise Chef::Exceptions::CannotWritePrivateKey, "I can't write your private key to #{abs_path} - check permissions?" |