chef 15.4.45 → 15.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -3
- data/Rakefile +5 -3
- data/chef.gemspec +2 -1
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -6
- data/lib/chef/chef_fs.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +2 -2
- data/lib/chef/client.rb +4 -5
- data/lib/chef/config.rb +3 -2
- data/lib/chef/cookbook/chefignore.rb +16 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +5 -3
- data/lib/chef/cookbook_loader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/run_end_message.rb +1 -0
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +9 -18
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/file_content_management/deploy.rb +3 -3
- data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/knife.rb +4 -3
- data/lib/chef/knife/config_get.rb +2 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +6 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mash.rb +21 -232
- data/lib/chef/mixin/file_class.rb +2 -2
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +3 -39
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +4 -5
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/user_context.rb +3 -3
- data/lib/chef/mixin/which.rb +10 -38
- data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
- data/lib/chef/mixin/windows_env_helper.rb +5 -5
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node_map.rb +17 -4
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +14 -85
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file/fetcher.rb +2 -2
- data/lib/chef/provider/remote_file/local_file.rb +1 -1
- data/lib/chef/provider/script.rb +3 -3
- data/lib/chef/provider/service.rb +5 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +4 -4
- data/lib/chef/provider/service/invokercd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +19 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/systemd_unit.rb +26 -2
- data/lib/chef/provider/windows_path.rb +3 -3
- data/lib/chef/provider/windows_task.rb +4 -4
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/batch.rb +2 -0
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +3 -3
- data/lib/chef/resource/chef_sleep.rb +70 -0
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -0
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -0
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +3 -1
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/link.rb +4 -2
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +2 -0
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +2 -0
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +1 -0
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +2 -0
- data/lib/chef/resource/scm.rb +2 -0
- data/lib/chef/resource/script.rb +2 -0
- data/lib/chef/resource/service.rb +9 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/subversion.rb +2 -0
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/systemd_unit.rb +1 -0
- data/lib/chef/resource/template.rb +2 -0
- data/lib/chef/resource/user.rb +2 -0
- data/lib/chef/resource/user/aix_user.rb +2 -0
- data/lib/chef/resource/user/linux_user.rb +2 -0
- data/lib/chef/resource/user/pw_user.rb +2 -0
- data/lib/chef/resource/user/solaris_user.rb +2 -0
- data/lib/chef/resource/user/windows_user.rb +2 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +11 -6
- data/lib/chef/resource/windows_script.rb +3 -1
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +1 -1
- data/lib/chef/run_lock.rb +5 -5
- data/lib/chef/search/query.rb +0 -3
- data/lib/chef/train_transport.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +2 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/eventlog.rb +2 -2
- data/spec/data/cookbooks/starter/chefignore +8 -0
- data/spec/data/cookbooks/starter/files/sample.txt +1 -0
- data/spec/data/cookbooks/starter/metadata.rb +2 -0
- data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
- data/spec/functional/mixin/user_context_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/cookbook_file_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/functional/win32/sid_spec.rb +2 -2
- data/spec/functional/win32/version_info_spec.rb +1 -1
- data/spec/functional/win32/versions_spec.rb +1 -1
- data/spec/integration/knife/config_get_profile_spec.rb +2 -2
- data/spec/integration/knife/config_get_spec.rb +9 -2
- data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
- data/spec/integration/knife/config_use_profile_spec.rb +2 -2
- data/spec/integration/knife/list_spec.rb +2 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/platform_helpers.rb +2 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +4 -4
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
- data/spec/unit/chef_fs/path_util_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/cookbook/chefignore_spec.rb +31 -11
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
- data/spec/unit/cookbook_loader_spec.rb +2 -2
- data/spec/unit/cookbook_uploader_spec.rb +6 -1
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +7 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
- data/spec/unit/knife/cookbook_show_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +27 -17
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_install_spec.rb +1 -1
- data/spec/unit/mixin/path_sanity_spec.rb +3 -3
- data/spec/unit/mixin/shell_out_spec.rb +2 -3
- data/spec/unit/mixin/template_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +3 -3
- data/spec/unit/node_map_spec.rb +12 -12
- data/spec/unit/platform/query_helpers_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +2 -2
- data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
- data/spec/unit/provider/subversion_spec.rb +3 -3
- data/spec/unit/provider/systemd_unit_spec.rb +53 -4
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_resolver_spec.rb +41 -61
- data/spec/unit/resource/chef_sleep_spec.rb +30 -0
- data/spec/unit/resource/cookbook_file_spec.rb +3 -3
- data/spec/unit/resource/remote_file_spec.rb +3 -3
- data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
- data/spec/unit/role_spec.rb +2 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/win32/error_spec.rb +1 -1
- data/spec/unit/win32/link_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +1 -1
- data/spec/unit/windows_service_spec.rb +1 -1
- data/tasks/docs.rb +10 -2
- data/tasks/rspec.rb +8 -6
- metadata +32 -8
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b826d0315123f87d4feb069a4289749d0bf5db9a76853499c80dcbddfdad2ed0
|
4
|
+
data.tar.gz: 27867153b65d9cd6123d57898e1a9348490d163c7dea664448d1e275786dc2d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29e068c32113545d82e3d83cfaff2966dd96ad08e8882861458354c9372707fb97a9846384e5e55078ee8b50fc06aa480a02f17e1a2201593460d991d9bbb3c0
|
7
|
+
data.tar.gz: bc7f429bf5bb6b92667db0b2fde9117bc4806744aea7a1e43259e3693c86d2099f9fcedc989036b57e2dc9a6a1437db020bee675c0d0f6d8ca6b352b6a2f46e0
|
data/Gemfile
CHANGED
@@ -10,6 +10,7 @@ gem "chef", path: "."
|
|
10
10
|
# necessary until we release ohai 15
|
11
11
|
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "master"
|
12
12
|
|
13
|
+
gem "chef-utils", path: File.expand_path("../chef-utils", __FILE__) if File.exist?(File.expand_path("../chef-utils", __FILE__))
|
13
14
|
gem "chef-config", path: File.expand_path("../chef-config", __FILE__) if File.exist?(File.expand_path("../chef-config", __FILE__))
|
14
15
|
|
15
16
|
if File.exist?(File.expand_path("../chef-bin", __FILE__))
|
@@ -25,8 +26,8 @@ gem "cheffish", "~> 14"
|
|
25
26
|
group(:omnibus_package) do
|
26
27
|
gem "appbundler"
|
27
28
|
gem "rb-readline"
|
28
|
-
gem "inspec-core", "~> 4.
|
29
|
-
gem "inspec-core-bin", "~> 4.
|
29
|
+
gem "inspec-core", "~> 4.18"
|
30
|
+
gem "inspec-core-bin", "~> 4.18" # need to provide the binaries for inspec
|
30
31
|
gem "chef-vault"
|
31
32
|
gem "ed25519" # ed25519 ssh key support done here as it's a native gem we can't put in train
|
32
33
|
gem "bcrypt_pbkdf" # ed25519 ssh key support done here as it's a native gem we can't put in train
|
@@ -65,6 +66,7 @@ group(:development, :test) do
|
|
65
66
|
gem "rspec_junit_formatter", "~> 0.2.0"
|
66
67
|
gem "simplecov"
|
67
68
|
gem "webmock"
|
69
|
+
gem "fauxhai-ng" # for chef-utils gem
|
68
70
|
end
|
69
71
|
|
70
72
|
group(:chefstyle) do
|
@@ -76,7 +78,7 @@ instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
|
76
78
|
|
77
79
|
# If you want to load debugging tools into the bundle exec sandbox,
|
78
80
|
# add these additional dependencies into Gemfile.local
|
79
|
-
eval_gemfile(
|
81
|
+
eval_gemfile("./Gemfile.local") if File.exist?("./Gemfile.local")
|
80
82
|
|
81
83
|
# These lines added for Windows development only.
|
82
84
|
# For FFI to call into PowerShell we need the binaries and assemblies located
|
data/Rakefile
CHANGED
@@ -26,9 +26,11 @@ ENV["CHEF_LICENSE"] = "accept-no-persist"
|
|
26
26
|
|
27
27
|
# hack the chef-config install to run before the traditional install task
|
28
28
|
task :super_install do
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
%w{chef-utils chef-config}.each do |gem|
|
30
|
+
path = ::File.join(::File.dirname(__FILE__), gem)
|
31
|
+
Dir.chdir(path)
|
32
|
+
sh("rake install")
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
task install: :super_install
|
data/chef.gemspec
CHANGED
@@ -16,13 +16,14 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.required_ruby_version = ">= 2.5.0"
|
17
17
|
|
18
18
|
s.add_dependency "chef-config", "= #{Chef::VERSION}"
|
19
|
+
s.add_dependency "chef-utils", "= #{Chef::VERSION}"
|
19
20
|
s.add_dependency "train-core", "~> 3.1"
|
20
21
|
s.add_dependency "train-winrm", ">= 0.2.5"
|
21
22
|
|
22
23
|
s.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.5"
|
23
24
|
s.add_dependency "mixlib-cli", ">= 2.1.1", "< 3.0"
|
24
25
|
s.add_dependency "mixlib-log", ">= 2.0.3", "< 4.0"
|
25
|
-
s.add_dependency "mixlib-authentication", "
|
26
|
+
s.add_dependency "mixlib-authentication", ">= 2.1", "< 4"
|
26
27
|
s.add_dependency "mixlib-shellout", ">= 3.0.3", "< 4.0"
|
27
28
|
s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
|
28
29
|
s.add_dependency "ohai", "~> 15.0"
|
data/lib/chef/application.rb
CHANGED
@@ -78,7 +78,7 @@ class Chef
|
|
78
78
|
Chef::Application.fatal!("SIGTERM received, stopping", Chef::Exceptions::SigTerm.new)
|
79
79
|
end
|
80
80
|
|
81
|
-
unless
|
81
|
+
unless ChefUtils.windows?
|
82
82
|
trap("QUIT") do
|
83
83
|
logger.info("SIGQUIT received, call stack:\n " + caller.join("\n "))
|
84
84
|
end
|
@@ -305,7 +305,7 @@ class Chef
|
|
305
305
|
# win32-process gem exposes some form of :fork for Process
|
306
306
|
# class. So we are separately ensuring that the platform we're
|
307
307
|
# running on is not windows before forking.
|
308
|
-
chef_config[:client_fork] && Process.respond_to?(:fork) && !
|
308
|
+
chef_config[:client_fork] && Process.respond_to?(:fork) && !ChefUtils.windows?
|
309
309
|
end
|
310
310
|
|
311
311
|
# Run chef-client once and then exit. If TERM signal is received, ignores the
|
@@ -33,7 +33,7 @@ class Chef::Application::Client < Chef::Application::Base
|
|
33
33
|
long: "--config CONFIG",
|
34
34
|
description: "The configuration file to use."
|
35
35
|
|
36
|
-
unless
|
36
|
+
unless ChefUtils.windows?
|
37
37
|
option :daemonize,
|
38
38
|
short: "-d [WAIT]",
|
39
39
|
long: "--daemonize [WAIT]",
|
@@ -36,7 +36,7 @@ class Chef::Application::Solo < Chef::Application::Base
|
|
36
36
|
default: Chef::Config.platform_specific_path("#{Chef::Dist::CONF_DIR}/solo.rb"),
|
37
37
|
description: "The configuration file to use."
|
38
38
|
|
39
|
-
unless
|
39
|
+
unless ChefUtils.windows?
|
40
40
|
option :daemonize,
|
41
41
|
short: "-d",
|
42
42
|
long: "--daemonize",
|
data/lib/chef/chef_class.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
3
|
-
# Copyright:: Copyright 2015-
|
3
|
+
# Copyright:: Copyright 2015-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -239,10 +239,5 @@ class Chef
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
-
# @api private Only for test dependency injection; not evenly implemented as yet.
|
243
|
-
def self.path_to(path)
|
244
|
-
path
|
245
|
-
end
|
246
|
-
|
247
242
|
reset!
|
248
243
|
end
|
data/lib/chef/chef_fs.rb
CHANGED
@@ -245,7 +245,7 @@ class Chef
|
|
245
245
|
end
|
246
246
|
|
247
247
|
def self.pattern_special_characters
|
248
|
-
if
|
248
|
+
if ChefUtils.windows?
|
249
249
|
@pattern_special_characters ||= /(\*\*|\*|\?|[\*\?\.\|\(\)\[\]\{\}\+\\\\\^\$])/
|
250
250
|
else
|
251
251
|
# Unix also supports character regexes and backslashes
|
@@ -65,7 +65,7 @@ class Chef
|
|
65
65
|
file_class.symlink other.file_path, proxy_cookbook_path
|
66
66
|
|
67
67
|
# Instantiate a proxy loader using the temporary symlink
|
68
|
-
proxy_loader = Chef::Cookbook::CookbookVersionLoader.new(proxy_cookbook_path, other.
|
68
|
+
proxy_loader = Chef::Cookbook::CookbookVersionLoader.new(proxy_cookbook_path, other.chefignore)
|
69
69
|
proxy_loader.load_cookbooks
|
70
70
|
|
71
71
|
cookbook_to_upload = proxy_loader.cookbook_version
|
@@ -86,7 +86,7 @@ class Chef
|
|
86
86
|
# the symlink without removing the original contents if we
|
87
87
|
# are running on windows
|
88
88
|
#
|
89
|
-
if
|
89
|
+
if ChefUtils.windows?
|
90
90
|
Dir.rmdir proxy_cookbook_path
|
91
91
|
end
|
92
92
|
end
|
@@ -71,7 +71,7 @@ class Chef
|
|
71
71
|
file_class.symlink other.file_path, proxy_cookbook_path
|
72
72
|
|
73
73
|
# Instantiate a proxy loader using the temporary symlink
|
74
|
-
proxy_loader = Chef::Cookbook::CookbookVersionLoader.new(proxy_cookbook_path, other.
|
74
|
+
proxy_loader = Chef::Cookbook::CookbookVersionLoader.new(proxy_cookbook_path, other.chefignore)
|
75
75
|
proxy_loader.load_cookbooks
|
76
76
|
|
77
77
|
cookbook_to_upload = proxy_loader.cookbook_version
|
@@ -91,7 +91,7 @@ class Chef
|
|
91
91
|
# the symlink without removing the original contents if we
|
92
92
|
# are running on windows
|
93
93
|
#
|
94
|
-
if
|
94
|
+
if ChefUtils.windows?
|
95
95
|
Dir.rmdir proxy_cookbook_path
|
96
96
|
end
|
97
97
|
end
|
data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb
CHANGED
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
class ChefRepositoryFileSystemCookbookArtifactDir < ChefRepositoryFileSystemCookbookDir
|
26
26
|
# Override from parent
|
27
27
|
def cookbook_version
|
28
|
-
loader = Chef::Cookbook::CookbookVersionLoader.new(file_path,
|
28
|
+
loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, chefignore)
|
29
29
|
cookbook_name, _dash, identifier = name.rpartition("-")
|
30
30
|
# KLUDGE: We shouldn't have to use instance_variable_set
|
31
31
|
loader.instance_variable_set(:@cookbook_name, cookbook_name)
|
@@ -21,6 +21,7 @@ require_relative "../chef_server/cookbook_dir"
|
|
21
21
|
require_relative "../chef_server/versioned_cookbook_dir"
|
22
22
|
require_relative "../exceptions"
|
23
23
|
require_relative "../../../cookbook/cookbook_version_loader"
|
24
|
+
require_relative "../../../cookbook/chefignore"
|
24
25
|
|
25
26
|
class Chef
|
26
27
|
module ChefFS
|
@@ -31,6 +32,11 @@ class Chef
|
|
31
32
|
class ChefRepositoryFileSystemCookbookDir < ChefRepositoryFileSystemCookbookEntry
|
32
33
|
|
33
34
|
# API Required by Respository::Directory
|
35
|
+
def chefignore
|
36
|
+
@chefignore ||= Chef::Cookbook::Chefignore.new(file_path)
|
37
|
+
rescue Errno::EISDIR, Errno::EACCES
|
38
|
+
# Work around a bug in Chefignore when chefignore is a directory
|
39
|
+
end
|
34
40
|
|
35
41
|
def fs_entry_valid?
|
36
42
|
return false unless File.directory?(file_path) && name_valid?
|
@@ -136,7 +142,7 @@ class Chef
|
|
136
142
|
end
|
137
143
|
|
138
144
|
def cookbook_version
|
139
|
-
loader = Chef::Cookbook::CookbookVersionLoader.new(file_path,
|
145
|
+
loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, chefignore)
|
140
146
|
loader.load_cookbooks
|
141
147
|
loader.cookbook_version
|
142
148
|
end
|
@@ -68,13 +68,14 @@ class Chef
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# Check chefignore
|
71
|
-
ignorer =
|
71
|
+
ignorer = self
|
72
|
+
|
72
73
|
loop do
|
73
|
-
if ignorer.is_a?(
|
74
|
+
if ignorer.is_a?(ChefRepositoryFileSystemCookbookDir)
|
74
75
|
# Grab the path from entry to child
|
75
76
|
path_to_child = name
|
76
77
|
child = self
|
77
|
-
while child
|
78
|
+
while child != ignorer
|
78
79
|
path_to_child = PathUtils.join(child.name, path_to_child)
|
79
80
|
child = child.parent
|
80
81
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
-
# Copyright:: Copyright 2012-
|
3
|
+
# Copyright:: Copyright 2012-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -44,7 +44,7 @@ require_relative "../../data_handler/role_data_handler"
|
|
44
44
|
require_relative "../../data_handler/user_data_handler"
|
45
45
|
require_relative "../../data_handler/group_data_handler"
|
46
46
|
require_relative "../../data_handler/container_data_handler"
|
47
|
-
require_relative "../../../win32/security" if
|
47
|
+
require_relative "../../../win32/security" if ChefUtils.windows?
|
48
48
|
|
49
49
|
class Chef
|
50
50
|
module ChefFS
|
@@ -112,7 +112,7 @@ class Chef
|
|
112
112
|
begin
|
113
113
|
::FileUtils.mkdir_p(path)
|
114
114
|
::FileUtils.chmod(0700, path)
|
115
|
-
if
|
115
|
+
if ChefUtils.windows?
|
116
116
|
all_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_ALL
|
117
117
|
administrators = Chef::ReservedNames::Win32::Security::SID.Administrators
|
118
118
|
owner = Chef::ReservedNames::Win32::Security::SID.default_security_object_owner
|
data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
CHANGED
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
class ChefRepositoryFileSystemVersionedCookbookDir < ChefRepositoryFileSystemCookbookDir
|
26
26
|
# Override from parent
|
27
27
|
def cookbook_version
|
28
|
-
loader = Chef::Cookbook::CookbookVersionLoader.new(file_path,
|
28
|
+
loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, chefignore)
|
29
29
|
# We need the canonical cookbook name if we are using versioned cookbooks, but we don't
|
30
30
|
# want to spend a lot of time adding code to the main Chef libraries
|
31
31
|
canonical_name = canonical_cookbook_name(File.basename(file_path))
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
3
|
# Author:: Ho-Sheng Hsiao (<hosh@chef.io>)
|
4
|
-
# Copyright:: Copyright 2012-
|
4
|
+
# Copyright:: Copyright 2012-2019, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -20,7 +20,7 @@
|
|
20
20
|
require_relative "node"
|
21
21
|
require_relative "directory"
|
22
22
|
require_relative "../exceptions"
|
23
|
-
require_relative "../../../win32/security" if
|
23
|
+
require_relative "../../../win32/security" if ChefUtils.windows?
|
24
24
|
|
25
25
|
class Chef
|
26
26
|
module ChefFS
|
@@ -35,7 +35,7 @@ class Chef
|
|
35
35
|
def create_child(child_name, file_contents = nil)
|
36
36
|
child = super
|
37
37
|
File.chmod(0600, child.file_path)
|
38
|
-
if
|
38
|
+
if ChefUtils.windows?
|
39
39
|
read_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_READ
|
40
40
|
write_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE
|
41
41
|
administrators = Chef::ReservedNames::Win32::Security::SID.Administrators
|
data/lib/chef/chef_fs/knife.rb
CHANGED
@@ -58,7 +58,7 @@ class Chef
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.regexp_path_separator
|
61
|
-
|
61
|
+
ChefUtils.windows? ? '[\/\\\\]' : "/"
|
62
62
|
end
|
63
63
|
|
64
64
|
# Given a server path, determines if it is absolute.
|
@@ -103,7 +103,7 @@ class Chef
|
|
103
103
|
|
104
104
|
# Compares two path fragments according to the case-sentitivity of the host platform.
|
105
105
|
def self.os_path_eq?(left, right)
|
106
|
-
|
106
|
+
ChefUtils.windows? ? left.casecmp(right) == 0 : left == right
|
107
107
|
end
|
108
108
|
|
109
109
|
# Given two general OS-dependent file paths, determines the relative path of the
|
data/lib/chef/client.rb
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
require_relative "config"
|
22
22
|
require_relative "mixin/params_validate"
|
23
|
-
|
23
|
+
require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
|
24
24
|
require_relative "log"
|
25
25
|
require_relative "deprecated"
|
26
26
|
require_relative "server_api"
|
@@ -52,6 +52,7 @@ require_relative "policy_builder"
|
|
52
52
|
require_relative "request_id"
|
53
53
|
require_relative "platform/rebooter"
|
54
54
|
require_relative "mixin/deprecation"
|
55
|
+
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
55
56
|
require "ohai" unless defined?(Ohai::System)
|
56
57
|
require "rbconfig"
|
57
58
|
require_relative "dist"
|
@@ -62,8 +63,6 @@ class Chef
|
|
62
63
|
# The main object in a Chef run. Preps a Chef::Node and Chef::RunContext,
|
63
64
|
# syncs cookbooks if necessary, and triggers convergence.
|
64
65
|
class Client
|
65
|
-
include Chef::Mixin::PathSanity
|
66
|
-
|
67
66
|
extend Chef::Mixin::Deprecation
|
68
67
|
|
69
68
|
extend Forwardable
|
@@ -251,7 +250,7 @@ class Chef
|
|
251
250
|
logger.info "#{Chef::Dist::CLIENT.capitalize} pid: #{Process.pid}"
|
252
251
|
logger.info "Targeting node: #{Chef::Config.target_mode.host}" if Chef::Config.target_mode?
|
253
252
|
logger.debug("#{Chef::Dist::CLIENT.capitalize} request_id: #{request_id}")
|
254
|
-
enforce_path_sanity
|
253
|
+
ENV["PATH"] = ChefUtils::PathSanity.sanitized_path if Chef::Config[:enforce_path_sanity]
|
255
254
|
|
256
255
|
if Chef::Config.target_mode?
|
257
256
|
get_ohai_data_remotely
|
@@ -749,7 +748,7 @@ class Chef
|
|
749
748
|
# @api private
|
750
749
|
#
|
751
750
|
def do_windows_admin_check
|
752
|
-
if
|
751
|
+
if ChefUtils.windows?
|
753
752
|
logger.trace("Checking for administrator privileges....")
|
754
753
|
|
755
754
|
if !has_admin_privileges?
|
data/lib/chef/config.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Author:: AJ Christensen (<aj@chef.io>)
|
5
5
|
# Author:: Mark Mzyk (<mmzyk@chef.io>)
|
6
6
|
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
|
7
|
-
# Copyright:: Copyright 2008-
|
7
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
8
8
|
# License:: Apache License, Version 2.0
|
9
9
|
#
|
10
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -28,6 +28,7 @@ require "chef-config/logger"
|
|
28
28
|
ChefConfig.logger = Chef::Log
|
29
29
|
|
30
30
|
require "chef-config/config"
|
31
|
+
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
31
32
|
require_relative "platform/query_helpers"
|
32
33
|
|
33
34
|
# Ohai::Config defines its own log_level and log_location. When loaded, it will
|
@@ -55,7 +56,7 @@ class Chef
|
|
55
56
|
|
56
57
|
default :event_loggers do
|
57
58
|
evt_loggers = []
|
58
|
-
if
|
59
|
+
if ChefUtils.windows? && !Chef::Platform.windows_nano_server?
|
59
60
|
evt_loggers << :win_evt
|
60
61
|
end
|
61
62
|
evt_loggers
|
@@ -24,11 +24,9 @@ class Chef
|
|
24
24
|
attr_reader :ignores
|
25
25
|
|
26
26
|
def initialize(ignore_file_or_repo)
|
27
|
-
# Check the 'ignore_file_or_repo' path first and then look in the parent
|
27
|
+
# Check the 'ignore_file_or_repo' path first and then look in the parent directories till root
|
28
28
|
# to handle both the chef repo cookbook layout and a standalone cookbook
|
29
29
|
@ignore_file = find_ignore_file(ignore_file_or_repo)
|
30
|
-
@ignore_file = find_ignore_file(File.dirname(ignore_file_or_repo)) unless readable_file_or_symlink?(@ignore_file)
|
31
|
-
|
32
30
|
@ignores = parse_ignore_file
|
33
31
|
end
|
34
32
|
|
@@ -50,27 +48,34 @@ class Chef
|
|
50
48
|
|
51
49
|
def parse_ignore_file
|
52
50
|
ignore_globs = []
|
53
|
-
if readable_file_or_symlink?(@ignore_file)
|
51
|
+
if @ignore_file && readable_file_or_symlink?(@ignore_file)
|
54
52
|
File.foreach(@ignore_file) do |line|
|
55
53
|
ignore_globs << line.strip unless line =~ COMMENTS_AND_WHITESPACE
|
56
54
|
end
|
57
55
|
else
|
58
|
-
Chef::Log.
|
56
|
+
Chef::Log.debug("No chefignore file found. No files will be ignored!")
|
59
57
|
end
|
60
58
|
ignore_globs
|
61
59
|
end
|
62
60
|
|
61
|
+
# Lookup of chefignore file till the root dir of the provided path.
|
62
|
+
# If file refer then lookup the parent dir till the root.
|
63
|
+
# eg. path: /var/.chef/cookbook_name
|
64
|
+
# Lookup at '/var/.chef/cookbook_name/chefignore', '/var/.chef/chefignore' '/var/chefignore' and '/chefignore' until exist
|
63
65
|
def find_ignore_file(path)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
Pathname.new(path).ascend do |dir|
|
67
|
+
next unless dir.directory?
|
68
|
+
|
69
|
+
file = dir.join("chefignore")
|
70
|
+
return file.expand_path.to_s if file.exist?
|
68
71
|
end
|
72
|
+
|
73
|
+
nil
|
69
74
|
end
|
70
75
|
|
71
76
|
def readable_file_or_symlink?(path)
|
72
|
-
File.exist?(
|
73
|
-
(File.file?(
|
77
|
+
File.exist?(path) && File.readable?(path) &&
|
78
|
+
(File.file?(path) || File.symlink?(path))
|
74
79
|
end
|
75
80
|
end
|
76
81
|
end
|