module Chef::Mixin::PathSanity
Public Instance Methods
enforce_path_sanity(env = ENV)
click to toggle source
# File lib/chef/mixin/path_sanity.rb, line 23 def enforce_path_sanity(env = ENV) if Chef::Config[:enforce_path_sanity] env["PATH"] = sanitized_path(env) end end
sanitized_path(env = ENV)
click to toggle source
# File lib/chef/mixin/path_sanity.rb, line 29 def sanitized_path(env = ENV) env_path = env["PATH"].nil? ? "" : env["PATH"].dup path_separator = Chef::Platform.windows? ? ";" : ":" # ensure the Ruby and Gem bindirs are included # mainly for 'full-stack' Chef installs new_paths = env_path.split(path_separator) [ ruby_bindir, gem_bindir ].compact.each do |path| new_paths = [ path ] + new_paths unless new_paths.include?(path) end sane_paths.each do |path| new_paths << path unless new_paths.include?(path) end new_paths.join(path_separator).encode("utf-8", invalid: :replace, undef: :replace) end
Private Instance Methods
gem_bindir()
click to toggle source
# File lib/chef/mixin/path_sanity.rb, line 60 def gem_bindir Gem.bindir end
ruby_bindir()
click to toggle source
# File lib/chef/mixin/path_sanity.rb, line 56 def ruby_bindir RbConfig::CONFIG["bindir"] end
sane_paths()
click to toggle source
# File lib/chef/mixin/path_sanity.rb, line 46 def sane_paths @sane_paths ||= begin if Chef::Platform.windows? %w{} else %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin} end end end