summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2014-09-02 15:20:56 -0700
committerdanielsdeleo <dan@getchef.com>2014-09-03 12:44:46 -0700
commitae7d23c48b9d93b0e10789eb3f0e307a18351d99 (patch)
treec0a9f5208a641069640473e1c9879573ecc56180
parentb4145b8ea22c91d22fc66fd585e36e1a415ede38 (diff)
downloadchef-ae7d23c48b9d93b0e10789eb3f0e307a18351d99.tar.gz
Remove config file jail, replaced with config skip option
-rw-r--r--lib/chef/application.rb3
-rw-r--r--lib/chef/application/client.rb5
-rw-r--r--lib/chef/config.rb6
-rw-r--r--lib/chef/config_fetcher.rb27
-rw-r--r--spec/unit/config_fetcher_spec.rb4
5 files changed, 10 insertions, 35 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 7a80b700d6..5b1d53d741 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -81,10 +81,11 @@ class Chef::Application
# Parse the config file
def load_config_file
- config_fetcher = Chef::ConfigFetcher.new(config[:config_file], Chef::Config.config_file_jail)
+ config_fetcher = Chef::ConfigFetcher.new(config[:config_file])
if config[:config_file].nil?
Chef::Log.warn("No config file found or specified on command line, using command line options.")
elsif config_fetcher.config_missing?
+ pp config_missing: true
Chef::Log.warn("*****************************************")
Chef::Log.warn("Did not find config file: #{config[:config_file]}, using command line options.")
Chef::Log.warn("*****************************************")
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 1dc29db307..c4d6bb4e24 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -220,10 +220,6 @@ class Chef::Application::Client < Chef::Application
:long => "--chef-zero-port PORT",
:description => "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works."
- option :config_file_jail,
- :long => "--config-file-jail PATH",
- :description => "Directory under which config files are allowed to be loaded (no client.rb or knife.rb outside this path will be loaded)."
-
option :dont_load_config,
:long => "--dont-load-config",
:description => "Refuse to load a config file and use defaults. This is for development and not a stable API",
@@ -279,7 +275,6 @@ class Chef::Application::Client < Chef::Application
end
def load_config_file
- Chef::Config.config_file_jail = config[:config_file_jail] if config[:config_file_jail]
if !config.has_key?(:config_file) && !config[:dont_load_config]
if config[:local_mode]
config[:config_file] = Chef::WorkstationConfigLoader.new(nil).config_location
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
index e8a9839d71..4e71645dcc 100644
--- a/lib/chef/config.rb
+++ b/lib/chef/config.rb
@@ -87,10 +87,6 @@ class Chef
end
end
- # No config file (client.rb / knife.rb / etc.) will be loaded outside this path.
- # Major use case is tests, where we don't want to load the user's config files.
- configurable(:config_file_jail)
-
default :formatters, []
# Override the config dispatch to set the value of multiple server options simultaneously
@@ -527,7 +523,7 @@ class Chef
end
def self.windows_home_path
- windows_home_path = env['SYSTEMDRIVE'] + env['HOMEPATH'] if env['SYSTEMDRIVE'] && env['HOMEPATH']
+ env['SYSTEMDRIVE'] + env['HOMEPATH'] if env['SYSTEMDRIVE'] && env['HOMEPATH']
end
# returns a platform specific path to the user home dir if set, otherwise default to current directory.
diff --git a/lib/chef/config_fetcher.rb b/lib/chef/config_fetcher.rb
index 1d0693eaa2..a8aad0740d 100644
--- a/lib/chef/config_fetcher.rb
+++ b/lib/chef/config_fetcher.rb
@@ -7,11 +7,9 @@ class Chef
class ConfigFetcher
attr_reader :config_location
- attr_reader :config_file_jail
- def initialize(config_location, config_file_jail=nil)
+ def initialize(config_location)
@config_location = config_location
- @config_file_jail = config_file_jail
end
def fetch_json
@@ -48,24 +46,11 @@ class Chef
def config_missing?
return false if remote_config?
- # Check if the config file exists, and check if it is underneath the config file jail
- begin
- real_config_file = Pathname.new(config_location).realpath.to_s
- rescue Errno::ENOENT
- return true
- end
-
- # If realpath succeeded, the file exists
- return false if !config_file_jail
-
- begin
- real_jail = Pathname.new(config_file_jail).realpath.to_s
- rescue Errno::ENOENT
- Chef::Log.warn("Config file jail #{config_file_jail} does not exist: will not load any config file.")
- return true
- end
-
- !Chef::ChefFS::PathUtils.descendant_of?(real_config_file, real_jail)
+ # Check if the config file exists
+ Pathname.new(config_location).realpath.to_s
+ false
+ rescue Errno::ENOENT
+ return true
end
def http
diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb
index c29521806a..f6d5436a11 100644
--- a/spec/unit/config_fetcher_spec.rb
+++ b/spec/unit/config_fetcher_spec.rb
@@ -8,9 +8,7 @@ describe Chef::ConfigFetcher do
let(:config_location_regex) { Regexp.escape(config_location) }
let(:invalid_json_error_regex) { %r[Could not parse the provided JSON file \(#{config_location_regex}\)] }
- let(:config_jail_path) { nil }
-
- let(:fetcher) { Chef::ConfigFetcher.new(config_location, config_jail_path) }
+ let(:fetcher) { Chef::ConfigFetcher.new(config_location) }
context "when loading a local file" do
let(:config_location) { "/etc/chef/client.rb" }