chef 11.14.0.alpha.4-x86-mingw32 → 11.14.0.rc.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/CONTRIBUTING.md +0 -4
  2. data/README.md +1 -1
  3. data/distro/common/man/man1/chef-shell.1 +4 -4
  4. data/distro/common/man/man1/knife-bootstrap.1 +14 -11
  5. data/distro/common/man/man1/knife-client.1 +14 -11
  6. data/distro/common/man/man1/knife-configure.1 +7 -7
  7. data/distro/common/man/man1/knife-cookbook-site.1 +23 -23
  8. data/distro/common/man/man1/knife-cookbook.1 +23 -23
  9. data/distro/common/man/man1/knife-data-bag.1 +13 -13
  10. data/distro/common/man/man1/knife-delete.1 +9 -9
  11. data/distro/common/man/man1/knife-deps.1 +9 -9
  12. data/distro/common/man/man1/knife-diff.1 +10 -10
  13. data/distro/common/man/man1/knife-download.1 +9 -9
  14. data/distro/common/man/man1/knife-edit.1 +7 -7
  15. data/distro/common/man/man1/knife-environment.1 +10 -10
  16. data/distro/common/man/man1/knife-exec.1 +7 -7
  17. data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
  18. data/distro/common/man/man1/knife-list.1 +12 -12
  19. data/distro/common/man/man1/knife-node.1 +12 -9
  20. data/distro/common/man/man1/knife-raw.1 +7 -7
  21. data/distro/common/man/man1/knife-recipe-list.1 +1 -1
  22. data/distro/common/man/man1/knife-role.1 +8 -8
  23. data/distro/common/man/man1/knife-search.1 +9 -9
  24. data/distro/common/man/man1/knife-serve.1 +109 -0
  25. data/distro/common/man/man1/knife-show.1 +8 -8
  26. data/distro/common/man/man1/knife-ssh.1 +9 -9
  27. data/distro/common/man/man1/knife-ssl-check.1 +9 -9
  28. data/distro/common/man/man1/knife-ssl-fetch.1 +10 -10
  29. data/distro/common/man/man1/knife-status.1 +9 -9
  30. data/distro/common/man/man1/knife-tag.1 +7 -7
  31. data/distro/common/man/man1/knife-upload.1 +10 -10
  32. data/distro/common/man/man1/knife-user.1 +9 -9
  33. data/distro/common/man/man1/knife-xargs.1 +7 -7
  34. data/distro/common/man/man1/knife.1 +118 -14
  35. data/distro/common/man/man8/chef-client.8 +13 -10
  36. data/distro/common/man/man8/chef-solo.8 +13 -14
  37. data/distro/common/markdown/man1/knife.mkd +1 -1
  38. data/lib/chef/application/knife.rb +1 -1
  39. data/lib/chef/application/windows_service.rb +0 -1
  40. data/lib/chef/chef_fs/file_system.rb +6 -2
  41. data/lib/chef/config.rb +3 -2
  42. data/lib/chef/config_fetcher.rb +1 -1
  43. data/lib/chef/cookbook/metadata.rb +20 -14
  44. data/lib/chef/cookbook/synchronizer.rb +24 -13
  45. data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
  46. data/lib/chef/encrypted_data_bag_item/encryptor.rb +2 -2
  47. data/lib/chef/exceptions.rb +1 -0
  48. data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
  49. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
  50. data/lib/chef/http.rb +6 -1
  51. data/lib/chef/http/http_request.rb +9 -1
  52. data/lib/chef/http/simple.rb +2 -1
  53. data/lib/chef/json_compat.rb +5 -16
  54. data/lib/chef/knife/bootstrap.rb +2 -0
  55. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  56. data/lib/chef/knife/core/object_loader.rb +3 -1
  57. data/lib/chef/knife/ssh.rb +14 -7
  58. data/lib/chef/mixin/convert_to_class_name.rb +1 -0
  59. data/lib/chef/mixin/windows_architecture_helper.rb +24 -4
  60. data/lib/chef/platform/provider_mapping.rb +13 -0
  61. data/lib/chef/provider/env/windows.rb +3 -6
  62. data/lib/chef/provider/git.rb +1 -2
  63. data/lib/chef/provider/log.rb +15 -1
  64. data/lib/chef/provider/package/apt.rb +3 -3
  65. data/lib/chef/provider/package/dpkg.rb +35 -16
  66. data/lib/chef/provider/package/paludis.rb +91 -0
  67. data/lib/chef/provider/package/rpm.rb +3 -2
  68. data/lib/chef/provider/package/yum-dump.py +6 -6
  69. data/lib/chef/provider/package/yum.rb +2 -0
  70. data/lib/chef/provider/registry_key.rb +4 -5
  71. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
  72. data/lib/chef/provider/service/solaris.rb +1 -1
  73. data/lib/chef/provider/service/upstart.rb +2 -1
  74. data/lib/chef/provider/service/windows.rb +37 -9
  75. data/lib/chef/provider/user/pw.rb +1 -1
  76. data/lib/chef/provider/user/useradd.rb +1 -1
  77. data/lib/chef/provider/windows_script.rb +2 -1
  78. data/lib/chef/providers.rb +1 -0
  79. data/lib/chef/resource.rb +10 -0
  80. data/lib/chef/resource/file.rb +0 -9
  81. data/lib/chef/resource/package.rb +14 -4
  82. data/lib/chef/resource/paludis_package.rb +33 -0
  83. data/lib/chef/resource/registry_key.rb +62 -3
  84. data/lib/chef/resource/service.rb +21 -4
  85. data/lib/chef/resource_reporter.rb +10 -0
  86. data/lib/chef/resources.rb +1 -0
  87. data/lib/chef/role.rb +14 -10
  88. data/lib/chef/shell.rb +8 -0
  89. data/lib/chef/shell/shell_session.rb +3 -3
  90. data/lib/chef/user.rb +12 -11
  91. data/lib/chef/util/selinux.rb +1 -1
  92. data/lib/chef/version.rb +1 -1
  93. data/lib/chef/version_constraint.rb +6 -5
  94. data/lib/chef/win32/api/process.rb +1 -0
  95. data/lib/chef/win32/api/system.rb +14 -0
  96. data/lib/chef/win32/error.rb +1 -1
  97. data/lib/chef/win32/security.rb +5 -5
  98. data/lib/chef/win32/version.rb +6 -2
  99. data/spec/data/trusted_certs/opscode.pem +57 -35
  100. data/spec/functional/application_spec.rb +2 -2
  101. data/spec/functional/resource/mount_spec.rb +3 -1
  102. data/spec/functional/shell_spec.rb +10 -0
  103. data/spec/functional/tiny_server_spec.rb +2 -2
  104. data/spec/support/chef_helpers.rb +1 -1
  105. data/spec/support/shared/functional/securable_resource.rb +11 -2
  106. data/spec/support/shared/functional/securable_resource_with_reporting.rb +13 -2
  107. data/spec/tiny_server.rb +1 -1
  108. data/spec/unit/config_spec.rb +5 -0
  109. data/spec/unit/cookbook/metadata_spec.rb +24 -0
  110. data/spec/unit/environment_spec.rb +6 -0
  111. data/spec/unit/http/http_request_spec.rb +91 -0
  112. data/spec/unit/http_spec.rb +23 -0
  113. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  114. data/spec/unit/knife/ssh_spec.rb +7 -13
  115. data/spec/unit/knife_spec.rb +1 -1
  116. data/spec/unit/mixin/convert_to_class_name_spec.rb +4 -0
  117. data/spec/unit/provider/git_spec.rb +2 -2
  118. data/spec/unit/provider/log_spec.rb +18 -0
  119. data/spec/unit/provider/mount/solaris_spec.rb +3 -1
  120. data/spec/unit/provider/package/apt_spec.rb +85 -40
  121. data/spec/unit/provider/package/dpkg_spec.rb +24 -48
  122. data/spec/unit/provider/package/paludis_spec.rb +135 -0
  123. data/spec/unit/provider/package/rpm_spec.rb +40 -32
  124. data/spec/unit/provider/package/yum_spec.rb +11 -4
  125. data/spec/unit/provider/registry_key_spec.rb +67 -53
  126. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +10 -1
  127. data/spec/unit/provider/service/solaris_smf_service_spec.rb +23 -2
  128. data/spec/unit/provider/service/upstart_service_spec.rb +7 -0
  129. data/spec/unit/provider/service/windows_spec.rb +72 -0
  130. data/spec/unit/provider/user/pw_spec.rb +21 -4
  131. data/spec/unit/provider/user/useradd_spec.rb +10 -0
  132. data/spec/unit/resource/package_spec.rb +26 -18
  133. data/spec/unit/resource/registry_key_spec.rb +28 -0
  134. data/spec/unit/resource/service_spec.rb +14 -0
  135. data/spec/unit/resource_reporter_spec.rb +37 -12
  136. data/spec/unit/resource_spec.rb +41 -6
  137. data/spec/unit/rest_spec.rb +2 -2
  138. data/spec/unit/role_spec.rb +46 -28
  139. data/spec/unit/shell/shell_session_spec.rb +42 -2
  140. data/spec/unit/shell_spec.rb +1 -1
  141. data/spec/unit/user_spec.rb +12 -0
  142. data/spec/unit/util/selinux_spec.rb +4 -4
  143. data/spec/unit/version_constraint_spec.rb +14 -2
  144. metadata +223 -167
  145. checksums.yaml +0 -7
@@ -41,7 +41,7 @@ documentation using `knife help TOPIC`.
41
41
  * `-c`, `--config` CONFIG:
42
42
  The configuration file to use
43
43
  * `-E`, `--environment ENVIRONMENT`:
44
- Set the Chef environment
44
+ Set the Chef environment (except for in searches, where this will be flagrantly ignored)
45
45
  * `-e`, `--editor` EDITOR:
46
46
  Set the editor to use for interactive commands
47
47
  * `-F`, `--format` FORMAT:
@@ -51,7 +51,7 @@ class Chef::Application::Knife < Chef::Application
51
51
  option :environment,
52
52
  :short => "-E ENVIRONMENT",
53
53
  :long => "--environment ENVIRONMENT",
54
- :description => "Set the Chef environment"
54
+ :description => "Set the Chef environment (except for in searches, where this will be flagrantly ignored)"
55
55
 
56
56
  option :editor,
57
57
  :short => "-e EDITOR",
@@ -211,7 +211,6 @@ class Chef
211
211
  def reconfigure(startup_parameters=[])
212
212
  configure_chef startup_parameters
213
213
  configure_logging
214
- configure_proxy_environment_variables
215
214
 
216
215
  Chef::Config[:chef_server_url] = config[:chef_server_url] if config.has_key? :chef_server_url
217
216
  unless Chef::Config[:exception_handlers].any? {|h| Chef::Handler::ErrorReport === h}
@@ -285,8 +285,12 @@ class Chef
285
285
  if options[:dry_run]
286
286
  ui.output "Would delete #{dest_path}" if ui
287
287
  else
288
- dest_entry.delete(true)
289
- ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui
288
+ begin
289
+ dest_entry.delete(true)
290
+ ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui
291
+ rescue Chef::ChefFS::FileSystem::NotFoundError
292
+ ui.output "Entry #{dest_path} does not exist. Nothing to do. (purge is on)" if ui
293
+ end
290
294
  end
291
295
  else
292
296
  ui.output ("Not deleting extra entry #{dest_path} (purge is off)") if ui
@@ -331,6 +331,7 @@ class Chef
331
331
 
332
332
  default :rest_timeout, 300
333
333
  default :yum_timeout, 900
334
+ default :yum_lock_timeout, 30
334
335
  default :solo, false
335
336
  default :splay, nil
336
337
  default :why_run, false
@@ -551,8 +552,8 @@ class Chef
551
552
  windows_home_path = env['SYSTEMDRIVE'] + env['HOMEPATH'] if env['SYSTEMDRIVE'] && env['HOMEPATH']
552
553
  end
553
554
 
554
- # returns a platform specific path to the user home dir
555
- default( :user_home ) { env['HOME'] || windows_home_path || env['USERPROFILE'] }
555
+ # returns a platform specific path to the user home dir if set, otherwise default to current directory.
556
+ default( :user_home ) { env['HOME'] || windows_home_path || env['USERPROFILE'] || Dir.pwd }
556
557
 
557
558
  # Enable file permission fixup for selinux. Fixup will be done
558
559
  # only if selinux is enabled in the system.
@@ -18,7 +18,7 @@ class Chef
18
18
  config_data = read_config
19
19
  begin
20
20
  Chef::JSONCompat.from_json(config_data)
21
- rescue JSON::ParserError => error
21
+ rescue FFI_Yajl::ParseError => error
22
22
  Chef::Application.fatal!("Could not parse the provided JSON file (#{config_location}): " + error.message, 2)
23
23
  end
24
24
  end
@@ -242,8 +242,8 @@ class Chef
242
242
  # versions<Array>:: Returns the list of versions for the platform
243
243
  def supports(platform, *version_args)
244
244
  version = new_args_format(:supports, platform, version_args)
245
- validate_version_constraint(:supports, platform, version)
246
- @platforms[platform] = version
245
+ normalized_version = normalize_version_constraint(:supports, platform, version)
246
+ @platforms[platform] = normalized_version
247
247
  @platforms[platform]
248
248
  end
249
249
 
@@ -259,8 +259,8 @@ class Chef
259
259
  # versions<Array>:: Returns the list of versions for the platform
260
260
  def depends(cookbook, *version_args)
261
261
  version = new_args_format(:depends, cookbook, version_args)
262
- validate_version_constraint(:depends, cookbook, version)
263
- @dependencies[cookbook] = version
262
+ normalized_version = normalize_version_constraint(:depends, cookbook, version)
263
+ @dependencies[cookbook] = normalized_version
264
264
  @dependencies[cookbook]
265
265
  end
266
266
 
@@ -276,8 +276,8 @@ class Chef
276
276
  # versions<Array>:: Returns the list of versions for the platform
277
277
  def recommends(cookbook, *version_args)
278
278
  version = new_args_format(:recommends, cookbook, version_args)
279
- validate_version_constraint(:recommends, cookbook, version)
280
- @recommendations[cookbook] = version
279
+ normalized_version = normalize_version_constraint(:recommends, cookbook, version)
280
+ @recommendations[cookbook] = normalized_version
281
281
  @recommendations[cookbook]
282
282
  end
283
283
 
@@ -293,8 +293,8 @@ class Chef
293
293
  # versions<Array>:: Returns the list of versions for the platform
294
294
  def suggests(cookbook, *version_args)
295
295
  version = new_args_format(:suggests, cookbook, version_args)
296
- validate_version_constraint(:suggests, cookbook, version)
297
- @suggestions[cookbook] = version
296
+ normalized_version = normalize_version_constraint(:suggests, cookbook, version)
297
+ @suggestions[cookbook] = normalized_version
298
298
  @suggestions[cookbook]
299
299
  end
300
300
 
@@ -310,8 +310,8 @@ class Chef
310
310
  # versions<Array>:: Returns the list of versions for the platform
311
311
  def conflicts(cookbook, *version_args)
312
312
  version = new_args_format(:conflicts, cookbook, version_args)
313
- validate_version_constraint(:conflicts, cookbook, version)
314
- @conflicting[cookbook] = version
313
+ normalized_version = normalize_version_constraint(:conflicts, cookbook, version)
314
+ @conflicting[cookbook] = normalized_version
315
315
  @conflicting[cookbook]
316
316
  end
317
317
 
@@ -331,8 +331,8 @@ class Chef
331
331
  # versions<Array>:: Returns the list of versions for the platform
332
332
  def provides(cookbook, *version_args)
333
333
  version = new_args_format(:provides, cookbook, version_args)
334
- validate_version_constraint(:provides, cookbook, version)
335
- @providing[cookbook] = version
334
+ normalized_version = normalize_version_constraint(:provides, cookbook, version)
335
+ @providing[cookbook] = normalized_version
336
336
  @providing[cookbook]
337
337
  end
338
338
 
@@ -347,8 +347,8 @@ class Chef
347
347
  # versions<Array>:: Returns the list of versions for the platform
348
348
  def replaces(cookbook, *version_args)
349
349
  version = new_args_format(:replaces, cookbook, version_args)
350
- validate_version_constraint(:replaces, cookbook, version)
351
- @replacing[cookbook] = version
350
+ normalized_version = normalize_version_constraint(:replaces, cookbook, version)
351
+ @replacing[cookbook] = normalized_version
352
352
  @replacing[cookbook]
353
353
  end
354
354
 
@@ -532,6 +532,12 @@ Called from:
532
532
  INVALID
533
533
  raise Exceptions::InvalidVersionConstraint, msg
534
534
  end
535
+
536
+ def normalize_version_constraint(caller_name, dep_name, constraint_str)
537
+ version_constraint = validate_version_constraint(caller_name, dep_name, constraint_str)
538
+ "#{version_constraint.op} #{version_constraint.raw_version}"
539
+ end
540
+
535
541
  # Verify that the given array is an array of strings
536
542
  #
537
543
  # Raise an exception if the members of the array are not Strings
@@ -68,6 +68,8 @@ class Chef
68
68
  @eager_segments.freeze
69
69
 
70
70
  @cookbooks_by_name, @events = cookbooks_by_name, events
71
+
72
+ @cookbook_full_file_paths = {}
71
73
  end
72
74
 
73
75
  def cache
@@ -136,14 +138,20 @@ class Chef
136
138
 
137
139
  files.each do |file|
138
140
  queue << lambda do |lock|
139
- sync_file(file)
140
- lock.synchronize { mark_file_synced(file) }
141
+ full_file_path = sync_file(file)
142
+
143
+ lock.synchronize {
144
+ # Save the full_path of the downloaded file to be restored in the manifest later
145
+ save_full_file_path(file, full_file_path)
146
+ mark_file_synced(file)
147
+ }
141
148
  end
142
149
  end
143
150
 
144
151
  @events.cookbook_sync_start(cookbook_count)
145
152
  queue.process(Chef::Config[:cookbook_sync_threads])
146
- update_cookbook_filenames
153
+ # Update the full file paths in the manifest
154
+ update_cookbook_filenames()
147
155
 
148
156
  rescue Exception => e
149
157
  @events.cookbook_sync_failed(cookbooks, e)
@@ -153,6 +161,14 @@ class Chef
153
161
  true
154
162
  end
155
163
 
164
+ # Saves the full_path to the file of the cookbook to be updated
165
+ # in the manifest later
166
+ def save_full_file_path(file, full_path)
167
+ @cookbook_full_file_paths[file.cookbook] ||= { }
168
+ @cookbook_full_file_paths[file.cookbook][file.segment] ||= [ ]
169
+ @cookbook_full_file_paths[file.cookbook][file.segment] << full_path
170
+ end
171
+
156
172
  # Iterates over cached cookbooks' files, removing files belonging to
157
173
  # cookbooks that don't appear in +cookbook_hash+
158
174
  def clear_obsoleted_cookbooks
@@ -170,14 +186,9 @@ class Chef
170
186
  end
171
187
 
172
188
  def update_cookbook_filenames
173
- files_by_cookbook.each do |cookbook, cookbook_files|
174
- files_by_segment = cookbook_files.group_by { |file| file.segment }
175
- @eager_segments.each do |segment|
176
- segment_files = files_by_segment[segment]
177
- next unless segment_files
178
-
179
- filenames = segment_files.map { |file| file.manifest_record['path'] }
180
- cookbook.replace_segment_filenames(segment, filenames)
189
+ @cookbook_full_file_paths.each do |cookbook, file_segments|
190
+ file_segments.each do |segment, full_paths|
191
+ cookbook.replace_segment_filenames(segment, full_paths)
181
192
  end
182
193
  end
183
194
  end
@@ -204,8 +215,8 @@ class Chef
204
215
  Chef::Log.debug("Not storing #{cache_filename}, as the cache is up to date.")
205
216
  end
206
217
 
207
- # Update the manifest with the full path to the cached file
208
- file.manifest_record['path'] = cache.load(cache_filename, false)
218
+ # Load the file in the cache and return the full file path to the loaded file
219
+ cache.load(cache_filename, false)
209
220
  end
210
221
 
211
222
  def cached_copy_up_to_date?(local_path, expected_checksum)
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require 'yaml'
20
- require 'yajl'
20
+ require 'ffi_yajl'
21
21
  require 'openssl'
22
22
  require 'base64'
23
23
  require 'digest/sha2'
@@ -121,8 +121,8 @@ class Chef::EncryptedDataBagItem
121
121
  end
122
122
 
123
123
  def for_decrypted_item
124
- Yajl::Parser.parse(decrypted_data)["json_wrapper"]
125
- rescue Yajl::ParseError
124
+ FFI_Yajl::Parser.parse(decrypted_data)["json_wrapper"]
125
+ rescue FFI_Yajl::ParseError
126
126
  # convert to a DecryptionFailure error because the most likely scenario
127
127
  # here is that the decryption step was unsuccessful but returned bad
128
128
  # data rather than raising an error.
@@ -19,7 +19,7 @@
19
19
  require 'base64'
20
20
  require 'digest/sha2'
21
21
  require 'openssl'
22
- require 'yajl'
22
+ require 'ffi_yajl'
23
23
  require 'chef/encrypted_data_bag_item'
24
24
  require 'chef/encrypted_data_bag_item/unsupported_encrypted_data_bag_item_format'
25
25
 
@@ -111,7 +111,7 @@ class Chef::EncryptedDataBagItem
111
111
  # Strings) that do not produce valid JSON when serialized without the
112
112
  # wrapper.
113
113
  def serialized_data
114
- Yajl::Encoder.encode(:json_wrapper => plaintext_data)
114
+ FFI_Yajl::Encoder.encode(:json_wrapper => plaintext_data)
115
115
  end
116
116
  end
117
117
 
@@ -64,6 +64,7 @@ class Chef
64
64
  class PrivateKeyMissing < RuntimeError; end
65
65
  class CannotWritePrivateKey < RuntimeError; end
66
66
  class RoleNotFound < RuntimeError; end
67
+ class DuplicateRole < RuntimeError; end
67
68
  class ValidationFailed < ArgumentError; end
68
69
  class InvalidPrivateKey < ArgumentError; end
69
70
  class ConfigurationError < ArgumentError; end
@@ -60,7 +60,7 @@ class Chef
60
60
  # Catch and raise if the user is not elevated enough.
61
61
  # At this point we can't configure the file as expected so
62
62
  # we're failing action on the resource.
63
- raise Chef::Exceptions::WindowsNotAdmin, "can not get the security information for '#{dst}' due to missing Administrator privilages."
63
+ raise Chef::Exceptions::WindowsNotAdmin, "can not get the security information for '#{dst}' due to missing Administrator privileges."
64
64
  end
65
65
 
66
66
  if dst_sd.dacl_present?
@@ -40,7 +40,7 @@ class Chef
40
40
  end
41
41
 
42
42
  unless dynamic_resource?
43
- error_description.section("Resource Declaration:", recipe_snippet)
43
+ error_description.section("Resource Declaration:", resource.sensitive ? "suppressed sensitive resource output" : recipe_snippet)
44
44
  end
45
45
 
46
46
  error_description.section("Compiled Resource:", "#{resource.to_text}")
@@ -21,12 +21,14 @@
21
21
  # limitations under the License.
22
22
  #
23
23
 
24
+ require 'tempfile'
24
25
  require 'net/https'
25
26
  require 'uri'
26
27
  require 'chef/http/basic_client'
27
28
  require 'chef/monkey_patches/string'
28
29
  require 'chef/monkey_patches/net_http'
29
30
  require 'chef/config'
31
+ require 'chef/platform/query_helpers'
30
32
  require 'chef/exceptions'
31
33
 
32
34
  class Chef
@@ -207,7 +209,10 @@ class Chef
207
209
  elsif path.nil? or path.empty?
208
210
  URI.parse(@url)
209
211
  else
210
- URI.parse("#{@url}/#{path}")
212
+ # The regular expressions used here are to make sure '@url' does not have
213
+ # any trailing slashes and 'path' does not have any leading slashes. This
214
+ # way they are always joined correctly using just one slash.
215
+ URI.parse(@url.gsub(%r{/+$}, '') + '/' + path.gsub(%r{^/+}, ''))
211
216
  end
212
217
  end
213
218
 
@@ -60,6 +60,8 @@ class Chef
60
60
 
61
61
  HOST_LOWER = "host".freeze
62
62
 
63
+ URI_SCHEME_DEFAULT_PORT = { 'http' => 80, 'https' => 443 }.freeze
64
+
63
65
  def self.user_agent=(ua)
64
66
  @user_agent = ua
65
67
  end
@@ -138,7 +140,13 @@ class Chef
138
140
  # No response compression unless we asked for it explicitly:
139
141
  @headers[HTTPRequest::ACCEPT_ENCODING] ||= "identity"
140
142
  @headers['X-Chef-Version'] = ::Chef::VERSION
141
- @headers['Host'] = "#{uri_safe_host}:#{port}" unless @headers.keys.any? {|k| k.downcase.to_s == HOST_LOWER }
143
+
144
+ # Only include port in Host header when it is not the default port
145
+ # for the url scheme (80;443) - Fixes CHEF-5355
146
+ host_header = uri_safe_host.dup
147
+ host_header << ":#{port}" unless URI_SCHEME_DEFAULT_PORT[@url.scheme] == port.to_i
148
+ @headers['Host'] = host_header unless @headers.keys.any? {|k| k.downcase.to_s == HOST_LOWER }
149
+
142
150
  @headers
143
151
  end
144
152
 
@@ -1,7 +1,8 @@
1
1
  require 'chef/http'
2
2
  require 'chef/http/authenticator'
3
3
  require 'chef/http/decompressor'
4
-
4
+ require 'chef/http/cookie_manager'
5
+ require 'chef/http/validate_content_length'
5
6
 
6
7
  class Chef
7
8
  class HTTP
@@ -17,8 +17,8 @@
17
17
 
18
18
  # Wrapper class for interacting with JSON.
19
19
 
20
- require 'json'
21
- require 'yajl'
20
+ require 'ffi_yajl'
21
+ require 'ffi_yajl/json_gem' # XXX: parts of chef require JSON gem's Hash#to_json monkeypatch
22
22
 
23
23
  class Chef
24
24
  class JSONCompat
@@ -40,20 +40,9 @@ class Chef
40
40
 
41
41
  class <<self
42
42
 
43
- # See CHEF-1292/PL-538. Increase the max nesting for JSON, which defaults
44
- # to 19, and isn't enough for some (for example, a Node within a Node)
45
- # structures.
46
- def opts_add_max_nesting(opts)
47
- if opts.nil? || !opts.has_key?(:max_nesting)
48
- opts = opts.nil? ? Hash.new : opts.clone
49
- opts[:max_nesting] = JSON_MAX_NESTING
50
- end
51
- opts
52
- end
53
-
54
43
  # Just call the JSON gem's parse method with a modified :max_nesting field
55
44
  def from_json(source, opts = {})
56
- obj = ::Yajl::Parser.parse(source)
45
+ obj = ::FFI_Yajl::Parser.parse(source)
57
46
 
58
47
  # JSON gem requires top level object to be a Hash or Array (otherwise
59
48
  # you get the "must contain two octets" error). Yajl doesn't impose the
@@ -99,11 +88,11 @@ class Chef
99
88
  end
100
89
 
101
90
  def to_json(obj, opts = nil)
102
- obj.to_json(opts_add_max_nesting(opts))
91
+ obj.to_json(opts)
103
92
  end
104
93
 
105
94
  def to_json_pretty(obj, opts = nil)
106
- ::JSON.pretty_generate(obj, opts_add_max_nesting(opts))
95
+ ::JSON.pretty_generate(obj, opts)
107
96
  end
108
97
 
109
98
 
@@ -239,6 +239,8 @@ class Chef
239
239
  if Array(@name_args).first.nil?
240
240
  ui.error("Must pass an FQDN or ip to bootstrap")
241
241
  exit 1
242
+ elsif Array(@name_args).first == "windows"
243
+ ui.warn("Hostname containing 'windows' specified. Please install 'knife-windows' if you are attempting to bootstrap a Windows node via WinRM.")
242
244
  end
243
245
  end
244
246
 
@@ -5,8 +5,8 @@ if [ ! -f /usr/bin/chef-client ]; then
5
5
  pacman -Syy
6
6
  pacman -S --noconfirm ruby ntp base-devel
7
7
  ntpdate -u pool.ntp.org
8
- gem install ohai --no-rdoc --no-ri --verbose
9
- gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
8
+ gem install ohai --no-user-install --no-document --verbose
9
+ gem install chef --no-user-install --no-document --verbose <%= bootstrap_version_string %>
10
10
  fi
11
11
 
12
12
  mkdir -p /etc/chef
@@ -16,6 +16,8 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
+ require 'ffi_yajl'
20
+
19
21
  class Chef
20
22
  class Knife
21
23
  module Core
@@ -83,7 +85,7 @@ class Chef
83
85
  def object_from_file(filename)
84
86
  case filename
85
87
  when /\.(js|json)$/
86
- r = Yajl::Parser.parse(IO.read(filename))
88
+ r = FFI_Yajl::Parser.parse(IO.read(filename))
87
89
 
88
90
  # Chef::DataBagItem doesn't work well with the json_create method
89
91
  if @klass == Chef::DataBagItem