diff options
author | John Keiser <jkeiser@opscode.com> | 2013-10-15 20:41:52 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-10-15 20:41:52 -0700 |
commit | e1c6bef68597f5c4f418107ef9e3638e44cc8cf7 (patch) | |
tree | c6871e3dcded48265f2b82c26ab13cd62a0ba2be /lib/chef/knife.rb | |
parent | 2da5abd0648f3ba6977d3a69d858078237bee585 (diff) | |
download | chef-e1c6bef68597f5c4f418107ef9e3638e44cc8cf7.tar.gz |
Add --config-file-jail to avoid loading user knife.rb in tests
Diffstat (limited to 'lib/chef/knife.rb')
-rw-r--r-- | lib/chef/knife.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 5ff6b92643..dbb719c30a 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -335,8 +335,7 @@ class Chef end candidate_configs.each do | candidate_config | - candidate_config = File.expand_path(candidate_config) - if File.exist?(candidate_config) + if Chef::Application.config_file_exists?(candidate_config) return candidate_config end end @@ -403,12 +402,17 @@ class Chef end def configure_chef - unless config[:config_file] + if config[:config_file] + if !Chef::Application.config_file_exists?(config[:config_file]) + ui.error("Specified config file #{config[:config_file]} does not exist#{Chef::Config.config_file_jail ? " or is not under config file jail #{Chef::Config.config_file_jail}" : ""}!") + exit 1 + end + else located_config_file = self.class.locate_config_file config[:config_file] = located_config_file if located_config_file end - # Don't try to load a knife.rb if it doesn't exist. + # Don't try to load a knife.rb if it wasn't specified. if config[:config_file] Chef::Log.debug("Using configuration from #{config[:config_file]}") read_config_file(config[:config_file]) |