diff options
Diffstat (limited to 'lib/chef')
-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 |
7 files changed, 49 insertions, 14 deletions
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" |