chef 15.4.45 → 15.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -3
  3. data/Rakefile +5 -3
  4. data/chef.gemspec +2 -1
  5. data/lib/chef/application.rb +2 -2
  6. data/lib/chef/application/client.rb +1 -1
  7. data/lib/chef/application/knife.rb +1 -0
  8. data/lib/chef/application/solo.rb +1 -1
  9. data/lib/chef/chef_class.rb +1 -6
  10. data/lib/chef/chef_fs.rb +1 -1
  11. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
  13. data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
  14. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
  16. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
  18. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
  19. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
  20. data/lib/chef/chef_fs/knife.rb +1 -1
  21. data/lib/chef/chef_fs/path_utils.rb +2 -2
  22. data/lib/chef/client.rb +4 -5
  23. data/lib/chef/config.rb +3 -2
  24. data/lib/chef/cookbook/chefignore.rb +16 -11
  25. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  26. data/lib/chef/cookbook/syntax_check.rb +5 -3
  27. data/lib/chef/cookbook_loader.rb +3 -3
  28. data/lib/chef/cookbook_uploader.rb +1 -1
  29. data/lib/chef/data_collector.rb +2 -2
  30. data/lib/chef/data_collector/run_end_message.rb +1 -0
  31. data/lib/chef/deprecated.rb +4 -0
  32. data/lib/chef/dsl/core.rb +1 -1
  33. data/lib/chef/dsl/platform_introspection.rb +9 -18
  34. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  35. data/lib/chef/file_content_management/deploy.rb +3 -3
  36. data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
  37. data/lib/chef/file_content_management/tempfile.rb +1 -1
  38. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
  39. data/lib/chef/http.rb +1 -1
  40. data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
  41. data/lib/chef/knife.rb +4 -3
  42. data/lib/chef/knife/config_get.rb +2 -1
  43. data/lib/chef/knife/configure.rb +1 -1
  44. data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
  45. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  46. data/lib/chef/knife/core/status_presenter.rb +1 -1
  47. data/lib/chef/knife/ssh.rb +6 -0
  48. data/lib/chef/local_mode.rb +1 -1
  49. data/lib/chef/mash.rb +21 -232
  50. data/lib/chef/mixin/file_class.rb +2 -2
  51. data/lib/chef/mixin/lazy_module_include.rb +1 -1
  52. data/lib/chef/mixin/path_sanity.rb +3 -39
  53. data/lib/chef/mixin/securable.rb +1 -1
  54. data/lib/chef/mixin/shell_out.rb +4 -5
  55. data/lib/chef/mixin/template.rb +1 -1
  56. data/lib/chef/mixin/user_context.rb +3 -3
  57. data/lib/chef/mixin/which.rb +10 -38
  58. data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
  59. data/lib/chef/mixin/windows_env_helper.rb +5 -5
  60. data/lib/chef/node/attribute.rb +2 -2
  61. data/lib/chef/node_map.rb +17 -4
  62. data/lib/chef/platform/query_helpers.rb +4 -2
  63. data/lib/chef/platform/rebooter.rb +1 -1
  64. data/lib/chef/platform/service_helpers.rb +14 -85
  65. data/lib/chef/provider.rb +2 -0
  66. data/lib/chef/provider/file.rb +2 -2
  67. data/lib/chef/provider/ifconfig/redhat.rb +1 -1
  68. data/lib/chef/provider/link.rb +3 -3
  69. data/lib/chef/provider/mount/solaris.rb +1 -1
  70. data/lib/chef/provider/package/yum.rb +1 -1
  71. data/lib/chef/provider/registry_key.rb +1 -1
  72. data/lib/chef/provider/remote_directory.rb +3 -3
  73. data/lib/chef/provider/remote_file/fetcher.rb +2 -2
  74. data/lib/chef/provider/remote_file/local_file.rb +1 -1
  75. data/lib/chef/provider/script.rb +3 -3
  76. data/lib/chef/provider/service.rb +5 -2
  77. data/lib/chef/provider/service/arch.rb +1 -1
  78. data/lib/chef/provider/service/debian.rb +4 -4
  79. data/lib/chef/provider/service/init.rb +1 -1
  80. data/lib/chef/provider/service/insserv.rb +4 -4
  81. data/lib/chef/provider/service/invokercd.rb +4 -4
  82. data/lib/chef/provider/service/redhat.rb +4 -4
  83. data/lib/chef/provider/service/systemd.rb +19 -3
  84. data/lib/chef/provider/service/upstart.rb +3 -3
  85. data/lib/chef/provider/subversion.rb +1 -1
  86. data/lib/chef/provider/systemd_unit.rb +26 -2
  87. data/lib/chef/provider/windows_path.rb +3 -3
  88. data/lib/chef/provider/windows_task.rb +4 -4
  89. data/lib/chef/resource.rb +1 -0
  90. data/lib/chef/resource/bash.rb +2 -0
  91. data/lib/chef/resource/batch.rb +2 -0
  92. data/lib/chef/resource/breakpoint.rb +3 -1
  93. data/lib/chef/resource/build_essential.rb +3 -3
  94. data/lib/chef/resource/chef_sleep.rb +70 -0
  95. data/lib/chef/resource/cookbook_file.rb +2 -1
  96. data/lib/chef/resource/csh.rb +2 -0
  97. data/lib/chef/resource/directory.rb +2 -0
  98. data/lib/chef/resource/dmg_package.rb +1 -1
  99. data/lib/chef/resource/dnf_package.rb +1 -1
  100. data/lib/chef/resource/execute.rb +2 -0
  101. data/lib/chef/resource/file.rb +2 -1
  102. data/lib/chef/resource/git.rb +2 -0
  103. data/lib/chef/resource/group.rb +1 -1
  104. data/lib/chef/resource/homebrew_package.rb +1 -1
  105. data/lib/chef/resource/http_request.rb +2 -0
  106. data/lib/chef/resource/ifconfig.rb +3 -1
  107. data/lib/chef/resource/ksh.rb +2 -0
  108. data/lib/chef/resource/link.rb +4 -2
  109. data/lib/chef/resource/locale.rb +1 -1
  110. data/lib/chef/resource/log.rb +2 -0
  111. data/lib/chef/resource/ohai.rb +2 -0
  112. data/lib/chef/resource/perl.rb +2 -0
  113. data/lib/chef/resource/python.rb +2 -0
  114. data/lib/chef/resource/reboot.rb +2 -0
  115. data/lib/chef/resource/registry_key.rb +2 -0
  116. data/lib/chef/resource/remote_directory.rb +3 -2
  117. data/lib/chef/resource/remote_file.rb +1 -0
  118. data/lib/chef/resource/ruby.rb +2 -0
  119. data/lib/chef/resource/ruby_block.rb +2 -0
  120. data/lib/chef/resource/scm.rb +2 -0
  121. data/lib/chef/resource/script.rb +2 -0
  122. data/lib/chef/resource/service.rb +9 -1
  123. data/lib/chef/resource/solaris_package.rb +1 -1
  124. data/lib/chef/resource/subversion.rb +2 -0
  125. data/lib/chef/resource/sudo.rb +1 -1
  126. data/lib/chef/resource/systemd_unit.rb +1 -0
  127. data/lib/chef/resource/template.rb +2 -0
  128. data/lib/chef/resource/user.rb +2 -0
  129. data/lib/chef/resource/user/aix_user.rb +2 -0
  130. data/lib/chef/resource/user/linux_user.rb +2 -0
  131. data/lib/chef/resource/user/pw_user.rb +2 -0
  132. data/lib/chef/resource/user/solaris_user.rb +2 -0
  133. data/lib/chef/resource/user/windows_user.rb +2 -0
  134. data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
  135. data/lib/chef/resource/windows_ad_join.rb +1 -1
  136. data/lib/chef/resource/windows_env.rb +1 -1
  137. data/lib/chef/resource/windows_feature.rb +2 -2
  138. data/lib/chef/resource/windows_feature_powershell.rb +1 -1
  139. data/lib/chef/resource/windows_firewall_rule.rb +11 -6
  140. data/lib/chef/resource/windows_script.rb +3 -1
  141. data/lib/chef/resource/yum_package.rb +1 -1
  142. data/lib/chef/resource_reporter.rb +1 -1
  143. data/lib/chef/resources.rb +1 -0
  144. data/lib/chef/run_context.rb +1 -1
  145. data/lib/chef/run_lock.rb +5 -5
  146. data/lib/chef/search/query.rb +0 -3
  147. data/lib/chef/train_transport.rb +3 -1
  148. data/lib/chef/util/powershell/ps_credential.rb +2 -2
  149. data/lib/chef/util/selinux.rb +1 -1
  150. data/lib/chef/util/windows/logon_session.rb +2 -2
  151. data/lib/chef/version.rb +1 -1
  152. data/lib/chef/win32/eventlog.rb +2 -2
  153. data/spec/data/cookbooks/starter/chefignore +8 -0
  154. data/spec/data/cookbooks/starter/files/sample.txt +1 -0
  155. data/spec/data/cookbooks/starter/metadata.rb +2 -0
  156. data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
  157. data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
  158. data/spec/functional/mixin/user_context_spec.rb +2 -2
  159. data/spec/functional/rebooter_spec.rb +1 -1
  160. data/spec/functional/resource/cookbook_file_spec.rb +2 -2
  161. data/spec/functional/resource/template_spec.rb +1 -1
  162. data/spec/functional/version_spec.rb +1 -1
  163. data/spec/functional/win32/crypto_spec.rb +1 -1
  164. data/spec/functional/win32/security_spec.rb +1 -1
  165. data/spec/functional/win32/service_manager_spec.rb +1 -1
  166. data/spec/functional/win32/sid_spec.rb +2 -2
  167. data/spec/functional/win32/version_info_spec.rb +1 -1
  168. data/spec/functional/win32/versions_spec.rb +1 -1
  169. data/spec/integration/knife/config_get_profile_spec.rb +2 -2
  170. data/spec/integration/knife/config_get_spec.rb +9 -2
  171. data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
  172. data/spec/integration/knife/config_use_profile_spec.rb +2 -2
  173. data/spec/integration/knife/list_spec.rb +2 -2
  174. data/spec/integration/solo/solo_spec.rb +1 -1
  175. data/spec/support/matchers/leak.rb +1 -1
  176. data/spec/support/mock/platform.rb +1 -1
  177. data/spec/support/platform_helpers.rb +2 -0
  178. data/spec/support/shared/integration/integration_helper.rb +1 -1
  179. data/spec/support/shared/integration/knife_support.rb +1 -1
  180. data/spec/support/shared/unit/provider/file.rb +4 -4
  181. data/spec/unit/application/client_spec.rb +2 -2
  182. data/spec/unit/application/knife_spec.rb +17 -0
  183. data/spec/unit/application_spec.rb +1 -1
  184. data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
  185. data/spec/unit/chef_fs/path_util_spec.rb +3 -3
  186. data/spec/unit/client_spec.rb +2 -2
  187. data/spec/unit/cookbook/chefignore_spec.rb +31 -11
  188. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
  189. data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
  190. data/spec/unit/cookbook_loader_spec.rb +2 -2
  191. data/spec/unit/cookbook_uploader_spec.rb +6 -1
  192. data/spec/unit/data_bag_spec.rb +2 -2
  193. data/spec/unit/data_collector_spec.rb +7 -0
  194. data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
  195. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
  196. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
  197. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
  198. data/spec/unit/knife/cookbook_show_spec.rb +1 -1
  199. data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
  200. data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
  201. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
  202. data/spec/unit/knife/core/ui_spec.rb +2 -2
  203. data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
  204. data/spec/unit/knife/environment_from_file_spec.rb +2 -2
  205. data/spec/unit/knife/ssh_spec.rb +27 -17
  206. data/spec/unit/knife/status_spec.rb +1 -1
  207. data/spec/unit/knife/supermarket_install_spec.rb +1 -1
  208. data/spec/unit/mixin/path_sanity_spec.rb +3 -3
  209. data/spec/unit/mixin/shell_out_spec.rb +2 -3
  210. data/spec/unit/mixin/template_spec.rb +4 -4
  211. data/spec/unit/mixin/user_context_spec.rb +3 -3
  212. data/spec/unit/node_map_spec.rb +12 -12
  213. data/spec/unit/platform/query_helpers_spec.rb +9 -9
  214. data/spec/unit/provider/execute_spec.rb +1 -1
  215. data/spec/unit/provider/link_spec.rb +5 -5
  216. data/spec/unit/provider/package/openbsd_spec.rb +1 -1
  217. data/spec/unit/provider/package/smartos_spec.rb +1 -1
  218. data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
  219. data/spec/unit/provider/package/windows_spec.rb +2 -2
  220. data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
  221. data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
  222. data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
  223. data/spec/unit/provider/script_spec.rb +2 -2
  224. data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
  225. data/spec/unit/provider/subversion_spec.rb +3 -3
  226. data/spec/unit/provider/systemd_unit_spec.rb +53 -4
  227. data/spec/unit/provider/user/dscl_spec.rb +1 -1
  228. data/spec/unit/provider_resolver_spec.rb +41 -61
  229. data/spec/unit/resource/chef_sleep_spec.rb +30 -0
  230. data/spec/unit/resource/cookbook_file_spec.rb +3 -3
  231. data/spec/unit/resource/remote_file_spec.rb +3 -3
  232. data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
  233. data/spec/unit/role_spec.rb +2 -2
  234. data/spec/unit/shell_spec.rb +1 -1
  235. data/spec/unit/util/selinux_spec.rb +2 -2
  236. data/spec/unit/win32/error_spec.rb +1 -1
  237. data/spec/unit/win32/link_spec.rb +1 -1
  238. data/spec/unit/win32/security_spec.rb +1 -1
  239. data/spec/unit/windows_service_spec.rb +1 -1
  240. data/tasks/docs.rb +10 -2
  241. data/tasks/rspec.rb +8 -6
  242. metadata +32 -8
  243. data/lib/chef/mixin/train_helpers.rb +0 -60
  244. data/spec/unit/mash_spec.rb +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09023fe03c2a36ec34f9b087b7671cd38d066cde37ad6027051f333046950701'
4
- data.tar.gz: cdd9bd027741716d597f2cc5c9faa1bfaac2f14f7c28b98995b0f71bc8afb295
3
+ metadata.gz: b826d0315123f87d4feb069a4289749d0bf5db9a76853499c80dcbddfdad2ed0
4
+ data.tar.gz: 27867153b65d9cd6123d57898e1a9348490d163c7dea664448d1e275786dc2d3
5
5
  SHA512:
6
- metadata.gz: 52c05b3792352bf46d3124412c92bb1e4a2d2b693de090bb7e793a923547a68955ab1f1faf3bd2c122d1850dd8f9b2c12e0f4ac639a60bdb9ad6cb1b2e607f52
7
- data.tar.gz: b9fb6e927fb5d5277979db1e798526b5294e55326a7c0fbc5527d0b736134fc78cec96f9e6584c3bab768a91f2328b66218ed7814735c610a5102af635a28422
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.3"
29
- gem "inspec-core-bin", "~> 4.3" # need to provide the binaries for inspec
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(__FILE__ + ".local") if File.exist?(__FILE__ + ".local")
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
- chef_config_path = ::File.join(::File.dirname(__FILE__), "chef-config")
30
- Dir.chdir(chef_config_path)
31
- sh("rake install")
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
@@ -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", "~> 2.1"
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"
@@ -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 Chef::Platform.windows?
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) && !Chef::Platform.windows?
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 Chef::Platform.windows?
36
+ unless ChefUtils.windows?
37
37
  option :daemonize,
38
38
  short: "-d [WAIT]",
39
39
  long: "--daemonize [WAIT]",
@@ -114,6 +114,7 @@ class Chef::Application::Knife < Chef::Application
114
114
  short: "-F FORMAT",
115
115
  long: "--format FORMAT",
116
116
  description: "Which format to use for output.",
117
+ in: %w{summary text json yaml pp},
117
118
  default: "summary"
118
119
 
119
120
  option :local_mode,
@@ -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 Chef::Platform.windows?
39
+ unless ChefUtils.windows?
40
40
  option :daemonize,
41
41
  short: "-d",
42
42
  long: "--daemonize",
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Lamont Granquist (<lamont@chef.io>)
3
- # Copyright:: Copyright 2015-2016, Chef Software, Inc.
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
@@ -53,7 +53,7 @@ require_relative "platform"
53
53
  class Chef
54
54
  module ChefFS
55
55
  def self.windows?
56
- Chef::Platform.windows?
56
+ ChefUtils.windows?
57
57
  end
58
58
  end
59
59
  end
@@ -245,7 +245,7 @@ class Chef
245
245
  end
246
246
 
247
247
  def self.pattern_special_characters
248
- if Chef::ChefFS.windows?
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.parent.chefignore)
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 Chef::Platform.windows?
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.parent.chefignore)
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 Chef::Platform.windows?
94
+ if ChefUtils.windows?
95
95
  Dir.rmdir proxy_cookbook_path
96
96
  end
97
97
  end
@@ -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, parent.chefignore)
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, parent.chefignore)
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 = parent
71
+ ignorer = self
72
+
72
73
  loop do
73
- if ignorer.is_a?(CookbooksDir)
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.parent != ignorer
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-2016, Chef Software, Inc.
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 Chef::Platform.windows?
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 Chef::Platform.windows?
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
@@ -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, parent.chefignore)
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-2016, Chef Software Inc.
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 Chef::Platform.windows?
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 Chef::Platform.windows?
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
@@ -18,7 +18,7 @@
18
18
 
19
19
  require_relative "../knife"
20
20
  require "pathname" unless defined?(Pathname)
21
- require "chef/dist"
21
+ require_relative "../dist"
22
22
 
23
23
  class Chef
24
24
  module ChefFS
@@ -58,7 +58,7 @@ class Chef
58
58
  end
59
59
 
60
60
  def self.regexp_path_separator
61
- Chef::ChefFS.windows? ? '[\/\\\\]' : "/"
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
- Chef::ChefFS.windows? ? left.casecmp(right) == 0 : left == right
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
@@ -20,7 +20,7 @@
20
20
 
21
21
  require_relative "config"
22
22
  require_relative "mixin/params_validate"
23
- require_relative "mixin/path_sanity"
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 Chef::Platform.windows?
751
+ if ChefUtils.windows?
753
752
  logger.trace("Checking for administrator privileges....")
754
753
 
755
754
  if !has_admin_privileges?
@@ -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-2016, Chef Software Inc.
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 ChefConfig.windows? && !Chef::Platform.windows_nano_server?
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 directory
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.trace("No chefignore file found at #{@ignore_file} no files will be ignored")
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
- if File.basename(path) =~ /chefignore/
65
- path
66
- else
67
- File.join(path, "chefignore")
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?(@ignore_file) && File.readable?(@ignore_file) &&
73
- (File.file?(@ignore_file) || File.symlink?(@ignore_file))
77
+ File.exist?(path) && File.readable?(path) &&
78
+ (File.file?(path) || File.symlink?(path))
74
79
  end
75
80
  end
76
81
  end