summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-01-26 13:32:29 -0800
committerdanielsdeleo <dan@chef.io>2016-01-27 12:38:54 -0800
commit05d98b354ab995fefd9ef6bc6d3e19bb5f960ad5 (patch)
treebf75f47b1b87ddbfddcb9100a803716eca1b65fe /lib
parent6defab990c91e07361cc27a41d506338ca915527 (diff)
downloadchef-05d98b354ab995fefd9ef6bc6d3e19bb5f960ad5.tar.gz
Force config file setting to absolute path in chef-client
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/application.rb7
-rw-r--r--lib/chef/config_fetcher.rb8
-rw-r--r--lib/chef/run_lock.rb2
3 files changed, 16 insertions, 1 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index a4d4fc209d..659c4b2f4d 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -90,6 +90,13 @@ class Chef
# Parse the config file
def load_config_file
config_fetcher = Chef::ConfigFetcher.new(config[:config_file])
+
+ # Some config settings are derived relative to the config file path; if
+ # given as a relative path, this is computed relative to cwd, but
+ # chef-client will later chdir to root, so we need to get the absolute path
+ # here.
+ config[:config_file] = config_fetcher.expanded_path
+
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?
diff --git a/lib/chef/config_fetcher.rb b/lib/chef/config_fetcher.rb
index ac6bdc2249..13f9fc3825 100644
--- a/lib/chef/config_fetcher.rb
+++ b/lib/chef/config_fetcher.rb
@@ -12,6 +12,14 @@ class Chef
@config_location = config_location
end
+ def expanded_path
+ if config_location.nil? || remote_config?
+ config_location
+ else
+ File.expand_path(config_location)
+ end
+ end
+
def fetch_json
config_data = read_config
begin
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index 42b99440bc..0d94afd15d 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -72,7 +72,7 @@ class Chef
end
end
end
- rescue Timeout::Error => e
+ rescue Timeout::Error
exit_from_timeout
end
else