chef 17.10.163 → 18.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +25 -21
  3. data/README.md +7 -7
  4. data/Rakefile +3 -22
  5. data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
  6. data/chef.gemspec +33 -27
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/base.rb +20 -2
  9. data/lib/chef/application/exit_code.rb +3 -3
  10. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  11. data/lib/chef/chef_fs/file_system.rb +21 -7
  12. data/lib/chef/chef_fs/path_utils.rb +7 -9
  13. data/lib/chef/client.rb +186 -2
  14. data/lib/chef/compliance/default_attributes.rb +2 -2
  15. data/lib/chef/compliance/input.rb +1 -1
  16. data/lib/chef/compliance/profile.rb +1 -1
  17. data/lib/chef/compliance/profile_collection.rb +0 -1
  18. data/lib/chef/compliance/runner.rb +6 -1
  19. data/lib/chef/compliance/waiver.rb +1 -1
  20. data/lib/chef/cookbook/chefignore.rb +4 -1
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  22. data/lib/chef/cookbook/metadata.rb +1 -1
  23. data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
  24. data/lib/chef/cookbook/synchronizer.rb +21 -3
  25. data/lib/chef/cookbook/syntax_check.rb +2 -2
  26. data/lib/chef/cookbook_manifest.rb +2 -2
  27. data/lib/chef/cookbook_version.rb +1 -1
  28. data/lib/chef/data_collector.rb +14 -0
  29. data/lib/chef/delayed_evaluator.rb +4 -0
  30. data/lib/chef/dsl/reader_helpers.rb +1 -1
  31. data/lib/chef/dsl/rest_resource.rb +77 -0
  32. data/lib/chef/event_dispatch/base.rb +3 -0
  33. data/lib/chef/event_dispatch/dispatcher.rb +0 -1
  34. data/lib/chef/exceptions.rb +9 -1
  35. data/lib/chef/file_access_control/windows.rb +4 -1
  36. data/lib/chef/file_cache.rb +17 -2
  37. data/lib/chef/formatters/doc.rb +1 -1
  38. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
  39. data/lib/chef/http/authenticator.rb +253 -3
  40. data/lib/chef/http/ssl_policies.rb +2 -2
  41. data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
  42. data/lib/chef/mixin/openssl_helper.rb +1 -16
  43. data/lib/chef/mixin/powershell_exec.rb +5 -28
  44. data/lib/chef/monkey_patches/net-http.rb +127 -0
  45. data/lib/chef/node/attribute.rb +3 -11
  46. data/lib/chef/node/attribute_collections.rb +10 -1
  47. data/lib/chef/node/immutable_collections.rb +17 -6
  48. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  49. data/lib/chef/node/mixin/state_tracking.rb +7 -4
  50. data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
  51. data/lib/chef/node.rb +23 -1
  52. data/lib/chef/platform/query_helpers.rb +4 -2
  53. data/lib/chef/policy_builder/policyfile.rb +8 -0
  54. data/lib/chef/property.rb +13 -6
  55. data/lib/chef/provider/group/windows.rb +1 -1
  56. data/lib/chef/provider/http_request.rb +11 -9
  57. data/lib/chef/provider/launchd.rb +2 -1
  58. data/lib/chef/provider/mount/linux.rb +6 -1
  59. data/lib/chef/provider/mount/mount.rb +13 -5
  60. data/lib/chef/provider/mount/windows.rb +1 -1
  61. data/lib/chef/provider/package/apt.rb +11 -2
  62. data/lib/chef/provider/package/chocolatey.rb +260 -22
  63. data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
  64. data/lib/chef/provider/package/homebrew.rb +6 -9
  65. data/lib/chef/provider/package/powershell.rb +1 -0
  66. data/lib/chef/provider/package/rubygems.rb +5 -1
  67. data/lib/chef/provider/package/snap.rb +3 -2
  68. data/lib/chef/provider/package/windows/msi.rb +2 -2
  69. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  70. data/lib/chef/provider/package/yum/yum_helper.py +3 -3
  71. data/lib/chef/provider/package/zypper/version.rb +60 -0
  72. data/lib/chef/provider/package/zypper.rb +47 -3
  73. data/lib/chef/provider/powershell_script.rb +96 -6
  74. data/lib/chef/provider/registry_key.rb +2 -0
  75. data/lib/chef/provider/remote_file/http.rb +1 -1
  76. data/lib/chef/provider/service/systemd.rb +23 -8
  77. data/lib/chef/provider/service/windows.rb +1 -1
  78. data/lib/chef/provider/service.rb +14 -0
  79. data/lib/chef/provider/user/aix.rb +5 -0
  80. data/lib/chef/provider/user/linux.rb +29 -0
  81. data/lib/chef/provider/user/mac.rb +1 -1
  82. data/lib/chef/provider/user/windows.rb +5 -0
  83. data/lib/chef/provider/user.rb +45 -9
  84. data/lib/chef/provider/yum_repository.rb +13 -1
  85. data/lib/chef/provider.rb +1 -1
  86. data/lib/chef/recipe.rb +4 -12
  87. data/lib/chef/resource/_rest_resource.rb +389 -0
  88. data/lib/chef/resource/alternatives.rb +0 -1
  89. data/lib/chef/resource/apt_package.rb +21 -1
  90. data/lib/chef/resource/apt_preference.rb +0 -1
  91. data/lib/chef/resource/apt_repository.rb +138 -18
  92. data/lib/chef/resource/apt_update.rb +0 -1
  93. data/lib/chef/resource/archive_file.rb +0 -1
  94. data/lib/chef/resource/bash.rb +13 -1
  95. data/lib/chef/resource/batch.rb +0 -1
  96. data/lib/chef/resource/bff_package.rb +0 -1
  97. data/lib/chef/resource/breakpoint.rb +0 -1
  98. data/lib/chef/resource/build_essential.rb +0 -1
  99. data/lib/chef/resource/cab_package.rb +0 -1
  100. data/lib/chef/resource/chef_client_config.rb +12 -14
  101. data/lib/chef/resource/chef_client_cron.rb +1 -2
  102. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  103. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  104. data/lib/chef/resource/chef_client_systemd_timer.rb +5 -1
  105. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  106. data/lib/chef/resource/chef_gem.rb +1 -2
  107. data/lib/chef/resource/chef_handler.rb +0 -1
  108. data/lib/chef/resource/chef_sleep.rb +1 -3
  109. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  110. data/lib/chef/resource/chocolatey_config.rb +0 -1
  111. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  112. data/lib/chef/resource/chocolatey_installer.rb +207 -0
  113. data/lib/chef/resource/chocolatey_package.rb +8 -1
  114. data/lib/chef/resource/chocolatey_source.rb +0 -1
  115. data/lib/chef/resource/cookbook_file.rb +0 -1
  116. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  117. data/lib/chef/resource/cron/cron.rb +0 -1
  118. data/lib/chef/resource/cron/cron_d.rb +15 -1
  119. data/lib/chef/resource/cron_access.rb +0 -1
  120. data/lib/chef/resource/csh.rb +0 -1
  121. data/lib/chef/resource/directory.rb +0 -1
  122. data/lib/chef/resource/dmg_package.rb +2 -1
  123. data/lib/chef/resource/dnf_package.rb +0 -1
  124. data/lib/chef/resource/dpkg_package.rb +0 -1
  125. data/lib/chef/resource/dsc_resource.rb +0 -1
  126. data/lib/chef/resource/dsc_script.rb +1 -2
  127. data/lib/chef/resource/execute.rb +8 -7
  128. data/lib/chef/resource/file.rb +0 -1
  129. data/lib/chef/resource/freebsd_package.rb +2 -1
  130. data/lib/chef/resource/gem_package.rb +2 -1
  131. data/lib/chef/resource/group.rb +25 -2
  132. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  133. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  134. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  135. data/lib/chef/resource/habitat_config.rb +0 -1
  136. data/lib/chef/resource/habitat_install.rb +2 -2
  137. data/lib/chef/resource/habitat_service.rb +0 -1
  138. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  139. data/lib/chef/resource/homebrew_cask.rb +21 -33
  140. data/lib/chef/resource/homebrew_package.rb +3 -2
  141. data/lib/chef/resource/homebrew_tap.rb +32 -18
  142. data/lib/chef/resource/homebrew_update.rb +4 -6
  143. data/lib/chef/resource/hostname.rb +0 -1
  144. data/lib/chef/resource/http_request.rb +0 -1
  145. data/lib/chef/resource/ifconfig.rb +0 -1
  146. data/lib/chef/resource/inspec_input.rb +0 -1
  147. data/lib/chef/resource/inspec_waiver.rb +0 -1
  148. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  149. data/lib/chef/resource/ips_package.rb +0 -1
  150. data/lib/chef/resource/kernel_module.rb +0 -1
  151. data/lib/chef/resource/ksh.rb +0 -1
  152. data/lib/chef/resource/launchd.rb +9 -3
  153. data/lib/chef/resource/link.rb +0 -1
  154. data/lib/chef/resource/locale.rb +0 -1
  155. data/lib/chef/resource/log.rb +0 -1
  156. data/lib/chef/resource/lwrp_base.rb +0 -4
  157. data/lib/chef/resource/macos_pkg.rb +111 -0
  158. data/lib/chef/resource/macos_userdefaults.rb +3 -4
  159. data/lib/chef/resource/macosx_service.rb +0 -1
  160. data/lib/chef/resource/macports_package.rb +2 -1
  161. data/lib/chef/resource/mdadm.rb +0 -1
  162. data/lib/chef/resource/mount.rb +0 -1
  163. data/lib/chef/resource/msu_package.rb +0 -1
  164. data/lib/chef/resource/notify_group.rb +0 -2
  165. data/lib/chef/resource/ohai.rb +0 -1
  166. data/lib/chef/resource/ohai_hint.rb +0 -1
  167. data/lib/chef/resource/openbsd_package.rb +2 -1
  168. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  169. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  170. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  171. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  172. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  173. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  174. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  175. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  176. data/lib/chef/resource/osx_profile.rb +0 -1
  177. data/lib/chef/resource/package.rb +0 -1
  178. data/lib/chef/resource/pacman_package.rb +2 -1
  179. data/lib/chef/resource/paludis_package.rb +0 -1
  180. data/lib/chef/resource/perl.rb +0 -1
  181. data/lib/chef/resource/plist.rb +7 -3
  182. data/lib/chef/resource/portage_package.rb +2 -1
  183. data/lib/chef/resource/powershell_package.rb +4 -1
  184. data/lib/chef/resource/powershell_package_source.rb +0 -1
  185. data/lib/chef/resource/powershell_script.rb +5 -2
  186. data/lib/chef/resource/python.rb +0 -1
  187. data/lib/chef/resource/reboot.rb +0 -1
  188. data/lib/chef/resource/registry_key.rb +6 -1
  189. data/lib/chef/resource/remote_directory.rb +0 -1
  190. data/lib/chef/resource/remote_file.rb +0 -1
  191. data/lib/chef/resource/rhsm_errata.rb +0 -1
  192. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  193. data/lib/chef/resource/rhsm_register.rb +2 -4
  194. data/lib/chef/resource/rhsm_repo.rb +0 -1
  195. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  196. data/lib/chef/resource/route.rb +0 -1
  197. data/lib/chef/resource/rpm_package.rb +2 -1
  198. data/lib/chef/resource/ruby.rb +0 -1
  199. data/lib/chef/resource/ruby_block.rb +0 -1
  200. data/lib/chef/resource/scm/_scm.rb +0 -2
  201. data/lib/chef/resource/scm/git.rb +0 -2
  202. data/lib/chef/resource/scm/subversion.rb +0 -2
  203. data/lib/chef/resource/script.rb +0 -1
  204. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  205. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  206. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  207. data/lib/chef/resource/selinux_boolean.rb +101 -0
  208. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  209. data/lib/chef/resource/selinux_install.rb +107 -0
  210. data/lib/chef/resource/selinux_login.rb +129 -0
  211. data/lib/chef/resource/selinux_module.rb +143 -0
  212. data/lib/chef/resource/selinux_permissive.rb +64 -0
  213. data/lib/chef/resource/selinux_port.rb +118 -0
  214. data/lib/chef/resource/selinux_state.rb +166 -0
  215. data/lib/chef/resource/selinux_user.rb +137 -0
  216. data/lib/chef/resource/service.rb +4 -2
  217. data/lib/chef/resource/smartos_package.rb +2 -1
  218. data/lib/chef/resource/snap_package.rb +25 -1
  219. data/lib/chef/resource/solaris_package.rb +2 -1
  220. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  221. data/lib/chef/resource/sudo.rb +37 -3
  222. data/lib/chef/resource/support/client.erb +2 -2
  223. data/lib/chef/resource/support/ulimit.erb +40 -0
  224. data/lib/chef/resource/swap_file.rb +0 -1
  225. data/lib/chef/resource/sysctl.rb +2 -2
  226. data/lib/chef/resource/systemd_unit.rb +0 -1
  227. data/lib/chef/resource/template.rb +0 -1
  228. data/lib/chef/resource/timezone.rb +0 -1
  229. data/lib/chef/resource/user/aix_user.rb +0 -1
  230. data/lib/chef/resource/user/linux_user.rb +0 -1
  231. data/lib/chef/resource/user/mac_user.rb +0 -1
  232. data/lib/chef/resource/user/pw_user.rb +0 -1
  233. data/lib/chef/resource/user/solaris_user.rb +0 -1
  234. data/lib/chef/resource/user/windows_user.rb +0 -1
  235. data/lib/chef/resource/user.rb +10 -1
  236. data/lib/chef/resource/user_ulimit.rb +38 -1
  237. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  238. data/lib/chef/resource/windows_ad_join.rb +0 -2
  239. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  240. data/lib/chef/resource/windows_auto_run.rb +0 -1
  241. data/lib/chef/resource/windows_certificate.rb +1 -1
  242. data/lib/chef/resource/windows_defender.rb +0 -1
  243. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  244. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  245. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  246. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  247. data/lib/chef/resource/windows_dns_record.rb +0 -1
  248. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  249. data/lib/chef/resource/windows_env.rb +0 -1
  250. data/lib/chef/resource/windows_feature.rb +0 -1
  251. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  252. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  253. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  254. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  255. data/lib/chef/resource/windows_font.rb +2 -3
  256. data/lib/chef/resource/windows_package.rb +3 -4
  257. data/lib/chef/resource/windows_pagefile.rb +0 -2
  258. data/lib/chef/resource/windows_path.rb +0 -1
  259. data/lib/chef/resource/windows_printer.rb +0 -1
  260. data/lib/chef/resource/windows_printer_port.rb +0 -1
  261. data/lib/chef/resource/windows_script.rb +0 -2
  262. data/lib/chef/resource/windows_security_policy.rb +2 -3
  263. data/lib/chef/resource/windows_service.rb +0 -1
  264. data/lib/chef/resource/windows_share.rb +0 -1
  265. data/lib/chef/resource/windows_shortcut.rb +1 -2
  266. data/lib/chef/resource/windows_task.rb +0 -1
  267. data/lib/chef/resource/windows_uac.rb +0 -1
  268. data/lib/chef/resource/windows_update_settings.rb +0 -1
  269. data/lib/chef/resource/windows_user_privilege.rb +14 -11
  270. data/lib/chef/resource/windows_workgroup.rb +0 -1
  271. data/lib/chef/resource/yum_package.rb +2 -1
  272. data/lib/chef/resource/yum_repository.rb +4 -1
  273. data/lib/chef/resource/zypper_package.rb +2 -1
  274. data/lib/chef/resource/zypper_repository.rb +0 -1
  275. data/lib/chef/resource.rb +23 -5
  276. data/lib/chef/resource_inspector.rb +25 -7
  277. data/lib/chef/resource_reporter.rb +4 -0
  278. data/lib/chef/resources.rb +11 -0
  279. data/lib/chef/run_context.rb +3 -3
  280. data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
  281. data/lib/chef/util/powershell/ps_credential.rb +10 -0
  282. data/lib/chef/version.rb +1 -1
  283. data/lib/chef/win32/handle.rb +6 -7
  284. data/lib/chef/win32/registry.rb +12 -4
  285. data/lib/chef/win32/security.rb +16 -1
  286. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  287. data/spec/data/trusted_certs/intermediate.pem +38 -27
  288. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  289. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  290. data/spec/functional/resource/execute_spec.rb +1 -1
  291. data/spec/functional/resource/group_spec.rb +26 -42
  292. data/spec/functional/resource/link_spec.rb +8 -8
  293. data/spec/functional/resource/plist_spec.rb +25 -0
  294. data/spec/functional/resource/registry_spec.rb +233 -609
  295. data/spec/functional/resource/remote_file_spec.rb +1 -1
  296. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  297. data/spec/functional/resource/windows_certificate_spec.rb +1 -1
  298. data/spec/functional/resource/windows_font_spec.rb +12 -9
  299. data/spec/functional/resource/yum_package_spec.rb +1 -1
  300. data/spec/functional/resource/zypper_package_spec.rb +12 -0
  301. data/spec/functional/shell_spec.rb +1 -2
  302. data/spec/functional/version_spec.rb +1 -1
  303. data/spec/functional/win32/registry_spec.rb +0 -3
  304. data/spec/integration/client/client_spec.rb +88 -3
  305. data/spec/integration/client/exit_code_spec.rb +1 -1
  306. data/spec/integration/client/fips_spec.rb +5 -5
  307. data/spec/integration/client/ipv6_spec.rb +1 -1
  308. data/spec/integration/client/open_ssl_spec.rb +3 -3
  309. data/spec/integration/compliance/compliance_spec.rb +1 -1
  310. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  311. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  312. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  313. data/spec/integration/recipes/notifies_spec.rb +1 -1
  314. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  315. data/spec/integration/recipes/remote_directory.rb +1 -1
  316. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  317. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  318. data/spec/integration/solo/solo_spec.rb +2 -2
  319. data/spec/spec_helper.rb +7 -4
  320. data/spec/support/chef_helpers.rb +2 -2
  321. data/spec/support/platform_helpers.rb +28 -7
  322. data/spec/support/ruby_installer.rb +1 -1
  323. data/spec/support/shared/functional/file_resource.rb +3 -3
  324. data/spec/support/shared/functional/windows_script.rb +2 -2
  325. data/spec/tiny_server.rb +5 -2
  326. data/spec/unit/application/client_spec.rb +0 -10
  327. data/spec/unit/chef_fs/file_system_spec.rb +2 -0
  328. data/spec/unit/client_spec.rb +80 -4
  329. data/spec/unit/compliance/runner_spec.rb +8 -0
  330. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  331. data/spec/unit/data_collector_spec.rb +106 -2
  332. data/spec/unit/delayed_evaluator_spec.rb +35 -0
  333. data/spec/unit/file_cache_spec.rb +64 -0
  334. data/spec/unit/http/authenticator_spec.rb +121 -0
  335. data/spec/unit/mixin/homebrew_spec.rb +118 -0
  336. data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
  337. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  338. data/spec/unit/node/vivid_mash_spec.rb +42 -0
  339. data/spec/unit/node_spec.rb +6 -0
  340. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  341. data/spec/unit/property/validation_spec.rb +30 -0
  342. data/spec/unit/provider/apt_repository_spec.rb +48 -12
  343. data/spec/unit/provider/cron_spec.rb +2 -0
  344. data/spec/unit/provider/http_request_spec.rb +60 -72
  345. data/spec/unit/provider/launchd_spec.rb +2 -2
  346. data/spec/unit/provider/mount/aix_spec.rb +2 -2
  347. data/spec/unit/provider/mount/linux_spec.rb +15 -4
  348. data/spec/unit/provider/mount/mount_spec.rb +8 -8
  349. data/spec/unit/provider/package/apt_spec.rb +18 -13
  350. data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
  351. data/spec/unit/provider/package/homebrew_spec.rb +4 -1
  352. data/spec/unit/provider/package/rpm_spec.rb +2 -2
  353. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  354. data/spec/unit/provider/package/windows_spec.rb +5 -5
  355. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  356. data/spec/unit/provider/powershell_script_spec.rb +100 -4
  357. data/spec/unit/provider/registry_key_spec.rb +17 -17
  358. data/spec/unit/provider/remote_file/http_spec.rb +4 -4
  359. data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
  360. data/spec/unit/provider/user/linux_spec.rb +51 -1
  361. data/spec/unit/provider/user/windows_spec.rb +1 -0
  362. data/spec/unit/provider/user_spec.rb +24 -6
  363. data/spec/unit/resource/apt_repository_spec.rb +5 -0
  364. data/spec/unit/resource/archive_file_spec.rb +1 -1
  365. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  366. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  367. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  368. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  369. data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
  370. data/spec/unit/resource/cron_d_spec.rb +37 -1
  371. data/spec/unit/resource/macos_pkg_spec.rb +38 -0
  372. data/spec/unit/resource/powershell_script_spec.rb +2 -2
  373. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  374. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  375. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  376. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  377. data/spec/unit/resource/selinux_login_spec.rb +73 -0
  378. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  379. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  380. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  381. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  382. data/spec/unit/resource/selinux_user_spec.rb +92 -0
  383. data/spec/unit/resource/sysctl_spec.rb +2 -2
  384. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  385. data/spec/unit/resource/yum_repository_spec.rb +4 -0
  386. data/spec/unit/resource_inspector_spec.rb +36 -0
  387. data/spec/unit/resource_reporter_spec.rb +57 -3
  388. data/spec/unit/resource_spec.rb +94 -2
  389. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  390. data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
  391. data/tasks/rspec.rb +1 -1
  392. metadata +126 -44
  393. data/lib/chef/powershell.rb +0 -81
  394. data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
  395. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  396. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  397. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  398. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  399. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  400. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
@@ -21,15 +21,16 @@ require_relative "../resource"
21
21
  class Chef
22
22
  class Resource
23
23
  class WindowsUserPrivilege < Chef::Resource
24
- unified_mode true
25
24
 
26
25
  provides :windows_user_privilege
27
- description "The windows_user_privilege resource allows to add a privilege to a principal or (User/Group).\n Ref: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-rights-assignment"
26
+ description "Use the **windows_user_privilege** resource to set privileges for a principal, user, or group.\n See [Microsoft's user rights assignment documentation](https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-rights-assignment) for more information."
28
27
 
29
28
  introduced "16.0"
30
29
 
31
30
  examples <<~DOC
32
- **Set the SeNetworkLogonRight Privilege for the Builtin Administrators Group and Authenticated Users**:
31
+ **Set the SeNetworkLogonRight privilege for the Builtin Administrators and Authenticated Users groups**:
32
+
33
+ The `:set` action will add this privilege for these two groups and remove this privilege from all other groups or users.
33
34
 
34
35
  ```ruby
35
36
  windows_user_privilege 'Network Logon Rights' do
@@ -39,7 +40,9 @@ class Chef
39
40
  end
40
41
  ```
41
42
 
42
- **Provide only the Builtin Guests and Administrator Groups with the SeCreatePageFile Privilege**:
43
+ **Set the SeCreatePagefilePrivilege privilege for the Builtin Guests and Administrator groups**:
44
+
45
+ The `:set` action will add this privilege for these two groups and remove this privilege from all other groups or users.
43
46
 
44
47
  ```ruby
45
48
  windows_user_privilege 'Create Pagefile' do
@@ -49,7 +52,7 @@ class Chef
49
52
  end
50
53
  ```
51
54
 
52
- **Add the SeDenyRemoteInteractiveLogonRight Privilege to the 'Remote interactive logon' principal**:
55
+ **Add the SeDenyRemoteInteractiveLogonRight privilege to the 'Remote interactive logon' principal**:
53
56
 
54
57
  ```ruby
55
58
  windows_user_privilege 'Remote interactive logon' do
@@ -58,7 +61,7 @@ class Chef
58
61
  end
59
62
  ```
60
63
 
61
- **Add to the Builtin Guests Group the SeCreatePageFile Privilege**:
64
+ **Add the SeCreatePageFilePrivilege privilege to the Builtin Guests group**:
62
65
 
63
66
  ```ruby
64
67
  windows_user_privilege 'Guests add Create Pagefile' do
@@ -68,7 +71,7 @@ class Chef
68
71
  end
69
72
  ```
70
73
 
71
- **Remove the SeCreatePageFile Privilege from the Builtin Guests Group**:
74
+ **Remove the SeCreatePageFilePrivilege privilege from the Builtin Guests group**:
72
75
 
73
76
  ```ruby
74
77
  windows_user_privilege 'Create Pagefile' do
@@ -78,7 +81,7 @@ class Chef
78
81
  end
79
82
  ```
80
83
 
81
- **Clear all users from the SeDenyNetworkLogonRight Privilege**:
84
+ **Clear the SeDenyNetworkLogonRight privilege from all users**:
82
85
 
83
86
  ```ruby
84
87
  windows_user_privilege 'Allow any user the Network Logon right' do
@@ -136,15 +139,15 @@ class Chef
136
139
  }.freeze
137
140
 
138
141
  property :principal, String,
139
- description: "An optional property to add the privilege for given principal. Use only with add and remove action. Principal can either be a User/Group or one of special identities found here Ref: https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/special-identities",
142
+ description: "An optional property to add the privilege for given principal. Use only with add and remove action. Principal can either be a user, group, or [special identity](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/special-identities).",
140
143
  name_property: true
141
144
 
142
145
  property :users, [Array, String],
143
- description: "An optional property to set the privilege for given users. Use only with set action.",
146
+ description: "An optional property to set the privilege for the specified users. Use only with `:set` action",
144
147
  coerce: proc { |v| Array(v) }
145
148
 
146
149
  property :privilege, [Array, String],
147
- description: "One or more privileges to set for principal or users/groups. For more information on what each privilege does Ref: https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-rights-assignment",
150
+ description: "One or more privileges to set for principal or users/groups. For more information, see [Microsoft's documentation on what each privilege does](https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-rights-assignment).",
148
151
  required: true,
149
152
  coerce: proc { |v| Array(v) },
150
153
  callbacks: {
@@ -21,7 +21,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
21
21
  class Chef
22
22
  class Resource
23
23
  class WindowsWorkgroup < Chef::Resource
24
- unified_mode true
25
24
 
26
25
  provides :windows_workgroup
27
26
 
@@ -22,7 +22,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
22
22
  class Chef
23
23
  class Resource
24
24
  class YumPackage < Chef::Resource::Package
25
- unified_mode true
26
25
 
27
26
  provides :yum_package
28
27
  provides :package, platform_family: "fedora_derived"
@@ -110,6 +109,8 @@ class Chef
110
109
  ```
111
110
  DOC
112
111
 
112
+ allowed_actions :install, :upgrade, :remove, :purge, :lock, :unlock
113
+
113
114
  # XXX: the coercions here are due to the provider promiscuously updating the properties on the
114
115
  # new_resource which causes immutable modification exceptions when passed an immutable node array.
115
116
  #
@@ -21,7 +21,6 @@ require_relative "../resource"
21
21
  class Chef
22
22
  class Resource
23
23
  class YumRepository < Chef::Resource
24
- unified_mode true
25
24
 
26
25
  provides(:yum_repository) { true }
27
26
 
@@ -115,6 +114,10 @@ class Chef
115
114
  description: "Determines whether package files downloaded by Yum stay in cache directories. By using cached data, you can carry out certain operations without a network connection.",
116
115
  default: true
117
116
 
117
+ property :makecache_fast, [TrueClass, FalseClass],
118
+ description: "if make_cache is true, uses `yum makecache fast`, which downloads only the minimum amount of data required. Useful over slower connections and when disk space is at a premium.",
119
+ default: false
120
+
118
121
  property :max_retries, [String, Integer],
119
122
  description: "Number of times any attempt to retrieve a file should retry before returning an error. Setting this to `0` makes Yum try forever."
120
123
 
@@ -21,7 +21,6 @@ require_relative "package"
21
21
  class Chef
22
22
  class Resource
23
23
  class ZypperPackage < Chef::Resource::Package
24
- unified_mode true
25
24
 
26
25
  provides :zypper_package
27
26
  provides :package, platform_family: "suse"
@@ -54,6 +53,8 @@ class Chef
54
53
  ```
55
54
  DOC
56
55
 
56
+ allowed_actions :install, :upgrade, :remove, :purge, :lock, :unlock
57
+
57
58
  property :gpg_check, [ TrueClass, FalseClass ],
58
59
  description: "Verify the package's GPG signature. Can also be controlled site-wide using the `zypper_check_gpg` config option.",
59
60
  default: lazy { Chef::Config[:zypper_check_gpg] }, default_description: "true"
@@ -21,7 +21,6 @@ require_relative "../resource"
21
21
  class Chef
22
22
  class Resource
23
23
  class ZypperRepository < Chef::Resource
24
- unified_mode true
25
24
 
26
25
  provides(:zypper_repository) { true }
27
26
  provides(:zypper_repo) { true } # legacy cookbook compatibility
data/lib/chef/resource.rb CHANGED
@@ -620,6 +620,7 @@ class Chef
620
620
  # Reporting endpoint doesn't accept a negative resource duration so set it to 0.
621
621
  # A negative value can occur when a resource changes the system time backwards
622
622
  @elapsed_time = 0 if @elapsed_time < 0
623
+
623
624
  events.resource_completed(self)
624
625
  end
625
626
 
@@ -662,7 +663,6 @@ class Chef
662
663
  all_props = {}
663
664
 
664
665
  self.class.sensitive_properties.map do |p|
665
-
666
666
  all_props[p.name.to_s] = p.sensitive? ? '"*sensitive value suppressed*"' : value_to_text(p.get(self))
667
667
  rescue Chef::Exceptions::ValidationFailed
668
668
  # This space left intentionally blank, the property was probably required or had an invalid default.
@@ -1499,10 +1499,28 @@ class Chef
1499
1499
  # @param partial [String] the code fragment to eval against the class
1500
1500
  #
1501
1501
  def self.use(partial)
1502
- dirname = ::File.dirname(partial)
1503
- basename = ::File.basename(partial, ".rb")
1504
- basename = basename[1..] if basename.start_with?("_")
1505
- class_eval IO.read(::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(caller_locations.first.absolute_path)))
1502
+ if partial =~ /^core::(.*)/
1503
+ partial = $1
1504
+ dirname = ::File.dirname(partial)
1505
+ basename = ::File.basename(partial, ".rb")
1506
+ basename = basename[1..] if basename.start_with?("_")
1507
+ class_eval IO.read(::File.expand_path("resource/#{dirname}/_#{basename}.rb", __dir__))
1508
+ else
1509
+ dirname = ::File.dirname(partial)
1510
+ basename = ::File.basename(partial, ".rb")
1511
+ basename = basename[1..] if basename.start_with?("_")
1512
+
1513
+ # Support recursive `use`
1514
+ callers = caller_locations
1515
+ used_from = if callers.first.label == "use"
1516
+ callers.detect { |caller| caller.label == "class_from_file" }.path
1517
+ else
1518
+ callers.first.path
1519
+ end
1520
+
1521
+ fullpath = ::File.expand_path("#{dirname}/_#{basename}.rb", ::File.dirname(used_from))
1522
+ class_eval IO.read(fullpath)
1523
+ end
1506
1524
  end
1507
1525
 
1508
1526
  # The cookbook in which this Resource was defined (if any).
@@ -79,19 +79,37 @@ class Chef
79
79
  Array(equal_to).map(&:inspect)
80
80
  end
81
81
 
82
+ def self.load_from_resources(resources, complete)
83
+ resources.each_with_object({}) do |r, res|
84
+ pth = r["full_path"]
85
+ # Here we do some magic to extract resources from files where there are multiple resources
86
+ # in a file - to do this, we load the file, and take the delta of which resources
87
+ # exist in object space
88
+ existing_classes = []
89
+ ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each { |klass| existing_classes << klass }
90
+ # Load the set of resources from this file
91
+ Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
92
+ # Finally, process every new class added to the object space by that
93
+ ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each do |klass|
94
+ unless existing_classes.include?(klass)
95
+ # Skip over anything which creates resources that start with exactly this - that happens
96
+ # because if there is no non-classed resource in here, LWRPBase.build_from_file builds a
97
+ # dummy object from it - we don't need that polluting out output!
98
+ next if klass.resource_name.start_with?("Chef__ResourceInspector")
99
+
100
+ res[klass.resource_name] = extract_resource(klass, complete)
101
+ end
102
+ end
103
+ end
104
+ end
105
+
82
106
  def self.extract_cookbook(path, complete)
83
107
  path = File.expand_path(path)
84
108
  dir, name = File.split(path)
85
109
  Chef::Cookbook::FileVendor.fetch_from_disk(path)
86
110
  loader = Chef::CookbookLoader.new(dir)
87
111
  cookbook = loader.load_cookbook(name)
88
- resources = cookbook.files_for(:resources)
89
-
90
- resources.each_with_object({}) do |r, res|
91
- pth = r["full_path"]
92
- cur = Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
93
- res[cur.resource_name] = extract_resource(cur, complete)
94
- end
112
+ load_from_resources(cookbook.files_for(:resources), complete)
95
113
  end
96
114
 
97
115
  # If we're given no resources, dump all of Chef's built ins
@@ -33,6 +33,9 @@ class Chef
33
33
  as_hash["id"] = new_resource.identity.to_s
34
34
  as_hash["after"] = new_resource.state_for_resource_reporter
35
35
  as_hash["before"] = current_resource ? current_resource.state_for_resource_reporter : {}
36
+ # if the "before" hash is too large, we need to truncate it to avoid 413 errors
37
+ # 640K ought be enough for every Windows registry entry
38
+ as_hash["before"] = {} if as_hash["before"].to_json.length > 657920
36
39
  as_hash["duration"] = ( action_record.elapsed_time * 1000 ).to_i.to_s
37
40
  as_hash["delta"] = new_resource.diff if new_resource.respond_to?(:diff)
38
41
  as_hash["delta"] = "" if as_hash["delta"].nil?
@@ -190,6 +193,7 @@ class Chef
190
193
  def prepare_run_data
191
194
  run_data = {}
192
195
  run_data["action"] = "end"
196
+
193
197
  run_data["resources"] = updated_resources.map do |action_record|
194
198
  for_json(action_record)
195
199
  end
@@ -39,6 +39,7 @@ require_relative "resource/chef_sleep"
39
39
  require_relative "resource/chef_vault_secret"
40
40
  require_relative "resource/chocolatey_config"
41
41
  require_relative "resource/chocolatey_feature"
42
+ require_relative "resource/chocolatey_installer"
42
43
  require_relative "resource/chocolatey_package"
43
44
  require_relative "resource/chocolatey_source"
44
45
  require_relative "resource/cron/cron"
@@ -83,6 +84,7 @@ require_relative "resource/link"
83
84
  require_relative "resource/locale"
84
85
  require_relative "resource/log"
85
86
  require_relative "resource/macports_package"
87
+ require_relative "resource/macos_pkg"
86
88
  require_relative "resource/macos_userdefaults"
87
89
  require_relative "resource/mdadm"
88
90
  require_relative "resource/mount"
@@ -124,6 +126,15 @@ require_relative "resource/route"
124
126
  require_relative "resource/ruby"
125
127
  require_relative "resource/ruby_block"
126
128
  require_relative "resource/script"
129
+ require_relative "resource/selinux_boolean"
130
+ require_relative "resource/selinux_fcontext"
131
+ require_relative "resource/selinux_install"
132
+ require_relative "resource/selinux_login"
133
+ require_relative "resource/selinux_module"
134
+ require_relative "resource/selinux_permissive"
135
+ require_relative "resource/selinux_port"
136
+ require_relative "resource/selinux_state"
137
+ require_relative "resource/selinux_user"
127
138
  require_relative "resource/service"
128
139
  require_relative "resource/sudo"
129
140
  require_relative "resource/sysctl"
@@ -413,9 +413,9 @@ class Chef
413
413
  logger.warn(<<~ERROR_MESSAGE)
414
414
  MissingCookbookDependency:
415
415
  Recipe `#{recipe_name}` is not in the run_list, and cookbook '#{cookbook_name}'
416
- is not a dependency of any cookbook in the run_list. To load this recipe,
417
- first add a dependency on cookbook '#{cookbook_name}' in the cookbook you're
418
- including it from in that cookbook's metadata.
416
+ is not a dependency of any cookbook in the run_list. To load this recipe,
417
+ first add a dependency of the cookbook '#{cookbook_name}' into the metadata
418
+ of the cookbook which depends on '#{cookbook_name}'.
419
419
  ERROR_MESSAGE
420
420
  end
421
421
 
@@ -59,7 +59,7 @@ class Chef
59
59
  end
60
60
 
61
61
  def validate!
62
- raise Chef::Exceptions::Secret::ConfigurationInvalid, "You may only specify one (these are mutually exclusive): :config_object_id, :client_id, or :mi_res_id" if [config_object_id, client_id, mi_res_id].count { |x| !x.nil? } > 1
62
+ raise Chef::Exceptions::Secret::ConfigurationInvalid, "You may only specify one (these are mutually exclusive): :object_id, :client_id, or :mi_res_id" if [config_object_id, client_id, mi_res_id].count { |x| !x.nil? } > 1
63
63
  end
64
64
 
65
65
  private
@@ -31,9 +31,19 @@ class Chef
31
31
  "New-Object System.Management.Automation.PSCredential('#{@username}',('#{encrypt(@password)}' | ConvertTo-SecureString))"
32
32
  end
33
33
 
34
+ def to_plaintext
35
+ "#<Chef::Util::Powershell::PSCredential:#{object_id} @username=#{@username.inspect}>"
36
+ end
37
+
38
+ # These leak an encrypted password, however we can't rely on no-one using
39
+ # these assuming that behavior.
34
40
  alias to_s to_psobject
35
41
  alias to_text to_psobject
36
42
 
43
+ # Inspect has no business leaking anything but the username, and to be honest
44
+ # even that one could be dicey
45
+ alias inspect to_plaintext
46
+
37
47
  private
38
48
 
39
49
  def encrypt(str)
data/lib/chef/version.rb CHANGED
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("..", __dir__)
26
- VERSION = Chef::VersionString.new("17.10.163")
26
+ VERSION = Chef::VersionString.new("18.7.10")
27
27
  end
28
28
 
29
29
  #
@@ -26,10 +26,6 @@ class Chef
26
26
  class Handle
27
27
  extend Chef::ReservedNames::Win32::API::Process
28
28
 
29
- # See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx
30
- # The handle value returned by the GetCurrentProcess function is the pseudo handle (HANDLE)-1 (which is 0xFFFFFFFF)
31
- CURRENT_PROCESS_HANDLE = 4294967295
32
-
33
29
  def initialize(handle)
34
30
  @handle = handle
35
31
  ObjectSpace.define_finalizer(self, Handle.close_handle_finalizer(handle))
@@ -38,13 +34,16 @@ class Chef
38
34
  attr_reader :handle
39
35
 
40
36
  def self.close_handle_finalizer(handle)
37
+ proc { close_handle(handle) }
38
+ end
39
+
40
+ def self.close_handle(handle)
41
41
  # According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx, it is not necessary
42
42
  # to close the pseudo handle returned by the GetCurrentProcess function. The docs also say that it doesn't hurt to call
43
43
  # CloseHandle on it. However, doing so from inside of Ruby always seems to produce an invalid handle error.
44
- proc { close_handle(handle) unless handle == CURRENT_PROCESS_HANDLE }
45
- end
44
+ # The recommendation is to use GetCurrentProcess instead of the const (HANDLE)-1, to ensure we're making the correct comparison.
45
+ return if handle == GetCurrentProcess()
46
46
 
47
- def self.close_handle(handle)
48
47
  unless CloseHandle(handle)
49
48
  Chef::ReservedNames::Win32::Error.raise!
50
49
  end
@@ -20,19 +20,24 @@ require_relative "../reserved_names"
20
20
  require_relative "api"
21
21
  require_relative "../mixin/wide_string"
22
22
 
23
- if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
23
+ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
24
24
  require "win32/api"
25
25
  module Win32
26
26
  autoload :Registry, File.expand_path("../monkey_patches/win32/registry", __dir__)
27
27
  end
28
28
  require_relative "api/registry"
29
+
30
+ require "win32/resolv"
31
+ ::Win32::Registry.define_method :export_string do |str, enc = (Encoding.default_internal || "utf-8")|
32
+ str.encode(enc)
33
+ end
29
34
  end
30
35
 
31
36
  class Chef
32
37
  class Win32
33
38
  class Registry
34
39
 
35
- if RUBY_PLATFORM.match?(/mswin|mingw32|windows/)
40
+ if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
36
41
  include Chef::ReservedNames::Win32::API::Registry
37
42
  extend Chef::ReservedNames::Win32::API::Registry
38
43
  end
@@ -293,7 +298,11 @@ class Chef
293
298
  end
294
299
 
295
300
  def machine_architecture
296
- node[:kernel][:machine].to_sym
301
+ if node.nil?
302
+ ::RbConfig::CONFIG["target_cpu"] == "x64" ? :x86_64 : :i386
303
+ else
304
+ node[:kernel][:machine].to_sym
305
+ end
297
306
  end
298
307
 
299
308
  def assert_architecture!
@@ -373,7 +382,6 @@ class Chef
373
382
  hive_name = reg_path.shift
374
383
  key = reg_path.join("\\")
375
384
  end
376
-
377
385
  end
378
386
  end
379
387
  end
@@ -130,6 +130,15 @@ class Chef
130
130
  end
131
131
  end
132
132
 
133
+ def self.clear_account_rights(name)
134
+ return if get_account_right(name) == []
135
+
136
+ with_lsa_policy(name) do |policy_handle, sid|
137
+ result = LsaRemoveAccountRights(policy_handle.read_pointer, sid, true, nil, 1)
138
+ test_and_raise_lsa_nt_status(result)
139
+ end
140
+ end
141
+
133
142
  def self.adjust_token_privileges(token, privileges)
134
143
  token = token.handle if token.respond_to?(:handle)
135
144
  old_privileges_size = FFI::Buffer.new(:long).write_long(privileges.size_with_privileges)
@@ -721,7 +730,13 @@ class Chef
721
730
  unless LogonUserW(username, domain, password, logon_type, logon_provider, token)
722
731
  Chef::ReservedNames::Win32::Error.raise!
723
732
  end
724
- Token.new(Handle.new(token.read_pointer))
733
+
734
+ # originally this was .read_pointer, but that is interpreted as a non-primitive
735
+ # class (FFI::Pointer) and causes an ArgumentError (Invalid Memory Object) when
736
+ # compared to GetCurrentProcess(), which returns a HANDLE (void *). Since a
737
+ # HANDLE is not a pointer to allocated memory that Ruby C extensions can understand,
738
+ # the Invalid Memory Object error is raised.
739
+ Token.new(Handle.new(token.read_ulong))
725
740
  end
726
741
 
727
742
  def self.test_and_raise_lsa_nt_status(result)
@@ -46,4 +46,5 @@
46
46
  4.14.0 |checksum:99a20cc5e7b901f6b493a8ca5e13439b73b19671eaaca68a00216c4f66765edc
47
47
  4.14.1 |checksum:0fa8731445cf4a0c01570ec29aac4b50a0451ce66b1b31ad768f5035e3af7b90,ruby:~> 2.2
48
48
  4.15.0 |checksum:a5ec27d8055ad47444cfb7ce860bad8af2365772a82892f4a8a0d97e8e9e3b34,ruby:~> 2.2
49
- 4.15.1 |checksum:9291a0f2247f50d15068ee6965b67cd7b678b0d273e18adf3c0b2ea4a890125c,ruby:< 3.1&>= 2.1
49
+ 4.15.1 |checksum:9291a0f2247f50d15068ee6965b67cd7b678b0d273e18adf3c0b2ea4a890125c,ruby:>= 2.1
50
+ 4.16.1 |checksum:5caadbf4bbe5ab539cb892a5bcf74ca33a2f2a897cecafdee4a63be79b4819dc,ruby:>= 2.1
@@ -1,27 +1,38 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIEjzCCA3egAwIBAgIQBp4dt3/PHfupevXlyaJANzANBgkqhkiG9w0BAQUFADBh
3
- MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
4
- d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
5
- QTAeFw0xMzAzMDgxMjAwMDBaFw0yMzAzMDgxMjAwMDBaMEgxCzAJBgNVBAYTAlVT
6
- MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxIjAgBgNVBAMTGURpZ2lDZXJ0IFNlY3Vy
7
- ZSBTZXJ2ZXIgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7V+Qh
8
- qdWbYDd+jqFhf4HiGsJ1ZNmRUAvkNkQkbjDSm3on+sJqrmpwCTi5IArIZRBKiKwx
9
- 8tyS8mOhXYBjWYCSIxzm73ZKUDXJ2HE4ue3w5kKu0zgmeTD5IpTG26Y/QXiQ2N5c
10
- fml9+JAVOtChoL76srIZodgr0c6/a91Jq6OS/rWryME+7gEA2KlEuEJziMNh9atK
11
- gygK0tRJ+mqxzd9XLJTl4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qYXL55f00m8AZ4Hf6oYANt/zbuM
33
+ QPhAoSHWwW4V4Pug3XPXM70LlY50y9kPD/57eHryhO2oXQLLx+l6mg8xzL6vKsHT
34
+ E30whFM32vVTpjejLZ9hJBAJURFaUrH2TZyAmoVbCNy50yuHYQ6FooYpbsbnpYPi
35
+ KW/E9bc201rqm/GQOWJ4zOJ8a5Etn3zY+rlPaxjJvxc3pSMfgtwwrm9KGXHsI1Gf
36
+ ULMwUbXclKV2qR8d6ECtUOIRxoQKutN85lmwB05yddu6uQQg0hHeaGFUk7EU90SV
37
+ ib/FA/op9sXfS3CkOnHQISY0JbWxrzC6eHaKeQi6lR1I
38
+ -----END CERTIFICATE-----
@@ -57,7 +57,7 @@ describe Chef::Resource::CookbookFile do
57
57
  create_resource
58
58
  end
59
59
 
60
- it_behaves_like "a file resource"
60
+ it_behaves_like "a file resource", :not_supported_on_windows_11
61
61
 
62
62
  # These examples cover CHEF-3467 where unexpected and incorrect
63
63
  # permissions can result on Windows because CookbookFile's
@@ -263,7 +263,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only, :ruby64_only d
263
263
  dsc_test_resource.cwd(dsc_environment_fail_etc_directory)
264
264
  expect {
265
265
  dsc_test_resource.run_action(:run)
266
- }.to raise_error(Chef::PowerShell::CommandFailed, /#{exception_message_signature}/)
266
+ }.to raise_error(ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed, /#{exception_message_signature}/)
267
267
  end
268
268
  end
269
269
  end
@@ -62,7 +62,7 @@ describe Chef::Resource::Execute do
62
62
  end
63
63
 
64
64
  describe "when parent resource sets :cwd" do
65
- let(:guard) { %{ruby -e 'exit 1 unless File.exists?("./nested.json")'} }
65
+ let(:guard) { %{ruby -e 'exit 1 unless File.exist?("./nested.json")'} }
66
66
 
67
67
  it "guard inherits :cwd from resource and runs" do
68
68
  resource.cwd CHEF_SPEC_DATA