chef 12.18.31-universal-mingw32 → 12.19.33-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -4
- data/README.md +12 -13
- data/VERSION +1 -1
- data/acceptance/Gemfile +4 -4
- data/acceptance/Gemfile.lock +70 -69
- data/chef-universal-mingw32.gemspec +2 -3
- data/chef.gemspec +6 -6
- data/lib/chef/api_client.rb +8 -10
- data/lib/chef/api_client_v1.rb +9 -11
- data/lib/chef/application/apply.rb +8 -10
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/exit_code.rb +3 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/windows_service.rb +29 -30
- data/lib/chef/application/windows_service_manager.rb +1 -1
- data/lib/chef/audit/audit_event_proxy.rb +2 -2
- data/lib/chef/audit/control_group_data.rb +1 -1
- data/lib/chef/chef_class.rb +1 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +5 -7
- data/lib/chef/chef_fs/command_line.rb +15 -16
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +2 -2
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +5 -6
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +8 -10
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +28 -30
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +27 -29
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +18 -24
- data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +10 -12
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +9 -13
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -0
- data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -0
- data/lib/chef/chef_fs/parallelizer.rb +9 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +25 -31
- data/lib/chef/cookbook/metadata.rb +26 -26
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +3 -3
- data/lib/chef/data_collector.rb +3 -4
- data/lib/chef/decorator.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/audit.rb +2 -2
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +29 -31
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/dsl/resources.rb +6 -8
- data/lib/chef/encrypted_data_bag_item.rb +2 -2
- data/lib/chef/environment.rb +9 -11
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_access_control/unix.rb +14 -14
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +4 -5
- data/lib/chef/formatters/error_mapper.rb +6 -6
- data/lib/chef/http/api_versions.rb +50 -0
- data/lib/chef/http/validate_content_length.rb +2 -2
- data/lib/chef/json_compat.rb +6 -10
- data/lib/chef/key.rb +5 -5
- data/lib/chef/knife.rb +4 -4
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -2
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/ui.rb +19 -25
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/deps.rb +32 -34
- data/lib/chef/knife/help.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/search.rb +2 -2
- data/lib/chef/knife/ssh.rb +37 -27
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/user_delete.rb +1 -1
- data/lib/chef/mash.rb +1 -1
- data/lib/chef/mixin/command.rb +2 -2
- data/lib/chef/mixin/create_path.rb +3 -5
- data/lib/chef/mixin/from_file.rb +2 -2
- data/lib/chef/mixin/get_source_from_package.rb +2 -2
- data/lib/chef/mixin/notifying_block.rb +7 -9
- data/lib/chef/mixin/params_validate.rb +3 -3
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +23 -3
- data/lib/chef/mixin/unformatter.rb +2 -2
- data/lib/chef/mixin/uris.rb +4 -6
- data/lib/chef/mixin/versioned_api.rb +69 -0
- data/lib/chef/mixin/which.rb +25 -8
- data/lib/chef/mixin/windows_architecture_helper.rb +2 -2
- data/lib/chef/mixin/xml_escape.rb +3 -5
- data/lib/chef/monkey_patches/webrick-utils.rb +1 -1
- data/lib/chef/node.rb +8 -8
- data/lib/chef/node/attribute.rb +4 -4
- data/lib/chef/node/common_api.rb +5 -7
- data/lib/chef/org.rb +10 -12
- data/lib/chef/platform/provider_mapping.rb +7 -7
- data/lib/chef/platform/query_helpers.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +31 -0
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/breakpoint.rb +1 -1
- data/lib/chef/provider/cookbook_file.rb +3 -3
- data/lib/chef/provider/cron.rb +38 -38
- data/lib/chef/provider/deploy.rb +81 -81
- data/lib/chef/provider/deploy/revision.rb +3 -5
- data/lib/chef/provider/directory.rb +32 -32
- data/lib/chef/provider/dsc_resource.rb +22 -6
- data/lib/chef/provider/env.rb +28 -28
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/erl_call.rb +13 -13
- data/lib/chef/provider/execute.rb +5 -2
- data/lib/chef/provider/file.rb +49 -51
- data/lib/chef/provider/git.rb +55 -55
- data/lib/chef/provider/http_request.rb +36 -36
- data/lib/chef/provider/launchd.rb +2 -2
- data/lib/chef/provider/link.rb +50 -50
- data/lib/chef/provider/log.rb +2 -2
- data/lib/chef/provider/mdadm.rb +25 -25
- data/lib/chef/provider/mount/aix.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/ohai.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +23 -23
- data/lib/chef/provider/package.rb +74 -56
- data/lib/chef/provider/package/aix.rb +55 -52
- data/lib/chef/provider/package/apt.rb +15 -13
- data/lib/chef/provider/package/cab.rb +49 -20
- data/lib/chef/provider/package/chocolatey.rb +9 -10
- data/lib/chef/provider/package/dnf.rb +20 -18
- data/lib/chef/provider/package/dnf/dnf_helper.py +1 -1
- data/lib/chef/provider/package/dnf/python_helper.rb +63 -26
- data/lib/chef/provider/package/dnf/version.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +8 -9
- data/lib/chef/provider/package/easy_install.rb +22 -22
- data/lib/chef/provider/package/freebsd/base.rb +10 -10
- data/lib/chef/provider/package/freebsd/pkg.rb +15 -15
- data/lib/chef/provider/package/freebsd/pkgng.rb +13 -15
- data/lib/chef/provider/package/freebsd/port.rb +7 -7
- data/lib/chef/provider/package/homebrew.rb +11 -10
- data/lib/chef/provider/package/ips.rb +18 -23
- data/lib/chef/provider/package/macports.rb +23 -23
- data/lib/chef/provider/package/msu.rb +11 -11
- data/lib/chef/provider/package/openbsd.rb +25 -22
- data/lib/chef/provider/package/pacman.rb +16 -16
- data/lib/chef/provider/package/paludis.rb +26 -27
- data/lib/chef/provider/package/portage.rb +22 -22
- data/lib/chef/provider/package/powershell.rb +17 -17
- data/lib/chef/provider/package/rpm.rb +25 -25
- data/lib/chef/provider/package/rubygems.rb +60 -60
- data/lib/chef/provider/package/smartos.rb +16 -16
- data/lib/chef/provider/package/solaris.rb +44 -44
- data/lib/chef/provider/package/windows.rb +3 -3
- data/lib/chef/provider/package/windows/exe.rb +6 -6
- data/lib/chef/provider/package/windows/msi.rb +6 -6
- data/lib/chef/provider/package/yum.rb +318 -268
- data/lib/chef/provider/package/yum/rpm_utils.rb +34 -34
- data/lib/chef/provider/package/yum/yum_cache.rb +12 -12
- data/lib/chef/provider/package/zypper.rb +11 -11
- data/lib/chef/provider/powershell_script.rb +15 -7
- data/lib/chef/provider/reboot.rb +10 -10
- data/lib/chef/provider/registry_key.rb +39 -39
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file.rb +3 -3
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/ruby_block.rb +3 -3
- data/lib/chef/provider/script.rb +42 -6
- data/lib/chef/provider/service.rb +49 -49
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +1 -1
- data/lib/chef/provider/subversion.rb +39 -39
- data/lib/chef/provider/systemd_unit.rb +2 -0
- data/lib/chef/provider/template.rb +3 -3
- data/lib/chef/provider/user.rb +42 -42
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +4 -4
- data/lib/chef/resource.rb +27 -16
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +6 -3
- data/lib/chef/resource/dsc_resource.rb +9 -1
- data/lib/chef/resource/execute.rb +70 -6
- data/lib/chef/resource/file/verification/systemd_unit.rb +67 -0
- data/lib/chef/resource/freebsd_package.rb +1 -1
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/launchd.rb +13 -1
- data/lib/chef/resource/package.rb +2 -2
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/yum_package.rb +12 -3
- data/lib/chef/resource/yum_repository.rb +0 -1
- data/lib/chef/resource_collection/resource_collection_serialization.rb +3 -3
- data/lib/chef/resource_collection/resource_set.rb +2 -2
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/run_list/run_list_item.rb +1 -1
- data/lib/chef/run_list/versioned_recipe_list.rb +6 -6
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/server_api_versions.rb +40 -0
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/shell/ext.rb +3 -3
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/user.rb +9 -11
- data/lib/chef/user_v1.rb +9 -11
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/net_group.rb +18 -30
- data/lib/chef/util/windows/net_use.rb +7 -11
- data/lib/chef/util/windows/net_user.rb +11 -17
- data/lib/chef/util/windows/volume.rb +9 -15
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/win32/api.rb +4 -6
- data/lib/chef/win32/api/file.rb +25 -31
- data/lib/chef/win32/api/installer.rb +2 -2
- data/lib/chef/win32/file.rb +4 -6
- data/lib/chef/win32/registry.rb +9 -9
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/acl.rb +2 -2
- data/lib/chef/win32/unicode.rb +2 -2
- data/lib/chef/win32/version.rb +1 -1
- data/spec/data/prefer_metadata_json/metadata.json +51 -0
- data/spec/data/prefer_metadata_json/metadata.rb +6 -0
- data/spec/data/prefer_metadata_json/recipes/default.rb +0 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/resource/batch_spec.rb +5 -1
- data/spec/functional/resource/dsc_script_spec.rb +2 -4
- data/spec/functional/resource/execute_spec.rb +17 -0
- data/spec/functional/resource/user/dscl_spec.rb +2 -4
- data/spec/integration/client/client_spec.rb +33 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +58 -58
- data/spec/spec_helper.rb +4 -0
- data/spec/support/chef_helpers.rb +5 -7
- data/spec/support/platform_helpers.rb +6 -0
- data/spec/support/platforms/prof/gc.rb +4 -6
- data/spec/support/shared/context/client.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +150 -0
- data/spec/support/shared/functional/windows_script.rb +74 -4
- data/spec/support/shared/unit/execute_resource.rb +37 -0
- data/spec/support/shared/unit/provider/file.rb +10 -0
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +9 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
- data/spec/unit/http/api_versions_spec.rb +69 -0
- data/spec/unit/knife/ssh_spec.rb +34 -36
- data/spec/unit/mixin/versioned_api_spec.rb +107 -0
- data/spec/unit/mixin/which.rb +160 -0
- data/spec/unit/platform_spec.rb +28 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +10 -0
- data/spec/unit/provider/dsc_resource_spec.rb +175 -0
- data/spec/unit/provider/execute_spec.rb +0 -1
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/package/aix_spec.rb +22 -22
- data/spec/unit/provider/package/apt_spec.rb +27 -27
- data/spec/unit/provider/package/cab_spec.rb +59 -5
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +29 -0
- data/spec/unit/provider/package/dpkg_spec.rb +16 -16
- data/spec/unit/provider/package/easy_install_spec.rb +18 -18
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +15 -15
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +9 -9
- data/spec/unit/provider/package/homebrew_spec.rb +9 -9
- data/spec/unit/provider/package/ips_spec.rb +37 -31
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +10 -10
- data/spec/unit/provider/package/pacman_spec.rb +6 -6
- data/spec/unit/provider/package/paludis_spec.rb +7 -7
- data/spec/unit/provider/package/portage_spec.rb +6 -7
- data/spec/unit/provider/package/rpm_spec.rb +23 -23
- data/spec/unit/provider/package/rubygems_spec.rb +38 -38
- data/spec/unit/provider/package/solaris_spec.rb +15 -15
- data/spec/unit/provider/package/windows_spec.rb +2 -1
- data/spec/unit/provider/package/yum_spec.rb +51 -43
- data/spec/unit/provider/package/zypper_spec.rb +34 -34
- data/spec/unit/provider/package_spec.rb +8 -0
- data/spec/unit/provider/remote_file/sftp_spec.rb +3 -3
- data/spec/unit/provider/route_spec.rb +7 -1
- data/spec/unit/provider/script_spec.rb +49 -6
- data/spec/unit/resource/dsc_resource_spec.rb +6 -0
- data/spec/unit/resource/execute_spec.rb +214 -0
- data/spec/unit/resource/file/verification/systemd_unit_spec.rb +103 -0
- data/spec/unit/resource/freebsd_package_spec.rb +2 -2
- data/spec/unit/resource/package_spec.rb +5 -0
- data/spec/unit/resource/yum_package_spec.rb +42 -1
- data/spec/unit/resource_reporter_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +18 -0
- data/spec/unit/server_api_versions_spec.rb +44 -0
- data/spec/unit/util/selinux_spec.rb +3 -14
- data/spec/unit/win32/error_spec.rb +67 -0
- data/spec/unit/win32/security_spec.rb +66 -0
- data/tasks/changelog.rb +1 -1
- data/tasks/dependencies.rb +20 -4
- metadata +39 -18
- data/lib/chef/monkey_patches/net-ssh-multi.rb +0 -141
@@ -121,8 +121,8 @@ class Chef::EncryptedDataBagItem
|
|
121
121
|
#
|
122
122
|
def self.load(data_bag, name, secret = nil)
|
123
123
|
raw_hash = Chef::DataBagItem.load(data_bag, name)
|
124
|
-
secret ||=
|
125
|
-
|
124
|
+
secret ||= load_secret
|
125
|
+
new(raw_hash, secret)
|
126
126
|
end
|
127
127
|
|
128
128
|
def self.load_secret(path = nil)
|
data/lib/chef/environment.rb
CHANGED
@@ -247,7 +247,7 @@ class Chef
|
|
247
247
|
if Chef::Config[:solo_legacy_mode]
|
248
248
|
load_from_file(name)
|
249
249
|
else
|
250
|
-
|
250
|
+
from_hash(chef_server_rest.get("environments/#{name}"))
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
@@ -309,17 +309,15 @@ class Chef
|
|
309
309
|
end
|
310
310
|
|
311
311
|
def self.validate_cookbook_version(version)
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
true
|
319
|
-
end
|
320
|
-
rescue ArgumentError
|
321
|
-
false
|
312
|
+
if Chef::Config[:solo_legacy_mode]
|
313
|
+
raise Chef::Exceptions::IllegalVersionConstraint,
|
314
|
+
"Environment cookbook version constraints not allowed in chef-solo"
|
315
|
+
else
|
316
|
+
Chef::VersionConstraint.new version
|
317
|
+
true
|
322
318
|
end
|
319
|
+
rescue ArgumentError
|
320
|
+
false
|
323
321
|
end
|
324
322
|
|
325
323
|
end
|
data/lib/chef/exceptions.rb
CHANGED
@@ -315,7 +315,7 @@ class Chef
|
|
315
315
|
|
316
316
|
def raise!
|
317
317
|
unless empty?
|
318
|
-
raise
|
318
|
+
raise for_raise
|
319
319
|
end
|
320
320
|
end
|
321
321
|
|
@@ -525,5 +525,8 @@ This error is most often caused by network issues (proxies, etc) outside of chef
|
|
525
525
|
super "Found multiple matching resources. #{matches_info.join("\n")}"
|
526
526
|
end
|
527
527
|
end
|
528
|
+
|
529
|
+
# exception specific to invalid usage of 'dsc_resource' resource
|
530
|
+
class DSCModuleNameMissing < ArgumentError; end
|
528
531
|
end
|
529
532
|
end
|
@@ -80,19 +80,19 @@ class Chef
|
|
80
80
|
if target_uid.nil?
|
81
81
|
# the user has not specified a permission on the new resource, so we never manage it with FAC
|
82
82
|
Chef::Log.debug("Found target_uid == nil, so no owner was specified on resource, not managing owner")
|
83
|
-
|
83
|
+
false
|
84
84
|
elsif current_uid.nil?
|
85
85
|
# the user has specified a permission, and we are creating a file, so always enforce permissions
|
86
86
|
Chef::Log.debug("Found current_uid == nil, so we are creating a new file, updating owner")
|
87
|
-
|
87
|
+
true
|
88
88
|
elsif target_uid != current_uid
|
89
89
|
# the user has specified a permission, and it does not match the file, so fix the permission
|
90
90
|
Chef::Log.debug("Found target_uid != current_uid, updating owner")
|
91
|
-
|
91
|
+
true
|
92
92
|
else
|
93
93
|
Chef::Log.debug("Found target_uid == current_uid, not updating owner")
|
94
94
|
# the user has specified a permission, but it matches the file, so behave idempotently
|
95
|
-
|
95
|
+
false
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -139,19 +139,19 @@ class Chef
|
|
139
139
|
if target_gid.nil?
|
140
140
|
# the user has not specified a permission on the new resource, so we never manage it with FAC
|
141
141
|
Chef::Log.debug("Found target_gid == nil, so no group was specified on resource, not managing group")
|
142
|
-
|
142
|
+
false
|
143
143
|
elsif current_gid.nil?
|
144
144
|
# the user has specified a permission, and we are creating a file, so always enforce permissions
|
145
145
|
Chef::Log.debug("Found current_gid == nil, so we are creating a new file, updating group")
|
146
|
-
|
146
|
+
true
|
147
147
|
elsif target_gid != current_gid
|
148
148
|
# the user has specified a permission, and it does not match the file, so fix the permission
|
149
149
|
Chef::Log.debug("Found target_gid != current_gid, updating group")
|
150
|
-
|
150
|
+
true
|
151
151
|
else
|
152
152
|
Chef::Log.debug("Found target_gid == current_gid, not updating group")
|
153
153
|
# the user has specified a permission, but it matches the file, so behave idempotently
|
154
|
-
|
154
|
+
false
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
@@ -188,21 +188,21 @@ class Chef
|
|
188
188
|
if target_mode.nil?
|
189
189
|
# the user has not specified a permission on the new resource, so we never manage it with FAC
|
190
190
|
Chef::Log.debug("Found target_mode == nil, so no mode was specified on resource, not managing mode")
|
191
|
-
|
191
|
+
false
|
192
192
|
elsif current_mode.nil?
|
193
193
|
# the user has specified a permission, and we are creating a file, so always enforce permissions
|
194
194
|
Chef::Log.debug("Found current_mode == nil, so we are creating a new file, updating mode")
|
195
|
-
|
195
|
+
true
|
196
196
|
elsif target_mode != current_mode
|
197
197
|
# the user has specified a permission, and it does not match the file, so fix the permission
|
198
198
|
Chef::Log.debug("Found target_mode != current_mode, updating mode")
|
199
|
-
|
199
|
+
true
|
200
200
|
elsif suid_bit_set? && (should_update_group? || should_update_owner?)
|
201
|
-
|
201
|
+
true
|
202
202
|
else
|
203
203
|
Chef::Log.debug("Found target_mode == current_mode, not updating mode")
|
204
204
|
# the user has specified a permission, but it matches the file, so behave idempotently
|
205
|
-
|
205
|
+
false
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
@@ -283,7 +283,7 @@ class Chef
|
|
283
283
|
end
|
284
284
|
|
285
285
|
def suid_bit_set?
|
286
|
-
|
286
|
+
target_mode & 04000 > 0
|
287
287
|
end
|
288
288
|
end
|
289
289
|
end
|
@@ -172,11 +172,10 @@ E
|
|
172
172
|
# .../lib/ruby/1.9.1/net/http.rb:2709:in `read_body'
|
173
173
|
# .../lib/ruby/1.9.1/net/http.rb:2736:in `body'
|
174
174
|
# .../lib/chef/formatters/error_inspectors/api_error_formatting.rb:91:in `rescue in format_rest_error'
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
end
|
175
|
+
|
176
|
+
exception.response.body
|
177
|
+
rescue Exception
|
178
|
+
"Cannot fetch the contents of the response."
|
180
179
|
end
|
181
180
|
|
182
181
|
end
|
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
headline = "Chef encountered an error attempting to create the client \"#{node_name}\""
|
31
31
|
description = ErrorDescription.new(headline)
|
32
32
|
error_inspector.add_explanation(description)
|
33
|
-
|
33
|
+
description
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.node_load_failed(node_name, exception, config)
|
@@ -38,7 +38,7 @@ class Chef
|
|
38
38
|
headline = "Chef encountered an error attempting to load the node data for \"#{node_name}\""
|
39
39
|
description = ErrorDescription.new(headline)
|
40
40
|
error_inspector.add_explanation(description)
|
41
|
-
|
41
|
+
description
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.run_list_expand_failed(node, exception)
|
@@ -46,7 +46,7 @@ class Chef
|
|
46
46
|
headline = "Error expanding the run_list:"
|
47
47
|
description = ErrorDescription.new(headline)
|
48
48
|
error_inspector.add_explanation(description)
|
49
|
-
|
49
|
+
description
|
50
50
|
end
|
51
51
|
|
52
52
|
def self.cookbook_resolution_failed(expanded_run_list, exception)
|
@@ -54,7 +54,7 @@ class Chef
|
|
54
54
|
headline = "Error Resolving Cookbooks for Run List:"
|
55
55
|
description = ErrorDescription.new(headline)
|
56
56
|
error_inspector.add_explanation(description)
|
57
|
-
|
57
|
+
description
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.cookbook_sync_failed(cookbooks, exception)
|
@@ -62,7 +62,7 @@ class Chef
|
|
62
62
|
headline = "Error Syncing Cookbooks:"
|
63
63
|
description = ErrorDescription.new(headline)
|
64
64
|
error_inspector.add_explanation(description)
|
65
|
-
|
65
|
+
description
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.resource_failed(resource, action, exception)
|
@@ -70,7 +70,7 @@ class Chef
|
|
70
70
|
headline = "Error executing action `#{action}` on resource '#{resource}'"
|
71
71
|
description = ErrorDescription.new(headline)
|
72
72
|
error_inspector.add_explanation(description)
|
73
|
-
|
73
|
+
description
|
74
74
|
end
|
75
75
|
|
76
76
|
def self.file_load_failed(path, exception)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright:: Copyright 2017, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "chef/server_api_versions"
|
19
|
+
|
20
|
+
class Chef
|
21
|
+
class HTTP
|
22
|
+
# An HTTP middleware to retrieve and store the Chef Server's minimum
|
23
|
+
# and maximum supported API versions.
|
24
|
+
class APIVersions
|
25
|
+
|
26
|
+
def initialize(options = {})
|
27
|
+
end
|
28
|
+
|
29
|
+
def handle_request(method, url, headers = {}, data = false)
|
30
|
+
[method, url, headers, data]
|
31
|
+
end
|
32
|
+
|
33
|
+
def handle_response(http_response, rest_request, return_value)
|
34
|
+
if http_response.key?("x-ops-server-api-version")
|
35
|
+
ServerAPIVersions.instance.set_versions(http_response["x-ops-server-api-version"])
|
36
|
+
end
|
37
|
+
[http_response, rest_request, return_value]
|
38
|
+
end
|
39
|
+
|
40
|
+
def stream_response_handler(response)
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def handle_stream_complete(http_response, rest_request, return_value)
|
45
|
+
[http_response, rest_request, return_value]
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -50,7 +50,7 @@ class Chef
|
|
50
50
|
|
51
51
|
def handle_response(http_response, rest_request, return_value)
|
52
52
|
validate(http_response, http_response.body.bytesize) if http_response && http_response.body
|
53
|
-
|
53
|
+
[http_response, rest_request, return_value]
|
54
54
|
end
|
55
55
|
|
56
56
|
def handle_stream_complete(http_response, rest_request, return_value)
|
@@ -63,7 +63,7 @@ class Chef
|
|
63
63
|
# Make sure the counter is reset since this object might get used
|
64
64
|
# again. See CHEF-5100
|
65
65
|
@content_length_counter = nil
|
66
|
-
|
66
|
+
[http_response, rest_request, return_value]
|
67
67
|
end
|
68
68
|
|
69
69
|
def stream_response_handler(response)
|
data/lib/chef/json_compat.rb
CHANGED
@@ -47,11 +47,9 @@ class Chef
|
|
47
47
|
|
48
48
|
# API to use to avoid create_addtions
|
49
49
|
def parse(source, opts = {})
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
raise Chef::Exceptions::JSON::ParseError, e.message
|
54
|
-
end
|
50
|
+
FFI_Yajl::Parser.parse(source, opts)
|
51
|
+
rescue FFI_Yajl::ParseError => e
|
52
|
+
raise Chef::Exceptions::JSON::ParseError, e.message
|
55
53
|
end
|
56
54
|
|
57
55
|
# Just call the JSON gem's parse method with a modified :max_nesting field
|
@@ -102,11 +100,9 @@ class Chef
|
|
102
100
|
end
|
103
101
|
|
104
102
|
def to_json(obj, opts = nil)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
raise Chef::Exceptions::JSON::EncodeError, e.message
|
109
|
-
end
|
103
|
+
FFI_Yajl::Encoder.encode(obj, opts)
|
104
|
+
rescue FFI_Yajl::EncodeError => e
|
105
|
+
raise Chef::Exceptions::JSON::EncodeError, e.message
|
110
106
|
end
|
111
107
|
|
112
108
|
def to_json_pretty(obj, opts = nil)
|
data/lib/chef/key.rb
CHANGED
@@ -155,7 +155,7 @@ class Chef
|
|
155
155
|
result = chef_rest.post("#{api_base}/#{@actor}/keys", payload)
|
156
156
|
# append the private key to the current key if the server returned one,
|
157
157
|
# since the POST endpoint just returns uri and private_key if needed.
|
158
|
-
new_key =
|
158
|
+
new_key = to_hash
|
159
159
|
new_key["private_key"] = result["private_key"] if result["private_key"]
|
160
160
|
Chef::Key.from_hash(new_key)
|
161
161
|
end
|
@@ -178,9 +178,9 @@ class Chef
|
|
178
178
|
new_key = chef_rest.put("#{api_base}/#{@actor}/keys/#{put_name}", to_hash)
|
179
179
|
# if the server returned a public_key, remove the create_key field, as we now have a key
|
180
180
|
if new_key["public_key"]
|
181
|
-
|
181
|
+
delete_create_key
|
182
182
|
end
|
183
|
-
Chef::Key.from_hash(
|
183
|
+
Chef::Key.from_hash(to_hash.merge(new_key))
|
184
184
|
end
|
185
185
|
|
186
186
|
def save
|
@@ -229,12 +229,12 @@ class Chef
|
|
229
229
|
|
230
230
|
def list_by_user(actor, inflate = false)
|
231
231
|
keys = Chef::ServerAPI.new(Chef::Config[:chef_server_root]).get("users/#{actor}/keys")
|
232
|
-
|
232
|
+
list(keys, actor, :load_by_user, inflate)
|
233
233
|
end
|
234
234
|
|
235
235
|
def list_by_client(actor, inflate = false)
|
236
236
|
keys = Chef::ServerAPI.new(Chef::Config[:chef_server_url]).get("clients/#{actor}/keys")
|
237
|
-
|
237
|
+
list(keys, actor, :load_by_client, inflate)
|
238
238
|
end
|
239
239
|
|
240
240
|
def load_by_user(actor, key_name)
|
data/lib/chef/knife.rb
CHANGED
@@ -430,11 +430,11 @@ class Chef
|
|
430
430
|
end
|
431
431
|
|
432
432
|
def show_usage
|
433
|
-
stdout.puts("USAGE: " +
|
433
|
+
stdout.puts("USAGE: " + opt_parser.to_s)
|
434
434
|
end
|
435
435
|
|
436
436
|
def run_with_pretty_exceptions(raise_exception = false)
|
437
|
-
unless
|
437
|
+
unless respond_to?(:run)
|
438
438
|
ui.error "You need to add a #run method to your knife command before you can use it"
|
439
439
|
end
|
440
440
|
enforce_path_sanity
|
@@ -553,7 +553,7 @@ class Chef
|
|
553
553
|
|
554
554
|
pretty_name ||= output
|
555
555
|
|
556
|
-
|
556
|
+
msg("Created #{pretty_name}")
|
557
557
|
|
558
558
|
output(output) if config[:print_after]
|
559
559
|
end
|
@@ -572,7 +572,7 @@ class Chef
|
|
572
572
|
output(format_for_display(object)) if config[:print_after]
|
573
573
|
|
574
574
|
obj_name = delete_name ? "#{delete_name}[#{name}]" : object
|
575
|
-
|
575
|
+
msg("Deleted #{obj_name}")
|
576
576
|
end
|
577
577
|
|
578
578
|
# helper method for testing if a field exists
|
@@ -161,9 +161,9 @@ class Chef
|
|
161
161
|
def convert_path(upstream_file)
|
162
162
|
# converts a Windows path (C:\foo) to a mingw path (/c/foo)
|
163
163
|
if ENV["MSYSTEM"] == "MINGW32"
|
164
|
-
|
164
|
+
upstream_file.sub(/^([[:alpha:]]):/, '/\1')
|
165
165
|
else
|
166
|
-
|
166
|
+
Shellwords.escape upstream_file
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -131,9 +131,9 @@ class Chef
|
|
131
131
|
|
132
132
|
def git_repo?(directory)
|
133
133
|
if File.directory?(File.join(directory, ".git"))
|
134
|
-
|
134
|
+
true
|
135
135
|
elsif File.dirname(directory) == directory
|
136
|
-
|
136
|
+
false
|
137
137
|
else
|
138
138
|
git_repo?(File.dirname(directory))
|
139
139
|
end
|