diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2020-07-24 10:06:36 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2020-07-24 10:06:36 -0700 |
commit | 8230c4d9d3cc8870632124f1bd92534a331d6893 (patch) | |
tree | 24ad42696c0c1e5610a6dfced93b10b6ada44806 | |
parent | 986d9cca6e9060eb4592599bbebd394cf06bfbea (diff) | |
download | chef-8230c4d9d3cc8870632124f1bd92534a331d6893.tar.gz |
Revert "Convert to default_paths API"
This reverts commit df3f9fa4f950827b028efb58b1403f8e4c6f3d08.
-rw-r--r-- | chef-config/lib/chef-config/config.rb | 5 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils.rb | 3 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/default_paths.rb | 59 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/path_sanity.rb | 29 | ||||
-rw-r--r-- | chef-utils/spec/spec_helper.rb | 2 | ||||
-rw-r--r-- | chef-utils/spec/unit/dsl/path_sanity_spec.rb | 28 | ||||
-rw-r--r-- | lib/chef/client.rb | 4 | ||||
-rw-r--r-- | lib/chef/knife.rb | 8 | ||||
-rw-r--r-- | lib/chef/knife/config_get.rb | 1 | ||||
-rw-r--r-- | lib/chef/mixin/default_paths.rb | 32 | ||||
-rw-r--r-- | lib/chef/mixin/path_sanity.rb | 9 | ||||
-rw-r--r-- | lib/chef/mixin/which.rb | 8 | ||||
-rw-r--r-- | lib/chef/mixins.rb | 1 | ||||
-rw-r--r-- | spec/unit/mixin/path_sanity_spec.rb (renamed from spec/unit/mixin/default_paths_spec.rb) | 28 | ||||
-rw-r--r-- | spec/unit/mixin/shell_out_spec.rb | 14 |
15 files changed, 77 insertions, 154 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 65a24d0ccc..f458d229bc 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -313,12 +313,9 @@ module ChefConfig # Defaults to <chef_repo_path>/users. default(:user_path) { derive_path_from_chef_repo_path("users") }.writes_value { |path| expand_relative_paths(path) } - # DEPRECATED + # Turn on "path sanity" by default. default :enforce_path_sanity, false - # Enforce default paths by default for all APIs, not just the default internal shell_out - default :enforce_default_paths, false - # Formatted Chef Client output is a beta feature, disabled by default: default :formatter, "null" diff --git a/chef-utils/lib/chef-utils.rb b/chef-utils/lib/chef-utils.rb index c1b06ed3fb..43058f6fe3 100644 --- a/chef-utils/lib/chef-utils.rb +++ b/chef-utils/lib/chef-utils.rb @@ -19,7 +19,6 @@ require_relative "chef-utils/dsl/architecture" require_relative "chef-utils/dsl/cloud" require_relative "chef-utils/dsl/introspection" require_relative "chef-utils/dsl/os" -require_relative "chef-utils/dsl/default_paths" require_relative "chef-utils/dsl/path_sanity" require_relative "chef-utils/dsl/platform" require_relative "chef-utils/dsl/platform_family" @@ -35,9 +34,9 @@ require_relative "chef-utils/mash" module ChefUtils include ChefUtils::DSL::Architecture include ChefUtils::DSL::Cloud - include ChefUtils::DSL::DefaultPaths include ChefUtils::DSL::Introspection include ChefUtils::DSL::OS + include ChefUtils::DSL::PathSanity include ChefUtils::DSL::Platform include ChefUtils::DSL::PlatformFamily include ChefUtils::DSL::PlatformVersion diff --git a/chef-utils/lib/chef-utils/dsl/default_paths.rb b/chef-utils/lib/chef-utils/dsl/default_paths.rb deleted file mode 100644 index f18bd93157..0000000000 --- a/chef-utils/lib/chef-utils/dsl/default_paths.rb +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright:: Copyright (c) Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require_relative "../internal" -require_relative "platform_family" - -module ChefUtils - module DSL - module DefaultPaths - include Internal - - # @since 15.5 - def default_paths(env = nil) - env_path = env ? env["PATH"] : __env_path - env_path = "" if env_path.nil? - path_separator = ChefUtils.windows? ? ";" : ":" - # ensure the Ruby and Gem bindirs are included for omnibus 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 - __default_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 - - def __default_paths - ChefUtils.windows? ? %w{} : %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin} - end - - def __ruby_bindir - RbConfig::CONFIG["bindir"] - end - - def __gem_bindir - Gem.bindir - end - - extend self - end - end -end diff --git a/chef-utils/lib/chef-utils/dsl/path_sanity.rb b/chef-utils/lib/chef-utils/dsl/path_sanity.rb index 1fbfbdccf3..921c666124 100644 --- a/chef-utils/lib/chef-utils/dsl/path_sanity.rb +++ b/chef-utils/lib/chef-utils/dsl/path_sanity.rb @@ -15,21 +15,42 @@ # limitations under the License. # -require_relative "default_paths" +require_relative "../internal" +require_relative "platform_family" module ChefUtils module DSL module PathSanity - include ChefUtils::DSL::DefaultPaths + include Internal + # @since 15.5 def sanitized_path(env = nil) - default_paths(env) + env_path = env ? env["PATH"] : __env_path + env_path = "" if env_path.nil? + path_separator = ChefUtils.windows? ? ";" : ":" + # ensure the Ruby and Gem bindirs are included for omnibus 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 def __sane_paths - __default_paths + ChefUtils.windows? ? %w{} : %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin} + end + + def __ruby_bindir + RbConfig::CONFIG["bindir"] + end + + def __gem_bindir + Gem.bindir end extend self diff --git a/chef-utils/spec/spec_helper.rb b/chef-utils/spec/spec_helper.rb index 0b193e2d9a..a44377336e 100644 --- a/chef-utils/spec/spec_helper.rb +++ b/chef-utils/spec/spec_helper.rb @@ -6,7 +6,7 @@ HELPER_MODULES = [ ChefUtils::DSL::Cloud, ChefUtils::DSL::Introspection, ChefUtils::DSL::OS, - ChefUtils::DSL::DefaultPaths, + ChefUtils::DSL::PathSanity, ChefUtils::DSL::Platform, ChefUtils::DSL::PlatformFamily, ChefUtils::DSL::Service, diff --git a/chef-utils/spec/unit/dsl/path_sanity_spec.rb b/chef-utils/spec/unit/dsl/path_sanity_spec.rb index c75b99a751..5f8e03aeb9 100644 --- a/chef-utils/spec/unit/dsl/path_sanity_spec.rb +++ b/chef-utils/spec/unit/dsl/path_sanity_spec.rb @@ -17,9 +17,9 @@ require "spec_helper" -RSpec.describe ChefUtils::DSL::DefaultPaths do - class DefaultPathsTestClass - include ChefUtils::DSL::DefaultPaths +RSpec.describe ChefUtils::DSL::PathSanity do + class PathSanityTestClass + include ChefUtils::DSL::PathSanity end before do @@ -32,26 +32,26 @@ RSpec.describe ChefUtils::DSL::DefaultPaths do allow(ChefUtils).to receive(:windows?).and_return(false) end - let(:test_instance) { DefaultPathsTestClass.new } + let(:test_instance) { PathSanityTestClass.new } it "works with no path" do env = {} - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end it "works with nil path" do env = { "PATH" => nil } - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end it "works with empty path" do env = { "PATH" => "" } - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end - it "appends the default_paths to the end of the path, preserving any that already exist, in the same order" do + it "appends the sane_paths to the end of the path, preserving any that already exist, in the same order" do env = { "PATH" => "/bin:/opt/app/bin:/sbin" } - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/bin:/opt/app/bin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir}:#{RbConfig::CONFIG["bindir"]}:/bin:/opt/app/bin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin") end end @@ -60,26 +60,26 @@ RSpec.describe ChefUtils::DSL::DefaultPaths do allow(ChefUtils).to receive(:windows?).and_return(true) end - let(:test_instance) { DefaultPathsTestClass.new } + let(:test_instance) { PathSanityTestClass.new } it "works with no path" do env = {} - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}") end it "works with nil path" do env = { "PATH" => nil } - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}") end it "works with empty path" do env = { "PATH" => "" } - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}") end it "prepends to an existing path" do env = { "PATH" => '%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\\' } - expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]};%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\") + expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]};%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\") end end end diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 1e069be185..b6f9958d64 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -20,7 +20,7 @@ require_relative "config" require_relative "mixin/params_validate" -require "chef-utils/dsl/default_paths" unless defined?(ChefUtils::DSL::DefaultPaths) +require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity) require_relative "log" require_relative "deprecated" require_relative "server_api" @@ -250,7 +250,7 @@ class Chef logger.info "#{Chef::Dist::CLIENT.capitalize} pid: #{Process.pid}" logger.info "Targeting node: #{Chef::Config.target_mode.host}" if Chef::Config.target_mode? logger.debug("#{Chef::Dist::CLIENT.capitalize} request_id: #{request_id}") - ENV["PATH"] = ChefUtils::DSL::DefaultPaths.default_paths if Chef::Config[:enforce_default_paths] || Chef::Config[:enforce_path_sanity] + ENV["PATH"] = ChefUtils::DSL::PathSanity.sanitized_path if Chef::Config[:enforce_path_sanity] if Chef::Config.target_mode? get_ohai_data_remotely diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index e1f2d56aaf..88e79b3c2e 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -20,10 +20,10 @@ require "forwardable" unless defined?(Forwardable) require_relative "version" require "mixlib/cli" unless defined?(Mixlib::CLI) -require "chef-utils/dsl/default_paths" unless defined?(ChefUtils::DSL::DefaultPaths) +require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity) require_relative "workstation_config_loader" require_relative "mixin/convert_to_class_name" -require_relative "mixin/default_paths" +require_relative "mixin/path_sanity" require_relative "knife/core/subcommand_loader" require_relative "knife/core/ui" require_relative "local_mode" @@ -40,7 +40,7 @@ class Chef Chef::HTTP::HTTPRequest.user_agent = "#{Chef::Dist::PRODUCT} Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}" include Mixlib::CLI - include ChefUtils::DSL::DefaultPaths + include ChefUtils::DSL::PathSanity extend Chef::Mixin::ConvertToClassName extend Forwardable @@ -484,7 +484,7 @@ class Chef unless respond_to?(:run) ui.error "You need to add a #run method to your knife command before you can use it" end - ENV["PATH"] = default_paths if Chef::Config[:enforce_default_paths] || Chef::Config[:enforce_path_sanity] + ENV["PATH"] = sanitized_path if Chef::Config[:enforce_path_sanity] maybe_setup_fips Chef::LocalMode.with_server_connectivity do run diff --git a/lib/chef/knife/config_get.rb b/lib/chef/knife/config_get.rb index 9a57d14316..47a0040a83 100644 --- a/lib/chef/knife/config_get.rb +++ b/lib/chef/knife/config_get.rb @@ -62,7 +62,6 @@ class Chef config_data.delete(:color) # Only keep these if true, false is much less important because it's the default. config_data.delete(:local_mode) unless config_data[:local_mode] - config_data.delete(:enforce_default_paths) unless config_data[:enforce_default_paths] config_data.delete(:enforce_path_sanity) unless config_data[:enforce_path_sanity] end diff --git a/lib/chef/mixin/default_paths.rb b/lib/chef/mixin/default_paths.rb deleted file mode 100644 index 836911270a..0000000000 --- a/lib/chef/mixin/default_paths.rb +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright:: Copyright (c) Chef Software Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -class Chef - module Mixin - module DefaultPaths - def enforce_path_sanity(env = ENV) - enforce_default_paths(env) - end - - def enforce_default_paths(env = ENV) - if Chef::Config[:enforce_default_paths] - env["PATH"] = ChefUtils::DSL::DefaultPaths.default_paths(env) - end - end - end - end -end diff --git a/lib/chef/mixin/path_sanity.rb b/lib/chef/mixin/path_sanity.rb index d9ca74bebf..e7674d3540 100644 --- a/lib/chef/mixin/path_sanity.rb +++ b/lib/chef/mixin/path_sanity.rb @@ -16,15 +16,14 @@ # limitations under the License. # -require_relative "default_paths" - class Chef module Mixin + # @ deprecated module PathSanity - include Chef::Mixin::DefaultPaths - def enforce_path_sanity(env = ENV) - enforce_default_paths(env) + if Chef::Config[:enforce_path_sanity] + env["PATH"] = ChefUtils::DSL::PathSanity.sanitized_path(env) + end end end end diff --git a/lib/chef/mixin/which.rb b/lib/chef/mixin/which.rb index a5975f958a..01357d76a5 100644 --- a/lib/chef/mixin/which.rb +++ b/lib/chef/mixin/which.rb @@ -16,14 +16,14 @@ # limitations under the License. require "chef-utils/dsl/which" unless defined?(ChefUtils::DSL::Which) -require "chef-utils/dsl/default_paths" unless defined?(ChefUtils::DSL::DefaultPaths) +require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity) require "chef/mixin/chef_utils_wiring" unless defined?(Chef::Mixin::ChefUtilsWiring) class Chef module Mixin module Which include ChefUtils::DSL::Which - include ChefUtils::DSL::DefaultPaths + include ChefUtils::DSL::PathSanity include ChefUtilsWiring private @@ -31,8 +31,8 @@ class Chef # we dep-inject path sanity into this API for historical reasons # # @api private - def __extra_paths - __default_paths + def __extra_path + __sane_paths end end end diff --git a/lib/chef/mixins.rb b/lib/chef/mixins.rb index 7d8ef849fe..3974328b8e 100644 --- a/lib/chef/mixins.rb +++ b/lib/chef/mixins.rb @@ -6,7 +6,6 @@ require_relative "mixin/deep_merge" require_relative "mixin/enforce_ownership_and_permissions" require_relative "mixin/from_file" require_relative "mixin/params_validate" -require_relative "mixin/default_paths" require_relative "mixin/path_sanity" require_relative "mixin/template" require_relative "mixin/securable" diff --git a/spec/unit/mixin/default_paths_spec.rb b/spec/unit/mixin/path_sanity_spec.rb index 0224b8f4ce..013225f853 100644 --- a/spec/unit/mixin/default_paths_spec.rb +++ b/spec/unit/mixin/path_sanity_spec.rb @@ -18,19 +18,19 @@ require "spec_helper" -class DefaultPathsTestHarness - include Chef::Mixin::DefaultPaths +class PathSanityTestHarness + include Chef::Mixin::PathSanity end -describe Chef::Mixin::DefaultPaths do +describe Chef::Mixin::PathSanity do before do - @default_paths = DefaultPathsTestHarness.new + @sanity = PathSanityTestHarness.new end - describe "when enforcing default paths" do + describe "when enforcing path sanity" do before do - Chef::Config[:enforce_default_paths] = true + Chef::Config[:enforce_path_sanity] = true @ruby_bindir = "/some/ruby/bin" @gem_bindir = "/some/gem/bin" allow(Gem).to receive(:bindir).and_return(@gem_bindir) @@ -40,41 +40,41 @@ describe Chef::Mixin::DefaultPaths do it "adds all useful PATHs even if environment is an empty hash" do env = {} - @default_paths.enforce_default_paths(env) + @sanity.enforce_path_sanity(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end it "adds all useful PATHs that are not yet in PATH to PATH" do env = { "PATH" => "" } - @default_paths.enforce_default_paths(env) + @sanity.enforce_path_sanity(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end it "does not re-add paths that already exist in PATH" do env = { "PATH" => "/usr/bin:/sbin:/bin" } - @default_paths.enforce_default_paths(env) + @sanity.enforce_path_sanity(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin") end it "creates path with utf-8 encoding" do env = { "PATH" => "/usr/bin:/sbin:/bin:/b#{0x81.chr}t".force_encoding("ISO-8859-1") } - @default_paths.enforce_default_paths(env) + @sanity.enforce_path_sanity(env) expect(env["PATH"].encoding.to_s).to eq("UTF-8") end it "adds the current executing Ruby's bindir and Gem bindir to the PATH" do env = { "PATH" => "" } - @default_paths.enforce_default_paths(env) + @sanity.enforce_path_sanity(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end - it "does not create entries for Ruby/Gem bindirs if they exist in PATH" do + it "does not create entries for Ruby/Gem bindirs if they exist in SANE_PATH or PATH" do ruby_bindir = "/usr/bin" gem_bindir = "/yo/gabba/gabba" allow(Gem).to receive(:bindir).and_return(gem_bindir) allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir) env = { "PATH" => gem_bindir } - @default_paths.enforce_default_paths(env) + @sanity.enforce_path_sanity(env) expect(env["PATH"]).to eq("/usr/bin:/yo/gabba/gabba:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin") end @@ -85,7 +85,7 @@ describe Chef::Mixin::DefaultPaths do allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir) allow(ChefUtils).to receive(:windows?).and_return(true) env = { "PATH" => 'C:\Windows\system32;C:\mr\softie' } - @default_paths.enforce_default_paths(env) + @sanity.enforce_path_sanity(env) expect(env["PATH"]).to eq("#{gem_bindir};#{ruby_bindir};C:\\Windows\\system32;C:\\mr\\softie") end end diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 2b76a10e6c..5880aa2b6a 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -21,7 +21,7 @@ # require "spec_helper" -require "chef/mixin/default_paths" +require "chef/mixin/path_sanity" describe Chef::Mixin::ShellOut do let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } } @@ -74,7 +74,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.default_paths, + env_path => shell_out_obj.sanitized_path, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) end @@ -87,7 +87,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.default_paths, + env_path => shell_out_obj.sanitized_path, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) expect(options[:environment].key?("LC_ALL")).to be false @@ -115,7 +115,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.default_paths, + env_path => shell_out_obj.sanitized_path, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) end @@ -128,7 +128,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.default_paths, + env_path => shell_out_obj.sanitized_path, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) expect(options[:env].key?("LC_ALL")).to be false @@ -144,7 +144,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.default_paths, + env_path => shell_out_obj.sanitized_path, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) end @@ -158,7 +158,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.default_paths, + env_path => shell_out_obj.sanitized_path, }).and_return(retobj) shell_out_obj.send(method, cmd) end |