diff options
author | Tim Smith <tsmith@chef.io> | 2018-09-08 21:00:31 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-09-08 21:59:03 -0700 |
commit | 2b5a6aac323463e6aa9fb726d9748685b1cd6554 (patch) | |
tree | 1c5a1a40f964fd1c039c4f88dd3cd2de7232cc4c | |
parent | d9cd0cb6071dfc8e0670f0bb87589ec18c822774 (diff) | |
download | ohai-2b5a6aac323463e6aa9fb726d9748685b1cd6554.tar.gz |
Fix provided relative paths to the config filefix_config
We do an expand_path on the passed config value and we use Dir.pwd with the expand, but before we ever get here we change the directory to /, which means specifying a file in the working directory results in something like /client.rb. This isn't what the user wants. Instead change the working directory right before we run the application instead of before we work out the config situation.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/application.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/ohai/application.rb b/lib/ohai/application.rb index dc16d111..2944dc16 100644 --- a/lib/ohai/application.rb +++ b/lib/ohai/application.rb @@ -69,14 +69,6 @@ class Ohai::Application proc: lambda { |v| puts "Ohai: #{::Ohai::VERSION}" }, exit: 0 - def initialize - super - - # Always switch to a readable directory. Keeps subsequent Dir.chdir() {} - # from failing due to permissions when launched as a less privileged user. - Dir.chdir("/") - end - def run elapsed = Benchmark.measure do configure_ohai @@ -95,6 +87,10 @@ class Ohai::Application end def run_application + # Always switch to a readable directory. Keeps subsequent Dir.chdir() {} + # from failing due to permissions when launched as a less privileged user. + Dir.chdir("/") + config[:invoked_from_cli] = true config[:logger] = Ohai::Log.with_child ohai = Ohai::System.new(config) |