summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-07-22 17:24:48 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-07-22 17:24:48 -0700
commitdf3f9fa4f950827b028efb58b1403f8e4c6f3d08 (patch)
tree932e2f01d86c39f328ca9c5475e253efb4b0e06a
parentd7deaae8fcf84c19c825e43c487819cde24ed549 (diff)
downloadchef-lcg/default-paths.tar.gz
Convert to default_paths APIlcg/default-paths
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--chef-config/lib/chef-config/config.rb5
-rw-r--r--chef-utils/lib/chef-utils.rb3
-rw-r--r--chef-utils/lib/chef-utils/dsl/default_paths.rb59
-rw-r--r--chef-utils/lib/chef-utils/dsl/path_sanity.rb29
-rw-r--r--chef-utils/spec/spec_helper.rb2
-rw-r--r--chef-utils/spec/unit/dsl/path_sanity_spec.rb28
-rw-r--r--lib/chef/client.rb4
-rw-r--r--lib/chef/knife.rb8
-rw-r--r--lib/chef/knife/config_get.rb1
-rw-r--r--lib/chef/mixin/default_paths.rb32
-rw-r--r--lib/chef/mixin/path_sanity.rb9
-rw-r--r--lib/chef/mixin/which.rb8
-rw-r--r--lib/chef/mixins.rb1
-rw-r--r--spec/unit/mixin/default_paths_spec.rb (renamed from spec/unit/mixin/path_sanity_spec.rb)28
-rw-r--r--spec/unit/mixin/shell_out_spec.rb14
15 files changed, 154 insertions, 77 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index bbf686af18..6675bac142 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -313,9 +313,12 @@ 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) }
- # Turn on "path sanity" by default.
+ # DEPRECATED
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 43058f6fe3..c1b06ed3fb 100644
--- a/chef-utils/lib/chef-utils.rb
+++ b/chef-utils/lib/chef-utils.rb
@@ -19,6 +19,7 @@ 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"
@@ -34,9 +35,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
new file mode 100644
index 0000000000..f18bd93157
--- /dev/null
+++ b/chef-utils/lib/chef-utils/dsl/default_paths.rb
@@ -0,0 +1,59 @@
+#
+# 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 921c666124..1fbfbdccf3 100644
--- a/chef-utils/lib/chef-utils/dsl/path_sanity.rb
+++ b/chef-utils/lib/chef-utils/dsl/path_sanity.rb
@@ -15,42 +15,21 @@
# limitations under the License.
#
-require_relative "../internal"
-require_relative "platform_family"
+require_relative "default_paths"
module ChefUtils
module DSL
module PathSanity
- include Internal
+ include ChefUtils::DSL::DefaultPaths
- # @since 15.5
def sanitized_path(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
- __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)
+ default_paths(env)
end
private
def __sane_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
+ __default_paths
end
extend self
diff --git a/chef-utils/spec/spec_helper.rb b/chef-utils/spec/spec_helper.rb
index a44377336e..0b193e2d9a 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::PathSanity,
+ ChefUtils::DSL::DefaultPaths,
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 5f8e03aeb9..c75b99a751 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::PathSanity do
- class PathSanityTestClass
- include ChefUtils::DSL::PathSanity
+RSpec.describe ChefUtils::DSL::DefaultPaths do
+ class DefaultPathsTestClass
+ include ChefUtils::DSL::DefaultPaths
end
before do
@@ -32,26 +32,26 @@ RSpec.describe ChefUtils::DSL::PathSanity do
allow(ChefUtils).to receive(:windows?).and_return(false)
end
- let(:test_instance) { PathSanityTestClass.new }
+ let(:test_instance) { DefaultPathsTestClass.new }
it "works with no path" do
env = {}
- 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")
+ 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")
end
it "works with nil path" do
env = { "PATH" => nil }
- 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")
+ 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")
end
it "works with empty path" do
env = { "PATH" => "" }
- 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")
+ 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")
end
- it "appends the sane_paths to the end of the path, preserving any that already exist, in the same order" do
+ it "appends the default_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.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")
+ 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")
end
end
@@ -60,26 +60,26 @@ RSpec.describe ChefUtils::DSL::PathSanity do
allow(ChefUtils).to receive(:windows?).and_return(true)
end
- let(:test_instance) { PathSanityTestClass.new }
+ let(:test_instance) { DefaultPathsTestClass.new }
it "works with no path" do
env = {}
- expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
+ expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
end
it "works with nil path" do
env = { "PATH" => nil }
- expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
+ expect(test_instance.default_paths(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
end
it "works with empty path" do
env = { "PATH" => "" }
- expect(test_instance.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]}")
+ expect(test_instance.default_paths(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.sanitized_path(env)).to eql("#{Gem.bindir};#{RbConfig::CONFIG["bindir"]};%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\\")
end
end
end
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index b6f9958d64..1e069be185 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/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
+require "chef-utils/dsl/default_paths" unless defined?(ChefUtils::DSL::DefaultPaths)
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::PathSanity.sanitized_path if Chef::Config[:enforce_path_sanity]
+ ENV["PATH"] = ChefUtils::DSL::DefaultPaths.default_paths if Chef::Config[:enforce_default_paths] || 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 88e79b3c2e..e1f2d56aaf 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/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
+require "chef-utils/dsl/default_paths" unless defined?(ChefUtils::DSL::DefaultPaths)
require_relative "workstation_config_loader"
require_relative "mixin/convert_to_class_name"
-require_relative "mixin/path_sanity"
+require_relative "mixin/default_paths"
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::PathSanity
+ include ChefUtils::DSL::DefaultPaths
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"] = sanitized_path if Chef::Config[:enforce_path_sanity]
+ ENV["PATH"] = default_paths if Chef::Config[:enforce_default_paths] || 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 47a0040a83..9a57d14316 100644
--- a/lib/chef/knife/config_get.rb
+++ b/lib/chef/knife/config_get.rb
@@ -62,6 +62,7 @@ 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
new file mode 100644
index 0000000000..836911270a
--- /dev/null
+++ b/lib/chef/mixin/default_paths.rb
@@ -0,0 +1,32 @@
+#
+# 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 e7674d3540..d9ca74bebf 100644
--- a/lib/chef/mixin/path_sanity.rb
+++ b/lib/chef/mixin/path_sanity.rb
@@ -16,14 +16,15 @@
# 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)
- if Chef::Config[:enforce_path_sanity]
- env["PATH"] = ChefUtils::DSL::PathSanity.sanitized_path(env)
- end
+ enforce_default_paths(env)
end
end
end
diff --git a/lib/chef/mixin/which.rb b/lib/chef/mixin/which.rb
index 01357d76a5..a5975f958a 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/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
+require "chef-utils/dsl/default_paths" unless defined?(ChefUtils::DSL::DefaultPaths)
require "chef/mixin/chef_utils_wiring" unless defined?(Chef::Mixin::ChefUtilsWiring)
class Chef
module Mixin
module Which
include ChefUtils::DSL::Which
- include ChefUtils::DSL::PathSanity
+ include ChefUtils::DSL::DefaultPaths
include ChefUtilsWiring
private
@@ -31,8 +31,8 @@ class Chef
# we dep-inject path sanity into this API for historical reasons
#
# @api private
- def __extra_path
- __sane_paths
+ def __extra_paths
+ __default_paths
end
end
end
diff --git a/lib/chef/mixins.rb b/lib/chef/mixins.rb
index 3974328b8e..7d8ef849fe 100644
--- a/lib/chef/mixins.rb
+++ b/lib/chef/mixins.rb
@@ -6,6 +6,7 @@ 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/path_sanity_spec.rb b/spec/unit/mixin/default_paths_spec.rb
index 013225f853..0224b8f4ce 100644
--- a/spec/unit/mixin/path_sanity_spec.rb
+++ b/spec/unit/mixin/default_paths_spec.rb
@@ -18,19 +18,19 @@
require "spec_helper"
-class PathSanityTestHarness
- include Chef::Mixin::PathSanity
+class DefaultPathsTestHarness
+ include Chef::Mixin::DefaultPaths
end
-describe Chef::Mixin::PathSanity do
+describe Chef::Mixin::DefaultPaths do
before do
- @sanity = PathSanityTestHarness.new
+ @default_paths = DefaultPathsTestHarness.new
end
- describe "when enforcing path sanity" do
+ describe "when enforcing default paths" do
before do
- Chef::Config[:enforce_path_sanity] = true
+ Chef::Config[:enforce_default_paths] = 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::PathSanity do
it "adds all useful PATHs even if environment is an empty hash" do
env = {}
- @sanity.enforce_path_sanity(env)
+ @default_paths.enforce_default_paths(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" => "" }
- @sanity.enforce_path_sanity(env)
+ @default_paths.enforce_default_paths(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" }
- @sanity.enforce_path_sanity(env)
+ @default_paths.enforce_default_paths(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") }
- @sanity.enforce_path_sanity(env)
+ @default_paths.enforce_default_paths(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" => "" }
- @sanity.enforce_path_sanity(env)
+ @default_paths.enforce_default_paths(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 SANE_PATH or PATH" do
+ it "does not create entries for Ruby/Gem bindirs if they exist in 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 }
- @sanity.enforce_path_sanity(env)
+ @default_paths.enforce_default_paths(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::PathSanity 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' }
- @sanity.enforce_path_sanity(env)
+ @default_paths.enforce_default_paths(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 5880aa2b6a..2b76a10e6c 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/path_sanity"
+require "chef/mixin/default_paths"
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.sanitized_path,
+ env_path => shell_out_obj.default_paths,
}).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.sanitized_path,
+ env_path => shell_out_obj.default_paths,
}).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.sanitized_path,
+ env_path => shell_out_obj.default_paths,
}).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.sanitized_path,
+ env_path => shell_out_obj.default_paths,
}).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.sanitized_path,
+ env_path => shell_out_obj.default_paths,
}).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.sanitized_path,
+ env_path => shell_out_obj.default_paths,
}).and_return(retobj)
shell_out_obj.send(method, cmd)
end