chef 18.5.0 → 18.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -3
  3. data/chef-universal-mingw-ucrt.gemspec +1 -1
  4. data/chef.gemspec +2 -2
  5. data/lib/chef/application/client.rb +0 -12
  6. data/lib/chef/client.rb +1 -10
  7. data/lib/chef/compliance/runner.rb +0 -10
  8. data/lib/chef/cookbook/remote_file_vendor.rb +3 -2
  9. data/lib/chef/cookbook/synchronizer.rb +0 -5
  10. data/lib/chef/exceptions.rb +1 -1
  11. data/lib/chef/file_access_control/unix.rb +9 -9
  12. data/lib/chef/file_content_management/deploy.rb +1 -4
  13. data/lib/chef/mixin/file_class.rb +1 -3
  14. data/lib/chef/mixin/get_source_from_package.rb +1 -1
  15. data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
  16. data/lib/chef/mixin/openssl_helper.rb +1 -12
  17. data/lib/chef/provider/cookbook_file.rb +1 -1
  18. data/lib/chef/provider/cron.rb +1 -1
  19. data/lib/chef/provider/directory.rb +15 -15
  20. data/lib/chef/provider/file.rb +29 -42
  21. data/lib/chef/provider/git.rb +8 -8
  22. data/lib/chef/provider/group/aix.rb +1 -1
  23. data/lib/chef/provider/group/dscl.rb +1 -1
  24. data/lib/chef/provider/group/gpasswd.rb +2 -2
  25. data/lib/chef/provider/group/groupadd.rb +1 -1
  26. data/lib/chef/provider/group/groupmod.rb +2 -2
  27. data/lib/chef/provider/group/pw.rb +2 -2
  28. data/lib/chef/provider/group/solaris.rb +2 -2
  29. data/lib/chef/provider/group/usermod.rb +2 -2
  30. data/lib/chef/provider/group.rb +1 -1
  31. data/lib/chef/provider/http_request.rb +3 -2
  32. data/lib/chef/provider/ifconfig/aix.rb +1 -1
  33. data/lib/chef/provider/ifconfig/debian.rb +3 -3
  34. data/lib/chef/provider/ifconfig/redhat.rb +1 -1
  35. data/lib/chef/provider/ifconfig.rb +1 -1
  36. data/lib/chef/provider/link.rb +10 -10
  37. data/lib/chef/provider/mount/aix.rb +4 -4
  38. data/lib/chef/provider/mount/linux.rb +4 -4
  39. data/lib/chef/provider/mount/mount.rb +11 -11
  40. data/lib/chef/provider/package/apt.rb +11 -2
  41. data/lib/chef/provider/package/bff.rb +3 -3
  42. data/lib/chef/provider/package/chocolatey.rb +2 -2
  43. data/lib/chef/provider/package/dpkg.rb +3 -3
  44. data/lib/chef/provider/package/freebsd/base.rb +1 -1
  45. data/lib/chef/provider/package/habitat.rb +3 -5
  46. data/lib/chef/provider/package/homebrew.rb +6 -9
  47. data/lib/chef/provider/package/ips.rb +2 -2
  48. data/lib/chef/provider/package/openbsd.rb +2 -3
  49. data/lib/chef/provider/package/pacman.rb +4 -4
  50. data/lib/chef/provider/package/paludis.rb +2 -2
  51. data/lib/chef/provider/package/portage.rb +1 -1
  52. data/lib/chef/provider/package/rpm.rb +2 -2
  53. data/lib/chef/provider/package/rubygems.rb +4 -0
  54. data/lib/chef/provider/package/smartos.rb +2 -2
  55. data/lib/chef/provider/package/snap.rb +1 -1
  56. data/lib/chef/provider/package/solaris.rb +4 -4
  57. data/lib/chef/provider/package/zypper.rb +4 -4
  58. data/lib/chef/provider/package.rb +1 -1
  59. data/lib/chef/provider/remote_directory.rb +5 -5
  60. data/lib/chef/provider/remote_file/http.rb +3 -2
  61. data/lib/chef/provider/remote_file.rb +1 -1
  62. data/lib/chef/provider/route.rb +9 -9
  63. data/lib/chef/provider/service/aix.rb +1 -1
  64. data/lib/chef/provider/service/aixinit.rb +4 -4
  65. data/lib/chef/provider/service/arch.rb +6 -6
  66. data/lib/chef/provider/service/debian.rb +5 -5
  67. data/lib/chef/provider/service/freebsd.rb +7 -7
  68. data/lib/chef/provider/service/gentoo.rb +5 -5
  69. data/lib/chef/provider/service/init.rb +2 -2
  70. data/lib/chef/provider/service/insserv.rb +2 -2
  71. data/lib/chef/provider/service/invokercd.rb +1 -1
  72. data/lib/chef/provider/service/openbsd.rb +7 -7
  73. data/lib/chef/provider/service/redhat.rb +3 -3
  74. data/lib/chef/provider/service/solaris.rb +2 -2
  75. data/lib/chef/provider/service/systemd.rb +2 -2
  76. data/lib/chef/provider/service/upstart.rb +2 -2
  77. data/lib/chef/provider/subversion.rb +8 -8
  78. data/lib/chef/provider/systemd_unit.rb +3 -3
  79. data/lib/chef/provider/template.rb +1 -1
  80. data/lib/chef/provider/user/aix.rb +3 -3
  81. data/lib/chef/provider/user/linux.rb +2 -7
  82. data/lib/chef/provider/user/pw.rb +3 -3
  83. data/lib/chef/provider/user/solaris.rb +7 -7
  84. data/lib/chef/provider/user/windows.rb +5 -0
  85. data/lib/chef/provider/user.rb +8 -7
  86. data/lib/chef/provider/yum_repository.rb +3 -1
  87. data/lib/chef/provider/zypper_repository.rb +1 -1
  88. data/lib/chef/providers.rb +0 -1
  89. data/lib/chef/resource/alternatives.rb +2 -2
  90. data/lib/chef/resource/apt_preference.rb +1 -1
  91. data/lib/chef/resource/apt_repository.rb +9 -7
  92. data/lib/chef/resource/apt_update.rb +3 -3
  93. data/lib/chef/resource/bff_package.rb +1 -1
  94. data/lib/chef/resource/chef_client_config.rb +3 -2
  95. data/lib/chef/resource/chef_sleep.rb +1 -1
  96. data/lib/chef/resource/cookbook_file.rb +1 -1
  97. data/lib/chef/resource/cron/cron.rb +1 -1
  98. data/lib/chef/resource/cron/cron_d.rb +1 -1
  99. data/lib/chef/resource/cron_access.rb +1 -1
  100. data/lib/chef/resource/directory.rb +1 -1
  101. data/lib/chef/resource/dpkg_package.rb +1 -1
  102. data/lib/chef/resource/file/verification/json.rb +1 -1
  103. data/lib/chef/resource/file/verification/systemd_unit.rb +1 -1
  104. data/lib/chef/resource/file/verification/yaml.rb +1 -1
  105. data/lib/chef/resource/file.rb +1 -1
  106. data/lib/chef/resource/freebsd_package.rb +2 -2
  107. data/lib/chef/resource/group.rb +1 -1
  108. data/lib/chef/resource/habitat/habitat_package.rb +1 -1
  109. data/lib/chef/resource/habitat/habitat_sup.rb +9 -9
  110. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +2 -2
  111. data/lib/chef/resource/habitat_install.rb +3 -3
  112. data/lib/chef/resource/homebrew_cask.rb +19 -30
  113. data/lib/chef/resource/homebrew_tap.rb +32 -17
  114. data/lib/chef/resource/homebrew_update.rb +4 -4
  115. data/lib/chef/resource/hostname.rb +10 -11
  116. data/lib/chef/resource/http_request.rb +1 -1
  117. data/lib/chef/resource/ifconfig.rb +1 -1
  118. data/lib/chef/resource/inspec_input.rb +1 -3
  119. data/lib/chef/resource/inspec_waiver.rb +1 -1
  120. data/lib/chef/resource/inspec_waiver_file_entry.rb +1 -1
  121. data/lib/chef/resource/ips_package.rb +2 -2
  122. data/lib/chef/resource/kernel_module.rb +2 -2
  123. data/lib/chef/resource/link.rb +1 -1
  124. data/lib/chef/resource/locale.rb +2 -2
  125. data/lib/chef/resource/mount.rb +1 -1
  126. data/lib/chef/resource/notify_group.rb +1 -1
  127. data/lib/chef/resource/ohai.rb +1 -1
  128. data/lib/chef/resource/ohai_hint.rb +1 -1
  129. data/lib/chef/resource/openbsd_package.rb +2 -2
  130. data/lib/chef/resource/package.rb +1 -1
  131. data/lib/chef/resource/pacman_package.rb +1 -1
  132. data/lib/chef/resource/paludis_package.rb +1 -1
  133. data/lib/chef/resource/portage_package.rb +1 -1
  134. data/lib/chef/resource/reboot.rb +1 -1
  135. data/lib/chef/resource/remote_directory.rb +1 -1
  136. data/lib/chef/resource/remote_file.rb +1 -1
  137. data/lib/chef/resource/rhsm_errata.rb +1 -1
  138. data/lib/chef/resource/rhsm_errata_level.rb +1 -1
  139. data/lib/chef/resource/rhsm_register.rb +1 -1
  140. data/lib/chef/resource/rhsm_repo.rb +4 -3
  141. data/lib/chef/resource/rhsm_subscription.rb +9 -8
  142. data/lib/chef/resource/route.rb +1 -1
  143. data/lib/chef/resource/rpm_package.rb +1 -1
  144. data/lib/chef/resource/scm/git.rb +1 -1
  145. data/lib/chef/resource/scm/subversion.rb +1 -1
  146. data/lib/chef/resource/selinux/common_helpers.rb +1 -1
  147. data/lib/chef/resource/selinux_boolean.rb +1 -1
  148. data/lib/chef/resource/selinux_fcontext.rb +3 -3
  149. data/lib/chef/resource/selinux_install.rb +1 -1
  150. data/lib/chef/resource/selinux_login.rb +1 -1
  151. data/lib/chef/resource/selinux_module.rb +5 -5
  152. data/lib/chef/resource/selinux_permissive.rb +2 -2
  153. data/lib/chef/resource/selinux_port.rb +2 -2
  154. data/lib/chef/resource/selinux_state.rb +2 -2
  155. data/lib/chef/resource/selinux_user.rb +1 -1
  156. data/lib/chef/resource/smartos_package.rb +2 -2
  157. data/lib/chef/resource/snap_package.rb +1 -1
  158. data/lib/chef/resource/solaris_package.rb +1 -1
  159. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  160. data/lib/chef/resource/sudo.rb +5 -5
  161. data/lib/chef/resource/support/client.erb +3 -2
  162. data/lib/chef/resource/swap_file.rb +6 -6
  163. data/lib/chef/resource/sysctl.rb +5 -5
  164. data/lib/chef/resource/systemd_unit.rb +1 -1
  165. data/lib/chef/resource/template.rb +1 -1
  166. data/lib/chef/resource/timezone.rb +5 -5
  167. data/lib/chef/resource/user/aix_user.rb +2 -2
  168. data/lib/chef/resource/user/linux_user.rb +2 -2
  169. data/lib/chef/resource/user/pw_user.rb +2 -2
  170. data/lib/chef/resource/user/solaris_user.rb +2 -2
  171. data/lib/chef/resource/user_ulimit.rb +1 -1
  172. data/lib/chef/resource/yum_repository.rb +1 -1
  173. data/lib/chef/resource/zypper_package.rb +2 -2
  174. data/lib/chef/resource/zypper_repository.rb +2 -2
  175. data/lib/chef/resource_inspector.rb +25 -7
  176. data/lib/chef/run_lock.rb +0 -3
  177. data/lib/chef/scan_access_control.rb +6 -6
  178. data/lib/chef/util/backup.rb +1 -1
  179. data/lib/chef/util/diff.rb +1 -14
  180. data/lib/chef/util/file_edit.rb +4 -4
  181. data/lib/chef/version.rb +1 -1
  182. data/lib/chef/win32/registry.rb +5 -0
  183. data/lib/chef/win32/security.rb +9 -0
  184. data/lib/chef.rb +0 -2
  185. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  186. data/spec/integration/client/open_ssl_spec.rb +1 -1
  187. data/spec/spec_helper.rb +1 -0
  188. data/spec/support/chef_helpers.rb +2 -2
  189. data/spec/support/platform_helpers.rb +8 -0
  190. data/spec/support/shared/functional/file_resource.rb +3 -3
  191. data/spec/unit/mixin/homebrew_spec.rb +118 -0
  192. data/spec/unit/provider/apt_repository_spec.rb +1 -1
  193. data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
  194. data/spec/unit/provider/package/homebrew_spec.rb +4 -1
  195. data/spec/unit/provider/route_spec.rb +4 -6
  196. data/spec/unit/provider/user/windows_spec.rb +1 -0
  197. data/spec/unit/resource/rhsm_repo_spec.rb +0 -1
  198. data/spec/unit/resource/rhsm_subscription_spec.rb +0 -2
  199. data/spec/unit/resource_inspector_spec.rb +36 -0
  200. metadata +20 -28
  201. data/lib/chef/file_content_management/deploy/target_io.rb +0 -29
  202. data/lib/chef/provider/.gitkeep +0 -0
  203. data/lib/chef/provider/package/snap_tm.rb +0 -79
  204. data/lib/chef/resource/.gitkeep +0 -0
  205. data/lib/chef/target_io/dir.rb +0 -12
  206. data/lib/chef/target_io/etc.rb +0 -16
  207. data/lib/chef/target_io/file.rb +0 -12
  208. data/lib/chef/target_io/fileutils.rb +0 -12
  209. data/lib/chef/target_io/http.rb +0 -22
  210. data/lib/chef/target_io/io.rb +0 -12
  211. data/lib/chef/target_io/shadow.rb +0 -44
  212. data/lib/chef/target_io/train/dir.rb +0 -69
  213. data/lib/chef/target_io/train/etc.rb +0 -112
  214. data/lib/chef/target_io/train/file.rb +0 -219
  215. data/lib/chef/target_io/train/fileutils.rb +0 -220
  216. data/lib/chef/target_io/train/http.rb +0 -117
  217. data/lib/chef/target_io/train/io.rb +0 -13
  218. data/lib/chef/target_io/train/shadow.rb +0 -52
  219. data/lib/chef/target_io/train_compat.rb +0 -7
  220. data/lib/chef/target_io.rb +0 -9
  221. data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6aeb4e21d11cdf70486e7d5c78992d1248331091782075950ed11103f16313eb
4
- data.tar.gz: 0d0732e253f1ff220fa4460a98befd22879d206f09e3053527b0996c0a84c268
3
+ metadata.gz: 9758afdcd61880d10d2e6fcbd0097a3dc94ead3ce67004ba317ed1754cf529d2
4
+ data.tar.gz: 2ea4ff22776735a4ec71531e3c188769328e3dab07f1930ab4f59c6c2032a9b4
5
5
  SHA512:
6
- metadata.gz: '067286ca73d5381ce8ffca9e20694d03b8b5032769ebec6805fdf51c03aadf5d7f2c55c6b1b27d32b81085b378b4e917410fa6dffb9532cae2130f3c6da8160f'
7
- data.tar.gz: 1e35e9df95757159af9ab8a22b1d59cbbf8c0e916fdc8ec032c8383921e7de9a9a05d5f6aaba138b3d53af9e4e8359c39bba0f64fb42e90201c704e8ce3bcfe4
6
+ metadata.gz: 6f54220fa4591d43a562055250981453252a30db5bed94473ba0350b4d147ae0eb517da7ab371ef5963b8c7675b06206a5366585a86234ef0ede60a2d92ebf28
7
+ data.tar.gz: d096c1a73764313a572382cb45963efac685f4a33655225b447b8f58f9dbcfb4abf732da9c7bd2c855bf526a28d195a2a3af49e36029b9f7941bbe4b2ad6682b
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "chef", path: "."
4
4
 
5
- gem "ohai", git: "https://github.com/chef/ohai.git", branch: "main"
5
+ gem "ohai", git: "https://github.com/chef/ohai.git", branch: "18-stable"
6
6
 
7
7
  # Nwed to file a bug with rest-client. In the meantime, we can use this until they accept the update.
8
8
  gem "rest-client", git: "https://github.com/chef/rest-client", branch: "jfm/ucrt_update1"
@@ -10,8 +10,13 @@ gem "rest-client", git: "https://github.com/chef/rest-client", branch: "jfm/ucrt
10
10
  gem "ffi", ">= 1.15.5"
11
11
  gem "chef-utils", path: File.expand_path("chef-utils", __dir__) if File.exist?(File.expand_path("chef-utils", __dir__))
12
12
  gem "chef-config", path: File.expand_path("chef-config", __dir__) if File.exist?(File.expand_path("chef-config", __dir__))
13
+
13
14
  # required for FIPS or bundler will pick up default openssl
14
- gem "openssl", "= 3.2.0" unless Gem.platforms.any? { |platform| !platform.is_a?(String) && platform.os == "darwin" }
15
+ install_if -> { RUBY_PLATFORM !~ /darwin/ } do
16
+ gem "openssl", "= 3.2.0"
17
+ end
18
+
19
+ gem "rdoc", "~> 6.4.1" # 6.4.1.1 required for CVE-2024-27281, allow patch upgrades
15
20
 
16
21
  if File.exist?(File.expand_path("chef-bin", __dir__))
17
22
  # bundling in a git checkout
@@ -51,7 +56,7 @@ group(:knife_windows_deps) do
51
56
  end
52
57
 
53
58
  group(:development, :test) do
54
- gem "rake"
59
+ gem "rake", ">= 12.3.3"
55
60
  gem "rspec"
56
61
  gem "webmock"
57
62
  gem "crack", "< 0.4.6" # due to https://github.com/jnunemaker/crack/pull/75
@@ -1,6 +1,6 @@
1
1
  gemspec = instance_eval(File.read(File.expand_path("chef.gemspec", __dir__)))
2
2
 
3
- gemspec.platform = Gem::Platform.new(%w{x64-mingw-ucrt})
3
+ gemspec.platform = Gem::Platform.new(%w{universal mingw-ucrt})
4
4
 
5
5
  gemspec.add_dependency "win32-api", "~> 1.10.0"
6
6
  gemspec.add_dependency "win32-event", "~> 0.6.1"
data/chef.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
 
31
31
  s.add_dependency "chef-config", "= #{Chef::VERSION}"
32
32
  s.add_dependency "chef-utils", "= #{Chef::VERSION}"
33
- s.add_dependency "train-core", "~> 3.10" # 3.2.28 fixes sudo prompts. See https://github.com/chef/chef/pull/9635
33
+ s.add_dependency "train-core", "~> 3.10", "<= 3.12.7"
34
34
  s.add_dependency "train-winrm", ">= 0.2.5"
35
35
  s.add_dependency "train-rest", ">= 0.4.1" # target mode with rest APIs
36
36
 
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  s.add_dependency "ohai", "~> 18.0"
44
44
  s.add_dependency "inspec-core", ">= 5", "< 6"
45
45
 
46
- s.add_dependency "ffi", ">= 1.15.5"
46
+ s.add_dependency "ffi", ">= 1.15.5", "<= 1.16.3"
47
47
  s.add_dependency "ffi-yajl", "~> 2.2"
48
48
  s.add_dependency "net-sftp", ">= 2.1.2", "< 5.0" # remote_file resource
49
49
  s.add_dependency "net-ftp" # remote_file resource
@@ -40,10 +40,6 @@ class Chef::Application::Client < Chef::Application::Base
40
40
  long: "--config CONFIG",
41
41
  description: "The configuration file to use."
42
42
 
43
- option :credentials,
44
- long: "--credentials CREDENTIALS",
45
- description: "Credentials file to use. Default: ~/.chef/credentials"
46
-
47
43
  unless ChefUtils.windows?
48
44
  option :daemonize,
49
45
  short: "-d [WAIT]",
@@ -129,14 +125,6 @@ class Chef::Application::Client < Chef::Application::Base
129
125
  Chef::Config.node_name = Chef::Config.target_mode.host unless Chef::Config.node_name
130
126
  end
131
127
 
132
- if config[:credentials]
133
- unless File.exist?(config[:credentials])
134
- Chef::Application.fatal!("credentials file #{config[:credentials]} not found")
135
- end
136
-
137
- Chef::Config.credentials = config[:credentials]
138
- end
139
-
140
128
  if Chef::Config[:daemonize]
141
129
  Chef::Config[:interval] ||= 1800
142
130
  end
data/lib/chef/client.rb CHANGED
@@ -292,7 +292,6 @@ class Chef
292
292
  Chef.provider_handler_map.lock!
293
293
 
294
294
  setup_run_context
295
- setup_targetmode if Chef::Config.target_mode?
296
295
 
297
296
  load_required_recipe(@rest, run_context) unless Chef::Config[:solo_legacy_mode]
298
297
 
@@ -572,15 +571,6 @@ class Chef
572
571
  end
573
572
  end
574
573
 
575
- #
576
- # Setup conditions for Target Mode.
577
- #
578
- # @api private
579
- #
580
- def setup_targetmode
581
- TargetIO::FileUtils.mkdir_p(Chef::Config[:file_cache_path])
582
- end
583
-
584
574
  #
585
575
  # Run ohai plugins. Runs all ohai plugins unless minimal_ohai is specified.
586
576
  #
@@ -1100,3 +1090,4 @@ end
1100
1090
  require_relative "cookbook_loader"
1101
1091
  require_relative "cookbook_version"
1102
1092
  require_relative "cookbook/synchronizer"
1093
+
@@ -208,16 +208,6 @@ class Chef
208
208
  logger.debug "Options are set to: #{opts}"
209
209
  runner = ::Inspec::Runner.new(opts)
210
210
 
211
- # Switch from local to remote backend for Target Mode
212
- if ChefConfig::Config.target_mode?
213
- logger.info "Configure InSpec backend to use established connection"
214
-
215
- connection = Chef.run_context.transport_connection
216
- backend = Inspec::Backend.new(connection)
217
-
218
- runner.set_backend(backend)
219
- end
220
-
221
211
  if profiles.empty?
222
212
  failed_report("No #{Inspec::Dist::PRODUCT_NAME} profiles are defined.")
223
213
  return
@@ -43,9 +43,10 @@ class Chef
43
43
  raise "get_filename: Cannot determine segment/filename for incoming filename #{filename}"
44
44
  end
45
45
 
46
- raise "No such segment #{segment} in cookbook #{@cookbook_name}" unless @manifest.files_for(segment)
46
+ files_for_segment = @manifest.files_for(segment)
47
+ raise "No such segment #{segment} in cookbook #{@cookbook_name}" unless files_for_segment
47
48
 
48
- found_manifest_record = @manifest.files_for(segment).find { |manifest_record| manifest_record[:path] == filename }
49
+ found_manifest_record = files_for_segment.find { |manifest_record| manifest_record[:path] == filename }
49
50
  raise "No such file #{filename} in #{@cookbook_name}" unless found_manifest_record
50
51
 
51
52
  cache_filename = File.join("cookbooks", @cookbook_name, found_manifest_record["path"])
@@ -61,11 +61,6 @@ class Chef
61
61
 
62
62
  def cleanup_file_cache
63
63
  unless Chef::Config[:solo_legacy_mode] || skip_removal
64
- if Chef::Config.target_mode?
65
- TargetIO::FileUtils.rm_rf(Chef::Config[:file_cache_path])
66
- return
67
- end
68
-
69
64
  # Delete each file in the cache that we didn't encounter in the
70
65
  # manifest.
71
66
  cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_filename|
@@ -170,7 +170,7 @@ class Chef
170
170
  class PowershellCmdletException < RuntimeError; end
171
171
  class LCMParser < RuntimeError; end
172
172
 
173
- class CannotDetermineHomebrewOwner < Package; end
173
+ class CannotDetermineHomebrewPath < Package; end
174
174
  class CannotDetermineWindowsInstallerType < Package; end
175
175
  class NoWindowsPackageSource < Package; end
176
176
 
@@ -29,7 +29,7 @@ class Chef
29
29
  module ClassMethods
30
30
  # We want to mix these in as class methods
31
31
  def writable?(path)
32
- ::TargetIO::File.writable?(path)
32
+ ::File.writable?(path)
33
33
  end
34
34
  end
35
35
 
@@ -120,7 +120,7 @@ class Chef
120
120
  return nil if resource.nil? || resource.group.nil?
121
121
 
122
122
  if resource.group.is_a?(String)
123
- diminished_radix_complement( TargetIO::Etc.getgrnam(resource.group).gid )
123
+ diminished_radix_complement( Etc.getgrnam(resource.group).gid )
124
124
  elsif resource.group.is_a?(Integer)
125
125
  resource.group
126
126
  else
@@ -222,9 +222,9 @@ class Chef
222
222
 
223
223
  def stat
224
224
  if manage_symlink_attrs?
225
- @stat ||= TargetIO::File.lstat(file)
225
+ @stat ||= File.lstat(file)
226
226
  else
227
- @stat ||= TargetIO::File.stat(file)
227
+ @stat ||= File.stat(file)
228
228
  end
229
229
  end
230
230
 
@@ -237,20 +237,20 @@ class Chef
237
237
  def chmod(mode, file)
238
238
  if manage_symlink_attrs?
239
239
  begin
240
- TargetIO::File.lchmod(mode, file)
240
+ File.lchmod(mode, file)
241
241
  rescue NotImplementedError
242
242
  Chef::Log.warn("#{file} mode not changed: File.lchmod is unimplemented on this OS and Ruby version")
243
243
  end
244
244
  else
245
- TargetIO::File.chmod(mode, file)
245
+ File.chmod(mode, file)
246
246
  end
247
247
  end
248
248
 
249
249
  def chown(uid, gid, file)
250
250
  if manage_symlink_attrs?
251
- TargetIO::File.lchown(uid, gid, file)
251
+ File.lchown(uid, gid, file)
252
252
  else
253
- TargetIO::File.chown(uid, gid, file)
253
+ File.chown(uid, gid, file)
254
254
  end
255
255
  end
256
256
 
@@ -269,7 +269,7 @@ class Chef
269
269
  return nil if resource.nil? || resource.owner.nil?
270
270
 
271
271
  if resource.owner.is_a?(String)
272
- diminished_radix_complement( TargetIO::Etc.getpwnam(resource.owner).uid )
272
+ diminished_radix_complement( Etc.getpwnam(resource.owner).uid )
273
273
  elsif resource.owner.is_a?(Integer)
274
274
  resource.owner
275
275
  else
@@ -18,7 +18,6 @@
18
18
 
19
19
  require_relative "deploy/cp"
20
20
  require_relative "deploy/mv_unix"
21
- require_relative "deploy/target_io"
22
21
  if ChefUtils.windows?
23
22
  require_relative "deploy/mv_windows"
24
23
  end
@@ -27,9 +26,7 @@ class Chef
27
26
  class FileContentManagement
28
27
  class Deploy
29
28
  def self.strategy(atomic_update)
30
- if ChefConfig::Config.target_mode?
31
- TargetIO::Deploy.new
32
- elsif atomic_update
29
+ if atomic_update
33
30
  ChefUtils.windows? ? MvWindows.new : MvUnix.new
34
31
  else
35
32
  Cp.new
@@ -23,9 +23,7 @@ class Chef
23
23
  module FileClass
24
24
 
25
25
  def file_class
26
- @host_os_file ||= if ChefConfig::Config.target_mode?
27
- ::TargetIO::File
28
- elsif ChefUtils.windows?
26
+ @host_os_file ||= if ChefUtils.windows?
29
27
  require_relative "../win32/file"
30
28
  Chef::ReservedNames::Win32::File
31
29
  else
@@ -38,7 +38,7 @@ class Chef
38
38
 
39
39
  # if we're passed something that looks like a filesystem path, with no source, use it
40
40
  # - require at least one '/' in the path to avoid gem_package "foo" breaking if a file named 'foo' exists in the cwd
41
- if new_resource.source.nil? && new_resource.package_name.include?(::File::SEPARATOR) && ::TargetIO::File.exist?(new_resource.package_name)
41
+ if new_resource.source.nil? && new_resource.package_name.include?(::File::SEPARATOR) && ::File.exist?(new_resource.package_name)
42
42
  Chef::Log.trace("No package source specified, but #{new_resource.package_name} exists on the filesystem, copying to package source")
43
43
  new_resource.source(new_resource.package_name)
44
44
  end
@@ -27,7 +27,7 @@ require "etc" unless defined?(Etc)
27
27
 
28
28
  class Chef
29
29
  module Mixin
30
- module HomebrewUser
30
+ module Homebrew
31
31
  include Chef::Mixin::ShellOut
32
32
 
33
33
  ##
@@ -57,15 +57,19 @@ class Chef
57
57
  @homebrew_owner_username
58
58
  end
59
59
 
60
+ # Use homebrew_bin_path to return the path to the brew binary
61
+ # @param [String, Array(String)] brew_bin_path
62
+ # @return [String] path to the brew binary
60
63
  def homebrew_bin_path(brew_bin_path = nil)
61
64
  if brew_bin_path && ::File.exist?(brew_bin_path)
62
65
  brew_bin_path
63
66
  else
64
- [which("brew"), "/opt/homebrew/bin/brew", "/usr/local/bin/brew", "/home/linuxbrew/.linuxbrew/bin/brew"].uniq.select do |x|
65
- next if x == false
67
+ brew_path = which("brew", prepend_path: %w{/opt/homebrew/bin /usr/local/bin /home/linuxbrew/.linuxbrew/bin})
68
+ unless brew_path
69
+ raise Chef::Exceptions::CannotDetermineHomebrewPath, 'Couldn\'t find the "brew" executable anywhere on the path.'
70
+ end
66
71
 
67
- ::File.exist?(x) && ::File.executable?(x)
68
- end.first || nil
72
+ brew_path
69
73
  end
70
74
  end
71
75
 
@@ -73,18 +77,11 @@ class Chef
73
77
 
74
78
  def calculate_owner
75
79
  brew_path = homebrew_bin_path
76
- if brew_path
77
- # By default, this follows symlinks which is what we want
78
- owner = ::File.stat(brew_path).uid
79
- else
80
- raise Chef::Exceptions::CannotDetermineHomebrewOwner,
81
- 'Couldn\'t find the "brew" executable anywhere on the path.'
82
- end
83
-
84
- Chef::Log.debug "Found Homebrew owner #{Etc.getpwuid(owner).name}; executing `brew` commands as them"
85
- owner
80
+ # By default, this follows symlinks which is what we want
81
+ owner_uid = ::File.stat(brew_path).uid
82
+ Chef::Log.debug "Found Homebrew owner #{Etc.getpwuid(owner_uid).name}; executing `brew` commands as them"
83
+ owner_uid
86
84
  end
87
-
88
85
  end
89
86
  end
90
87
  end
@@ -170,18 +170,7 @@ class Chef
170
170
  key_content = ::File.exist?(priv_key) ? File.read(priv_key) : priv_key
171
171
  key = ::OpenSSL::PKey::EC.new key_content, priv_key_password
172
172
 
173
- # Get curve type (prime256v1...)
174
- group = ::OpenSSL::PKey::EC::Group.new(key.group.curve_name)
175
- # Get Generator point & public point (priv * generator)
176
- generator = group.generator
177
- pub_point = generator.mul(key.private_key)
178
- key.public_key = pub_point
179
-
180
- # Public Key in pem
181
- public_key = ::OpenSSL::PKey::EC.new
182
- public_key.group = group
183
- public_key.public_key = pub_point
184
- public_key.to_pem
173
+ key.public_to_pem
185
174
  end
186
175
 
187
176
  # generate a pem file given a cipher, key, an optional key_password
@@ -22,7 +22,7 @@ class Chef
22
22
  class Provider
23
23
  class CookbookFile < Chef::Provider::File
24
24
 
25
- provides :cookbook_file, target_mode: true
25
+ provides :cookbook_file
26
26
 
27
27
  def initialize(new_resource, run_context)
28
28
  @content_class = Chef::Provider::CookbookFile::Content
@@ -22,7 +22,7 @@ class Chef
22
22
  class Provider
23
23
  class Cron < Chef::Provider
24
24
 
25
- provides :cron, os: ["!aix", "!solaris2"], target_mode: true
25
+ provides :cron, os: ["!aix", "!solaris2"]
26
26
 
27
27
  SPECIAL_TIME_VALUES = %i{reboot yearly annually monthly weekly daily midnight hourly}.freeze
28
28
  CRON_ATTRIBUTES = %i{minute hour day month weekday time command mailto path shell home environment}.freeze
@@ -27,12 +27,12 @@ class Chef
27
27
  class Provider
28
28
  class Directory < Chef::Provider::File
29
29
 
30
- provides :directory, target_mode: true
30
+ provides :directory
31
31
 
32
32
  def load_current_resource
33
33
  @current_resource = Chef::Resource::Directory.new(new_resource.name)
34
34
  current_resource.path(new_resource.path)
35
- if ::TargetIO::File.exist?(current_resource.path) && @action != :create_if_missing
35
+ if ::File.exist?(current_resource.path) && @action != :create_if_missing
36
36
  load_resource_attributes_from_file(current_resource)
37
37
  end
38
38
  current_resource
@@ -50,15 +50,15 @@ class Chef
50
50
  if new_resource.recursive
51
51
  does_parent_exist = lambda do |base_dir|
52
52
  base_dir = ::File.dirname(base_dir)
53
- if ::TargetIO::File.exist?(base_dir)
54
- ::TargetIO::File.directory?(base_dir)
53
+ if ::File.exist?(base_dir)
54
+ ::File.directory?(base_dir)
55
55
  else
56
56
  does_parent_exist.call(base_dir)
57
57
  end
58
58
  end
59
59
  does_parent_exist.call(new_resource.path)
60
60
  else
61
- ::TargetIO::File.directory?(parent_directory)
61
+ ::File.directory?(parent_directory)
62
62
  end
63
63
  end
64
64
  a.failure_message(Chef::Exceptions::EnclosingDirectoryDoesNotExist, "Parent directory #{parent_directory} does not exist, cannot create #{new_resource.path}")
@@ -73,7 +73,7 @@ class Chef
73
73
  # make sure we have write permissions to that directory
74
74
  is_parent_writable = lambda do |base_dir|
75
75
  base_dir = ::File.dirname(base_dir)
76
- if ::TargetIO::File.exist?(base_dir)
76
+ if ::File.exist?(base_dir)
77
77
  if Chef::FileAccessControl.writable?(base_dir)
78
78
  true
79
79
  elsif Chef::Util::PathHelper.is_sip_path?(base_dir, node)
@@ -89,7 +89,7 @@ class Chef
89
89
  else
90
90
  # in why run mode & parent directory does not exist no permissions check is required
91
91
  # If not in why run, permissions must be valid and we rely on prior assertion that dir exists
92
- if !whyrun_mode? || ::TargetIO::File.exist?(parent_directory)
92
+ if !whyrun_mode? || ::File.exist?(parent_directory)
93
93
  if Chef::FileAccessControl.writable?(parent_directory)
94
94
  true
95
95
  elsif Chef::Util::PathHelper.is_sip_path?(parent_directory, node)
@@ -108,8 +108,8 @@ class Chef
108
108
 
109
109
  requirements.assert(:delete) do |a|
110
110
  a.assertion do
111
- if ::TargetIO::File.exist?(new_resource.path)
112
- ::TargetIO::File.directory?(new_resource.path) && Chef::FileAccessControl.writable?(new_resource.path)
111
+ if ::File.exist?(new_resource.path)
112
+ ::File.directory?(new_resource.path) && Chef::FileAccessControl.writable?(new_resource.path)
113
113
  else
114
114
  true
115
115
  end
@@ -122,12 +122,12 @@ class Chef
122
122
  end
123
123
 
124
124
  action :create, description: "Create a directory. If a directory already exists (but does not match), update that directory to match." do
125
- unless ::TargetIO::File.exist?(new_resource.path)
125
+ unless ::File.exist?(new_resource.path)
126
126
  converge_by("create new directory #{new_resource.path}") do
127
127
  if new_resource.recursive == true
128
- ::TargetIO::FileUtils.mkdir_p(new_resource.path)
128
+ ::FileUtils.mkdir_p(new_resource.path)
129
129
  else
130
- ::TargetIO::Dir.mkdir(new_resource.path)
130
+ ::Dir.mkdir(new_resource.path)
131
131
  end
132
132
  logger.info("#{new_resource} created directory #{new_resource.path}")
133
133
  end
@@ -138,15 +138,15 @@ class Chef
138
138
  end
139
139
 
140
140
  action :delete, description: "Delete a directory." do
141
- if ::TargetIO::File.exist?(new_resource.path)
141
+ if ::File.exist?(new_resource.path)
142
142
  converge_by("delete existing directory #{new_resource.path}") do
143
143
  if new_resource.recursive == true
144
144
  # we don't use rm_rf here because it masks all errors, including
145
145
  # IO errors or permission errors that would prevent the deletion
146
- ::TargetIO::FileUtils.rm_r(new_resource.path)
146
+ FileUtils.rm_r(new_resource.path)
147
147
  logger.info("#{new_resource} deleted #{new_resource.path} recursively")
148
148
  else
149
- ::TargetIO::Dir.delete(new_resource.path)
149
+ ::Dir.delete(new_resource.path)
150
150
  logger.info("#{new_resource} deleted #{new_resource.path}")
151
151
  end
152
152
  end