diff options
author | Tim Smith <tsmith@chef.io> | 2018-09-08 21:00:31 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-10-29 21:57:48 -0700 |
commit | bcb9a37f2ee707573bcad27c137db0dba2e01cc6 (patch) | |
tree | c4188490d05eb3039c78208dfdc835d557b7f91e | |
parent | 678f326b6f41be8f4b0d71c8b5d45185f0be01bc (diff) | |
download | ohai-configs.tar.gz |
Fix provided relative paths to the config fileconfigs
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 3b648e9a..55ef9b67 100644 --- a/lib/ohai/application.rb +++ b/lib/ohai/application.rb @@ -66,14 +66,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 @@ -92,6 +84,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 ohai = Ohai::System.new(config) ohai.all_plugins(@attributes) |