chef 15.13.8-universal-mingw32 → 15.16.7-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -6
  3. data/README.md +3 -3
  4. data/Rakefile +11 -17
  5. data/chef-universal-mingw32.gemspec +2 -2
  6. data/chef.gemspec +22 -4
  7. data/lib/chef/api_client/registration.rb +2 -2
  8. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  9. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  10. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  11. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  13. data/lib/chef/environment.rb +2 -2
  14. data/lib/chef/http.rb +2 -1
  15. data/lib/chef/knife/bootstrap.rb +2 -2
  16. data/lib/chef/knife/cookbook_download.rb +1 -1
  17. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  18. data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
  19. data/lib/chef/knife/exec.rb +2 -2
  20. data/lib/chef/knife/ssh.rb +16 -1
  21. data/lib/chef/provider/package/dnf/dnf_helper.py +5 -0
  22. data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
  23. data/lib/chef/provider/package/yum/yum_helper.py +4 -0
  24. data/lib/chef/provider/service/arch.rb +2 -2
  25. data/lib/chef/provider/service/debian.rb +1 -1
  26. data/lib/chef/provider/service/gentoo.rb +2 -2
  27. data/lib/chef/provider/service/macosx.rb +2 -2
  28. data/lib/chef/provider/service/openbsd.rb +1 -1
  29. data/lib/chef/provider/service/redhat.rb +2 -2
  30. data/lib/chef/provider/service/upstart.rb +1 -1
  31. data/lib/chef/resource/cron_d.rb +1 -0
  32. data/lib/chef/resource/homebrew_cask.rb +3 -3
  33. data/lib/chef/resource/hostname.rb +18 -18
  34. data/lib/chef/resource/locale.rb +1 -1
  35. data/lib/chef/resource/sudo.rb +1 -1
  36. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  37. data/lib/chef/resource/windows_font.rb +2 -1
  38. data/lib/chef/role.rb +2 -2
  39. data/lib/chef/shell.rb +32 -1
  40. data/lib/chef/util/diff.rb +1 -1
  41. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  42. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  43. data/lib/chef/version.rb +1 -1
  44. data/lib/chef/version_string.rb +1 -1
  45. data/lib/chef/win32/file.rb +2 -2
  46. data/spec/functional/resource/aixinit_service_spec.rb +7 -7
  47. data/spec/functional/resource/bff_spec.rb +2 -2
  48. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  49. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  50. data/spec/functional/resource/insserv_spec.rb +4 -4
  51. data/spec/functional/resource/link_spec.rb +17 -17
  52. data/spec/functional/resource/rpm_spec.rb +2 -2
  53. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  54. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  55. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  56. data/spec/functional/resource/windows_font_spec.rb +49 -0
  57. data/spec/functional/shell_spec.rb +5 -5
  58. data/spec/functional/win32/service_manager_spec.rb +1 -1
  59. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  60. data/spec/spec_helper.rb +5 -4
  61. data/spec/support/platform_helpers.rb +12 -42
  62. data/spec/support/platforms/win32/spec_service.rb +1 -1
  63. data/spec/support/shared/functional/directory_resource.rb +1 -1
  64. data/spec/support/shared/functional/execute_resource.rb +1 -1
  65. data/spec/support/shared/functional/file_resource.rb +2 -2
  66. data/spec/support/shared/functional/win32_service.rb +1 -1
  67. data/spec/support/shared/functional/windows_script.rb +3 -3
  68. data/spec/unit/environment_spec.rb +7 -7
  69. data/spec/unit/knife/bootstrap_spec.rb +14 -14
  70. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  71. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  72. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  73. data/spec/unit/knife/ssh_spec.rb +2 -2
  74. data/spec/unit/knife/supermarket_share_spec.rb +5 -3
  75. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
  76. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  77. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  78. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  79. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  80. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  81. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  82. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  83. data/spec/unit/role_spec.rb +11 -11
  84. metadata +40 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc9053028d3cccbdba43dc5be7b25a0fd5a060e98508ca8d30a081dea3c3a427
4
- data.tar.gz: c7286fd82ecedab382a685fd24bfc97f80682b8351300254d1aee414c8910db6
3
+ metadata.gz: 63cfc02be9e339727c4f8c15a37094e43ccb8196e3db7b0e20fa21f7dbcd1bc8
4
+ data.tar.gz: 7e9d225f5c020dbadb6108cef64015d59413eddc24fe30d7b1754397e0c35f5c
5
5
  SHA512:
6
- metadata.gz: 5260139892c3516289eab07b899dfd949d420811d832fd49c856b4615f59c3fe4e3928e7d26fa26bdb9fb4667556b2145ddd25b43ac2508031389457dcc1f1e9
7
- data.tar.gz: 5f934310d3867313ef3fb9d3f35b29a2960fab407e856c574cfc10062a2a1bbc55f991c3a555e661b79dd81e98e0ce0771aa6b7bd14f3e1638266dcae4d5774f
6
+ metadata.gz: 6d1c62834df5a51f1cb515cce89c9d70967377096f76ee2adcda18244e0dcb82c009fdafe109aaab31724e711726dc05cb2ffc656fde6dd9673a03c77435d90e
7
+ data.tar.gz: 355205b67f39573e24a16cc7b87a1a1b653e02e2039dc6e753f653b2c36d1d4b5f9b8010208dc9657a4dca4b63463ee59313ec395ef67f7843bdd386fe97e492
data/Gemfile CHANGED
@@ -28,10 +28,8 @@ group(:omnibus_package) do
28
28
  gem "appbundler"
29
29
  gem "rb-readline"
30
30
  gem "inspec-core", "~> 4.18"
31
- gem "inspec-core-bin", "~> 4.18" # need to provide the binaries for inspec
31
+ gem "inspec-core-bin", "~> 4.24" # need to provide the binaries for inspec
32
32
  gem "chef-vault"
33
- gem "ed25519" # ed25519 ssh key support done here as it's a native gem we can't put in train
34
- gem "bcrypt_pbkdf", ">= 1.1.0.rc1" # ed25519 ssh key support done here as it's a native gem we can't put in train
35
33
  end
36
34
 
37
35
  group(:omnibus_package, :pry) do
@@ -65,14 +63,13 @@ group(:development, :test) do
65
63
  gem "rspec-core", "~> 3.5"
66
64
  gem "rspec-mocks", "~> 3.5"
67
65
  gem "rspec-expectations", "~> 3.5"
68
- gem "rspec_junit_formatter", "~> 0.2.0"
66
+ gem "rspec_junit_formatter", "~> 0.4.0"
69
67
  gem "webmock"
70
68
  gem "fauxhai-ng" # for chef-utils gem
71
69
  end
72
70
 
73
71
  group(:chefstyle) do
74
- # for testing new chefstyle rules
75
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
72
+ gem "chefstyle", "1.2.1" # pinned so we don't have to fixup 2 branches for new rules
76
73
  end
77
74
 
78
75
  instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
@@ -85,6 +82,9 @@ eval_gemfile("./Gemfile.local") if File.exist?("./Gemfile.local")
85
82
  # For FFI to call into PowerShell we need the binaries and assemblies located
86
83
  # in the Ruby bindir.
87
84
  # The Powershell DLL source lives here: https://github.com/chef/chef-powershell-shim
85
+ # Every merge into that repo triggers a Habitat build and promotion. Running
86
+ # the rake :update_chef_exec_dll task in this (chef/chef) repo will pull down
87
+ # the built packages and copy the binaries to distro/ruby_bin_folder.
88
88
  #
89
89
  # We copy (and overwrite) these files every time "bundle <exec|install>" is
90
90
  # executed, just in case they have changed.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![Code Climate](https://codeclimate.com/github/chef/chef.svg)](https://codeclimate.com/github/chef/chef)
3
3
  [![Build status](https://badge.buildkite.com/13b36bf2d9116e3527ff9893e7edd82cb183027941fef3d24e.svg)](https://buildkite.com/chef-oss/chef-chef-chef-15-verify)
4
4
  [![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef)
5
- [![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef/blob/v15.2.21/docs/dev/design_documents/client_release_cadence.md)
5
+ [![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef/blob/chef-15/docs/dev/design_documents/client_release_cadence.md)
6
6
 
7
7
  **Umbrella Project**: [Chef Infra](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-infra.md)
8
8
 
@@ -26,7 +26,7 @@ Other useful resources for Chef Infra users:
26
26
  - Source: <https://github.com/chef/chef/tree/master>
27
27
  - Tickets/Issues: <https://github.com/chef/chef/issues>
28
28
  - Slack: [Chef Community Slack](https://community-slack.chef.io/)
29
- - Mailing list/Forum: <https://discourse.chef.io>
29
+ - Mailing list/Forum: <https://discourse.chef.io/>
30
30
 
31
31
  ## Reporting Issues
32
32
 
@@ -46,7 +46,7 @@ We'd love to have your help developing Chef Infra. See our [Contributing Documen
46
46
 
47
47
  ## License and Copyright
48
48
 
49
- Copyright 2008-2020, Chef Software, Inc.
49
+ Copyright 2008-2021, Chef Software, Inc.
50
50
 
51
51
  ```
52
52
  Licensed under the Apache License, Version 2.0 (the "License");
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Daniel DeLeo (<dan@chef.io>)
4
- # Copyright:: Copyright 2008-2019, Chef Software Inc.
4
+ # Copyright:: Copyright, 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");
@@ -17,16 +17,20 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
+ # we need this to resolve files required by lib/chef/dist
21
+ $LOAD_PATH.unshift(File.expand_path("chef-config/lib", __dir__))
22
+
20
23
  begin
21
24
  require_relative "tasks/rspec"
22
25
  require_relative "tasks/dependencies"
23
- require_relative "tasks/announce"
24
26
  require_relative "tasks/docs"
25
- require_relative "lib/chef/dist"
27
+ require_relative "lib/chef/dist" unless defined?(Chef::Dist)
26
28
  rescue LoadError => e
27
29
  puts "Skipping missing rake dep: #{e}"
28
30
  end
29
31
 
32
+ require "bundler/gem_helper"
33
+
30
34
  ENV["CHEF_LICENSE"] = "accept-no-persist"
31
35
 
32
36
  # hack the chef-config install to run before the traditional install task
@@ -38,6 +42,7 @@ task :super_install do
38
42
  end
39
43
 
40
44
  # Templating the powershell extensions so we can inject distro constants
45
+ require "erb"
41
46
  template_file = ::File.join(::File.dirname(__FILE__), "distro", "templates", "powershell", "chef", "chef.psm1.erb")
42
47
  psm1_path = ::File.join(::File.dirname(__FILE__), "distro", "powershell", "chef")
43
48
  FileUtils.mkdir_p psm1_path
@@ -55,8 +60,9 @@ Bundler::GemHelper.install_tasks name: gemspec
55
60
  # this gets appended to the normal bundler install helper
56
61
  task :install do
57
62
  chef_bin_path = ::File.join(::File.dirname(__FILE__), "chef-bin")
58
- Dir.chdir(chef_bin_path)
59
- sh("rake install:force")
63
+ Dir.chdir(chef_bin_path) do
64
+ sh("rake install:force")
65
+ end
60
66
  end
61
67
 
62
68
  task :pedant, :chef_zero_spec
@@ -82,15 +88,3 @@ begin
82
88
  rescue LoadError
83
89
  puts "chefstyle/rubocop is not available. bundle install first to make sure all dependencies are installed."
84
90
  end
85
-
86
- begin
87
- require "yard"
88
- DOC_FILES = [ "spec/tiny_server.rb", "lib/**/*.rb" ].freeze
89
-
90
- YARD::Rake::YardocTask.new(:docs) do |t|
91
- t.files = DOC_FILES
92
- t.options = ["--format", "html"]
93
- end
94
- rescue LoadError
95
- puts "yard is not available. bundle install first to make sure all dependencies are installed."
96
- end
@@ -10,12 +10,12 @@ gemspec.add_dependency "win32-event", "~> 0.6.1"
10
10
  gemspec.add_dependency "win32-eventlog", "0.6.3"
11
11
  gemspec.add_dependency "win32-mmap", "~> 0.4.1"
12
12
  gemspec.add_dependency "win32-mutex", "~> 0.4.2"
13
- gemspec.add_dependency "win32-process", "~> 0.8.2"
13
+ gemspec.add_dependency "win32-process", "~> 0.9"
14
14
  gemspec.add_dependency "win32-service", ">= 2.1.5", "< 3.0"
15
15
  gemspec.add_dependency "wmi-lite", "~> 1.0"
16
16
  gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
17
17
  gemspec.add_dependency "iso8601", ">= 0.12.1", "< 0.14" # validate 0.14 when it comes out
18
- gemspec.add_dependency "win32-certstore", "~> 0.3"
18
+ gemspec.add_dependency "win32-certstore", "~> 0.5.0" # 0.5+ required for specifying user vs. system store
19
19
  gemspec.extensions << "ext/win32-eventlog/Rakefile"
20
20
  gemspec.files += Dir.glob("{distro,ext}/**/*")
21
21
 
data/chef.gemspec CHANGED
@@ -1,4 +1,13 @@
1
1
  $:.unshift(File.dirname(__FILE__) + "/lib")
2
+ vs_path = File.expand_path("chef-utils/lib/chef-utils/version_string.rb", __dir__)
3
+
4
+ if File.exist?(vs_path)
5
+ # this is the moral equivalent of a require_relative since bundler makes require_relative here fail hard
6
+ eval(IO.read(vs_path))
7
+ else
8
+ # if the path doesn't exist then we're just in the wild gem and not in the git repo
9
+ require "chef-utils/version_string"
10
+ end
2
11
  require "chef/version"
3
12
 
4
13
  Gem::Specification.new do |s|
@@ -20,7 +29,7 @@ Gem::Specification.new do |s|
20
29
  s.add_dependency "train-core", "~> 3.2", ">= 3.2.28" # 3.2.28 fixes sudo prompts. See https://github.com/chef/chef/pull/9635
21
30
  s.add_dependency "train-winrm", ">= 0.2.5"
22
31
 
23
- s.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.5"
32
+ s.add_dependency "license-acceptance", ">= 1.0.5", "< 3"
24
33
  s.add_dependency "mixlib-cli", ">= 2.1.1", "< 3.0"
25
34
  s.add_dependency "mixlib-log", ">= 2.0.3", "< 4.0"
26
35
  s.add_dependency "mixlib-authentication", ">= 2.1", "< 4"
@@ -35,10 +44,10 @@ Gem::Specification.new do |s|
35
44
  s.add_dependency "net-sftp", ">= 2.1.2", "< 4.0"
36
45
  s.add_dependency "ed25519", "~> 1.2" # ed25519 ssh key support
37
46
  s.add_dependency "bcrypt_pbkdf", "~> 1.0" # ed25519 ssh key support
38
- s.add_dependency "highline", ">= 1.6.9", "< 2"
47
+ s.add_dependency "highline", ">= 1.6.9", "< 3"
39
48
  s.add_dependency "tty-screen", "~> 0.6" # knife list
40
49
  s.add_dependency "erubis", "~> 2.7"
41
- s.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.4"
50
+ s.add_dependency "diff-lcs", ">= 1.2.4", "< 1.4.0" # 1.4 breaks output
42
51
  s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3"
43
52
  s.add_dependency "chef-zero", ">= 14.0.11"
44
53
 
@@ -46,7 +55,7 @@ Gem::Specification.new do |s|
46
55
  s.add_dependency "iniparse", "~> 1.4"
47
56
  s.add_dependency "addressable"
48
57
  s.add_dependency "syslog-logger", "~> 1.6"
49
- s.add_dependency "uuidtools", "~> 2.1.5"
58
+ s.add_dependency "uuidtools", ">= 2.1.5", "< 3.0"
50
59
 
51
60
  s.add_dependency "proxifier", "~> 1.0"
52
61
 
@@ -62,4 +71,13 @@ Gem::Specification.new do |s|
62
71
  Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } +
63
72
  Dir.glob("*.gemspec") +
64
73
  Dir.glob("tasks/rspec.rb")
74
+
75
+ s.metadata = {
76
+ "bug_tracker_uri" => "https://github.com/chef/chef/issues",
77
+ "changelog_uri" => "https://github.com/chef/chef/blob/master/CHANGELOG.md",
78
+ "documentation_uri" => "https://docs.chef.io/",
79
+ "homepage_uri" => "https://www.chef.io",
80
+ "mailing_list_uri" => "https://discourse.chef.io/",
81
+ "source_code_uri" => "https://github.com/chef/chef/",
82
+ }
65
83
  end
@@ -72,14 +72,14 @@ class Chef
72
72
 
73
73
  def assert_destination_writable!
74
74
  abs_path = File.expand_path(destination)
75
- unless File.exists?(File.dirname(abs_path))
75
+ unless File.exist?(File.dirname(abs_path))
76
76
  begin
77
77
  FileUtils.mkdir_p(File.dirname(abs_path))
78
78
  rescue Errno::EACCES
79
79
  raise Chef::Exceptions::CannotWritePrivateKey, "I can't create the configuration directory at #{File.dirname(abs_path)} - check permissions?"
80
80
  end
81
81
  end
82
- if (File.exists?(abs_path) && !File.writable?(abs_path)) || !File.writable?(File.dirname(abs_path))
82
+ if (File.exist?(abs_path) && !File.writable?(abs_path)) || !File.writable?(File.dirname(abs_path))
83
83
  raise Chef::Exceptions::CannotWritePrivateKey, "I can't write your private key to #{abs_path} - check permissions?"
84
84
  end
85
85
  end
@@ -76,7 +76,7 @@ class Chef
76
76
 
77
77
  # Write out .uploaded-cookbook-version.json
78
78
  # cookbook_file_path = File.join(file_path, cookbook_name) <- this should be the same as self.file_path
79
- unless File.exists?(file_path)
79
+ unless File.exist?(file_path)
80
80
  FileUtils.mkdir_p(file_path)
81
81
  end
82
82
  uploaded_cookbook_version_path = File.join(file_path, Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE)
@@ -132,7 +132,7 @@ class Chef
132
132
  end
133
133
 
134
134
  def can_upload?
135
- File.exists?(uploaded_cookbook_version_path) || children.size > 0
135
+ File.exist?(uploaded_cookbook_version_path) || children.size > 0
136
136
  end
137
137
 
138
138
  protected
@@ -137,7 +137,7 @@ class Chef
137
137
  end
138
138
 
139
139
  def exists?
140
- File.exists?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
140
+ File.exist?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
141
141
  end
142
142
 
143
143
  def read
@@ -161,7 +161,7 @@ class Chef
161
161
  # members.json and org.json may be found.
162
162
  #
163
163
  def root_dir
164
- existing_paths = root_paths.select { |path| File.exists?(path) }
164
+ existing_paths = root_paths.select { |path| File.exist?(path) }
165
165
  if existing_paths.size > 0
166
166
  MultiplexedDir.new(existing_paths.map do |path|
167
167
  dir = FileSystemEntry.new(name, parent, path)
@@ -184,7 +184,7 @@ class Chef
184
184
  return root_dir.child(name)
185
185
  end
186
186
 
187
- paths = (child_paths[name] || []).select { |path| File.exists?(path) }
187
+ paths = (child_paths[name] || []).select { |path| File.exist?(path) }
188
188
  if paths.size == 0
189
189
  return NonexistentFSObject.new(name, self)
190
190
  end
@@ -151,7 +151,7 @@ class Chef
151
151
  end
152
152
 
153
153
  def exists?
154
- File.exists?(file_path)
154
+ File.exist?(file_path)
155
155
  end
156
156
 
157
157
  protected
@@ -122,7 +122,7 @@ class Chef
122
122
  end
123
123
 
124
124
  def exists?
125
- File.exists?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
125
+ File.exist?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?))
126
126
  end
127
127
 
128
128
  def read
@@ -255,11 +255,11 @@ class Chef
255
255
  js_file = File.join(Chef::Config[:environment_path], "#{name}.json")
256
256
  rb_file = File.join(Chef::Config[:environment_path], "#{name}.rb")
257
257
 
258
- if File.exists?(js_file)
258
+ if File.exist?(js_file)
259
259
  # from_json returns object.class => json_class in the JSON.
260
260
  hash = Chef::JSONCompat.parse(IO.read(js_file))
261
261
  from_hash(hash)
262
- elsif File.exists?(rb_file)
262
+ elsif File.exist?(rb_file)
263
263
  environment = Chef::Environment.new
264
264
  environment.name(name)
265
265
  environment.from_file(rb_file)
data/lib/chef/http.rb CHANGED
@@ -22,7 +22,8 @@
22
22
  #
23
23
 
24
24
  require "tempfile" unless defined?(Tempfile)
25
- require "net/https"
25
+ require "openssl" unless defined?(OpenSSL)
26
+ require "net/http" unless defined?(Net::HTTP)
26
27
  require "uri" unless defined?(URI)
27
28
  require_relative "http/basic_client"
28
29
  require_relative "monkey_patches/net_http"
@@ -497,7 +497,7 @@ class Chef
497
497
  template = bootstrap_template
498
498
 
499
499
  # Use the template directly if it's a path to an actual file
500
- if File.exists?(template)
500
+ if File.exist?(template)
501
501
  Chef::Log.trace("Using the specified bootstrap template: #{File.dirname(template)}")
502
502
  return template
503
503
  end
@@ -512,7 +512,7 @@ class Chef
512
512
 
513
513
  template_file = Array(bootstrap_files).find do |bootstrap_template|
514
514
  Chef::Log.trace("Looking for bootstrap template in #{File.dirname(bootstrap_template)}")
515
- File.exists?(bootstrap_template)
515
+ File.exist?(bootstrap_template)
516
516
  end
517
517
 
518
518
  unless template_file
@@ -73,7 +73,7 @@ class Chef
73
73
  manifest = cookbook.cookbook_manifest
74
74
 
75
75
  basedir = File.join(config[:download_directory], "#{@cookbook_name}-#{cookbook.version}")
76
- if File.exists?(basedir)
76
+ if File.exist?(basedir)
77
77
  if config[:force]
78
78
  Chef::Log.trace("Deleting #{basedir}")
79
79
  FileUtils.rm_rf(basedir)
@@ -62,7 +62,7 @@ class Chef
62
62
  def generate_metadata(cookbook)
63
63
  Array(config[:cookbook_path]).reverse_each do |path|
64
64
  file = File.expand_path(File.join(path, cookbook, "metadata.rb"))
65
- if File.exists?(file)
65
+ if File.exist?(file)
66
66
  generate_metadata_from_file(cookbook, file)
67
67
  else
68
68
  validate_metadata_json(path, cookbook)
@@ -53,7 +53,7 @@ class Chef
53
53
  paths = manifest[KEY]["plugins_paths"][command]
54
54
  if paths && paths.is_a?(Array)
55
55
  # It is only an error if all the paths don't exist
56
- if paths.all? { |sc| !File.exists?(sc) }
56
+ if paths.all? { |sc| !File.exist?(sc) }
57
57
  errors[command] = paths
58
58
  end
59
59
  end
@@ -77,7 +77,7 @@ class Chef
77
77
  false
78
78
  else
79
79
  paths.each do |sc|
80
- if File.exists?(sc)
80
+ if File.exist?(sc)
81
81
  Kernel.load sc
82
82
  else
83
83
  return false
@@ -76,7 +76,7 @@ class Chef::Knife::Exec < Chef::Knife
76
76
  def find_script(x)
77
77
  # Try to find a script. First try expanding the path given.
78
78
  script = File.expand_path(x)
79
- return script if File.exists?(script)
79
+ return script if File.exist?(script)
80
80
 
81
81
  # Failing that, try searching the script path. If we can't find
82
82
  # anything, fail gracefully.
@@ -86,7 +86,7 @@ class Chef::Knife::Exec < Chef::Knife
86
86
  path = File.expand_path(path)
87
87
  test = File.join(path, x)
88
88
  Chef::Log.trace("Testing: #{test}")
89
- if File.exists?(test)
89
+ if File.exist?(test)
90
90
  script = test
91
91
  Chef::Log.trace("Found: #{test}")
92
92
  return script
@@ -362,11 +362,21 @@ class Chef
362
362
  subsession ||= session
363
363
  command = fixup_sudo(command)
364
364
  command.force_encoding("binary") if command.respond_to?(:force_encoding)
365
+ begin
366
+ open_session(subsession, command)
367
+ rescue => e
368
+ open_session(subsession, command, true)
369
+ end
370
+ end
371
+
372
+ def open_session(subsession, command, pty = false)
373
+ stderr = ""
374
+ exit_status = 0
365
375
  subsession.open_channel do |chan|
366
376
  if config[:on_error] && exit_status != 0
367
377
  chan.close
368
378
  else
369
- chan.request_pty
379
+ chan.request_pty if pty
370
380
  chan.exec command do |ch, success|
371
381
  raise ArgumentError, "Cannot execute #{command}" unless success
372
382
 
@@ -377,6 +387,11 @@ class Chef
377
387
  ichannel.send_data("#{get_password}\n")
378
388
  end
379
389
  end
390
+
391
+ ch.on_extended_data do |_, _type, data|
392
+ stderr += data
393
+ end
394
+
380
395
  ch.on_request "exit-status" do |ichannel, data|
381
396
  exit_status = [exit_status, data.read_long].max
382
397
  end
@@ -101,6 +101,11 @@ while 1:
101
101
  if ppid == 1:
102
102
  sys.exit(0)
103
103
  line = sys.stdin.readline()
104
+
105
+ # only way to detect EOF in python
106
+ if line == "":
107
+ break
108
+
104
109
  command = json.loads(line)
105
110
  if command['action'] == "whatinstalled":
106
111
  query(command)