summaryrefslogtreecommitdiff
path: root/lib/ohai/mixin
diff options
context:
space:
mode:
authorAkira Kitada <akitada@gmail.com>2017-04-26 03:10:28 +0900
committerAkira Kitada <akitada@gmail.com>2017-04-26 04:07:45 +0900
commit7c969e1e80c2b86eb0583aebb4098e6a693ffba0 (patch)
tree8a30fa6eed708a904365d155db3f413ad16849b9 /lib/ohai/mixin
parentd531bcc83c390ecbe323b6cf3d26ea01ed60495e (diff)
downloadohai-7c969e1e80c2b86eb0583aebb4098e6a693ffba0.tar.gz
Inject sane paths into shell_out
To ensure shell_out can find binaries. Signed-off-by: Akira Kitada <akitada@gmail.com>
Diffstat (limited to 'lib/ohai/mixin')
-rw-r--r--lib/ohai/mixin/command.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb
index 10c93baf..01a00edc 100644
--- a/lib/ohai/mixin/command.rb
+++ b/lib/ohai/mixin/command.rb
@@ -27,8 +27,13 @@ module Ohai
# DISCLAIMER: Logging only works in the context of a plugin!!
# accept a command and any of the mixlib-shellout options
def shell_out(cmd, **options)
+ options = options.dup
# unless specified by the caller timeout after 30 seconds
options[:timeout] ||= 30
+ unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
+ options[:env] = options.key?(:env) ? options[:env].dup : {}
+ options[:env]["PATH"] ||= ((ENV["PATH"] || "").split(":") + %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}).join(":")
+ end
so = Mixlib::ShellOut.new(cmd, options)
begin
so.run_command