chef 18.10.17 → 19.1.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +24 -18
- data/README.md +6 -2
- data/Rakefile +1 -12
- data/chef-universal-mingw-ucrt.gemspec +1 -1
- data/chef.gemspec +17 -19
- data/lib/chef/action_collection.rb +3 -1
- data/lib/chef/api_client/registration.rb +1 -1
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/api_client_v1.rb +1 -1
- data/lib/chef/application/apply.rb +30 -3
- data/lib/chef/application/base.rb +34 -3
- data/lib/chef/application/client.rb +15 -1
- data/lib/chef/application/exit_code.rb +3 -1
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/application.rb +6 -1
- data/lib/chef/chef_class.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +7 -6
- data/lib/chef/chef_fs/config.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbooks_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/policies_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/policy_groups_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/exceptions.rb +1 -1
- data/lib/chef/chef_fs/file_system/nonexistent_fs_object.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/acl.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/acls_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/acls_sub_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +7 -6
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/client.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/client_key.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/client_keys_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/client_keys_sub_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/clients_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/container.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/containers_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/cookbook_artifacts_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/data_bag.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/data_bag_item.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/data_bags_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/environment.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/group.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/groups_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/node.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/policies_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/policy.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/policy_group.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/policy_groups_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/role.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/roles_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/user.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/users_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/versioned_cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system_cache.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +1 -1
- data/lib/chef/client.rb +13 -3
- data/lib/chef/compliance/default_attributes.rb +1 -1
- data/lib/chef/compliance/fetcher/chef_server.rb +1 -1
- data/lib/chef/compliance/input.rb +1 -1
- data/lib/chef/compliance/input_collection.rb +1 -1
- data/lib/chef/compliance/profile.rb +1 -1
- data/lib/chef/compliance/profile_collection.rb +1 -1
- data/lib/chef/compliance/runner.rb +19 -1
- data/lib/chef/compliance/waiver.rb +1 -1
- data/lib/chef/compliance/waiver_collection.rb +1 -1
- data/lib/chef/config.rb +1 -1
- data/lib/chef/constants.rb +1 -1
- data/lib/chef/context.rb +53 -0
- data/lib/chef/cookbook/chefignore.rb +2 -2
- data/lib/chef/cookbook/cookbook_collection.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +2 -1
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook/file_vendor.rb +1 -1
- data/lib/chef/cookbook/gem_installer.rb +1 -1
- data/lib/chef/cookbook/manifest_v0.rb +1 -1
- data/lib/chef/cookbook/manifest_v2.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +5 -0
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/daemon.rb +1 -1
- data/lib/chef/data_bag.rb +3 -3
- data/lib/chef/data_bag_item.rb +2 -2
- data/lib/chef/data_collector/config_validation.rb +1 -1
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/data_collector/message_helpers.rb +1 -1
- data/lib/chef/data_collector/run_end_message.rb +1 -1
- data/lib/chef/data_collector/run_start_message.rb +2 -2
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/decorator/lazy.rb +1 -1
- data/lib/chef/decorator/lazy_array.rb +1 -1
- data/lib/chef/decorator.rb +1 -1
- data/lib/chef/delayed_evaluator.rb +1 -1
- data/lib/chef/deprecated.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +1 -1
- data/lib/chef/digester.rb +1 -1
- data/lib/chef/dsl/chef_vault.rb +2 -2
- data/lib/chef/dsl/cheffish.rb +1 -1
- data/lib/chef/dsl/compliance.rb +1 -1
- data/lib/chef/dsl/data_query.rb +1 -1
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/dsl/include_attribute.rb +1 -1
- data/lib/chef/dsl/include_recipe.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +1 -1
- data/lib/chef/dsl/powershell.rb +1 -1
- data/lib/chef/dsl/reader_helpers.rb +3 -1
- data/lib/chef/dsl/reboot_pending.rb +1 -1
- data/lib/chef/dsl/recipe.rb +1 -1
- data/lib/chef/dsl/registry_helper.rb +1 -1
- data/lib/chef/dsl/render_helpers.rb +1 -1
- data/lib/chef/dsl/resources.rb +1 -1
- data/lib/chef/dsl/rest_resource.rb +165 -5
- data/lib/chef/dsl/secret.rb +1 -1
- data/lib/chef/dsl/universal.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/check_encrypted.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryption_failure.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/unacceptable_encrypted_data_bag_item_format.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/unsupported_cipher.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/unsupported_encrypted_data_bag_item_format.rb +1 -1
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/event_loggers/base.rb +1 -1
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/exceptions.rb +2 -12
- data/lib/chef/file_access_control/unix.rb +10 -10
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/file_access_control.rb +1 -1
- data/lib/chef/file_cache.rb +1 -1
- data/lib/chef/file_content_management/content_base.rb +1 -1
- data/lib/chef/file_content_management/deploy/cp.rb +1 -1
- data/lib/chef/file_content_management/deploy/mv_unix.rb +1 -1
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/file_content_management/deploy/target_io.rb +27 -0
- data/lib/chef/file_content_management/deploy.rb +5 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +1 -1
- data/lib/chef/formatters/error_description.rb +1 -1
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +1 -1
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +3 -2
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +3 -2
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_mapper.rb +1 -1
- data/lib/chef/group.rb +1 -1
- data/lib/chef/guard_interpreter/default_guard_interpreter.rb +1 -1
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +1 -1
- data/lib/chef/guard_interpreter.rb +1 -1
- data/lib/chef/handler/error_report.rb +1 -1
- data/lib/chef/handler/json_file.rb +1 -1
- data/lib/chef/handler/slow_report.rb +1 -1
- data/lib/chef/handler.rb +1 -1
- data/lib/chef/http/api_versions.rb +1 -1
- data/lib/chef/http/auth_credentials.rb +1 -1
- data/lib/chef/http/authenticator.rb +10 -10
- data/lib/chef/http/basic_client.rb +1 -2
- data/lib/chef/http/cookie_jar.rb +1 -1
- data/lib/chef/http/cookie_manager.rb +1 -1
- data/lib/chef/http/decompressor.rb +1 -1
- data/lib/chef/http/http_request.rb +17 -16
- data/lib/chef/http/json_input.rb +1 -1
- data/lib/chef/http/json_output.rb +1 -1
- data/lib/chef/http/json_to_model_output.rb +1 -1
- data/lib/chef/http/remote_request_id.rb +1 -1
- data/lib/chef/http/simple.rb +1 -1
- data/lib/chef/http/simple_json.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/http/ssl_policies.rb +1 -1
- data/lib/chef/http/validate_content_length.rb +1 -1
- data/lib/chef/http.rb +1 -2
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/key.rb +1 -1
- data/lib/chef/licensing.rb +105 -0
- data/lib/chef/licensing_config.rb +20 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/log/syslog.rb +1 -1
- data/lib/chef/log/winevt.rb +1 -1
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mash.rb +1 -1
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/mixin/checksum.rb +1 -1
- data/lib/chef/mixin/chef_utils_wiring.rb +1 -1
- data/lib/chef/mixin/convert_to_class_name.rb +1 -1
- data/lib/chef/mixin/create_path.rb +1 -1
- data/lib/chef/mixin/deep_merge.rb +1 -1
- data/lib/chef/mixin/default_paths.rb +1 -1
- data/lib/chef/mixin/deprecation.rb +1 -1
- data/lib/chef/mixin/enforce_ownership_and_permissions.rb +1 -1
- data/lib/chef/mixin/file_class.rb +4 -2
- data/lib/chef/mixin/from_file.rb +1 -1
- data/lib/chef/mixin/get_source_from_package.rb +2 -2
- data/lib/chef/mixin/homebrew.rb +3 -4
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/notifying_block.rb +1 -1
- data/lib/chef/mixin/openssl_helper.rb +1 -1
- data/lib/chef/mixin/params_validate.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +1 -1
- data/lib/chef/mixin/powershell_exec.rb +1 -1
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
- data/lib/chef/mixin/proxified_socket.rb +1 -1
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/subclass_directive.rb +1 -1
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/unformatter.rb +1 -1
- data/lib/chef/mixin/uris.rb +1 -1
- data/lib/chef/mixin/user_context.rb +1 -1
- data/lib/chef/mixin/versioned_api.rb +1 -1
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/mixin/why_run.rb +1 -1
- data/lib/chef/mixin/wide_string.rb +1 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +1 -1
- data/lib/chef/mixin/windows_env_helper.rb +1 -1
- data/lib/chef/mixin/xml_escape.rb +1 -1
- data/lib/chef/monkey_patches/net-http.rb +10 -11
- data/lib/chef/monkey_patches/win32/registry.rb +1 -1
- data/lib/chef/node/attribute.rb +1 -1
- data/lib/chef/node/attribute_collections.rb +1 -1
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +1 -1
- data/lib/chef/node/mixin/deep_merge_cache.rb +1 -1
- data/lib/chef/node/mixin/immutablize_array.rb +27 -1
- data/lib/chef/node/mixin/immutablize_hash.rb +36 -1
- data/lib/chef/node/mixin/mashy_array.rb +1 -1
- data/lib/chef/node/mixin/state_tracking.rb +1 -1
- data/lib/chef/node/mixin/state_tracking_array.rb +1 -1
- data/lib/chef/node.rb +1 -1
- data/lib/chef/node_map.rb +15 -3
- data/lib/chef/null_logger.rb +1 -1
- data/lib/chef/org.rb +1 -1
- data/lib/chef/platform/priority_map.rb +1 -1
- data/lib/chef/platform/provider_handler_map.rb +1 -1
- data/lib/chef/platform/provider_mapping.rb +1 -1
- data/lib/chef/platform/query_helpers.rb +1 -1
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/resource_handler_map.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +1 -1
- data/lib/chef/platform.rb +1 -1
- data/lib/chef/policy_builder/dynamic.rb +1 -1
- data/lib/chef/policy_builder/expand_node_object.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/policy_builder.rb +1 -1
- data/lib/chef/property.rb +3 -3
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/cookbook_file/content.rb +1 -1
- data/lib/chef/provider/cookbook_file.rb +2 -2
- data/lib/chef/provider/cron/aix.rb +1 -1
- data/lib/chef/provider/cron/solaris.rb +1 -1
- data/lib/chef/provider/cron.rb +15 -5
- data/lib/chef/provider/directory.rb +18 -18
- data/lib/chef/provider/dsc_resource.rb +1 -1
- data/lib/chef/provider/dsc_script.rb +1 -1
- data/lib/chef/provider/execute.rb +3 -2
- data/lib/chef/provider/file/content.rb +1 -1
- data/lib/chef/provider/file.rb +43 -30
- data/lib/chef/provider/git.rb +10 -10
- data/lib/chef/provider/group/aix.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +2 -2
- data/lib/chef/provider/group/gpasswd.rb +3 -3
- data/lib/chef/provider/group/groupadd.rb +2 -2
- data/lib/chef/provider/group/groupmod.rb +3 -3
- data/lib/chef/provider/group/pw.rb +3 -3
- data/lib/chef/provider/group/solaris.rb +3 -3
- data/lib/chef/provider/group/usermod.rb +3 -3
- data/lib/chef/provider/group.rb +2 -2
- data/lib/chef/provider/http_request.rb +3 -4
- data/lib/chef/provider/ifconfig/aix.rb +2 -2
- data/lib/chef/provider/ifconfig/debian.rb +3 -3
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +1 -1
- data/lib/chef/provider/link.rb +22 -11
- data/lib/chef/provider/lwrp_base.rb +1 -1
- data/lib/chef/provider/mount/aix.rb +5 -5
- data/lib/chef/provider/mount/linux.rb +4 -4
- data/lib/chef/provider/mount/mount.rb +12 -12
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/mount/windows.rb +3 -3
- data/lib/chef/provider/mount.rb +1 -1
- data/lib/chef/provider/noop.rb +1 -1
- data/lib/chef/provider/package/apt.rb +1 -1
- data/lib/chef/provider/package/bff.rb +4 -4
- data/lib/chef/provider/package/cab.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +20 -79
- data/lib/chef/provider/package/deb.rb +1 -1
- data/lib/chef/provider/package/dnf/python_helper.rb +3 -3
- data/lib/chef/provider/package/dnf/version.rb +1 -1
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +6 -6
- data/lib/chef/provider/package/freebsd/base.rb +1 -1
- data/lib/chef/provider/package/habitat.rb +6 -6
- data/lib/chef/provider/package/homebrew.rb +1 -1
- data/lib/chef/provider/package/ips.rb +3 -3
- data/lib/chef/provider/package/msu.rb +1 -1
- data/lib/chef/provider/package/openbsd.rb +3 -2
- data/lib/chef/provider/package/pacman.rb +4 -4
- data/lib/chef/provider/package/paludis.rb +3 -3
- data/lib/chef/provider/package/portage.rb +3 -3
- data/lib/chef/provider/package/powershell.rb +1 -1
- data/lib/chef/provider/package/rpm.rb +3 -3
- data/lib/chef/provider/package/rubygems.rb +21 -28
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/package/snap.rb +19 -7
- data/lib/chef/provider/package/snap_tm.rb +79 -0
- data/lib/chef/provider/package/solaris.rb +5 -5
- data/lib/chef/provider/package/windows/exe.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +1 -1
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/windows.rb +1 -1
- data/lib/chef/provider/package/yum/python_helper.rb +1 -1
- data/lib/chef/provider/package/yum/rpm_utils.rb +1 -1
- data/lib/chef/provider/package/yum/version.rb +1 -1
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/package/yum_tm.rb +132 -0
- data/lib/chef/provider/package/zypper/version.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +5 -5
- data/lib/chef/provider/package.rb +2 -2
- data/lib/chef/provider/powershell_script.rb +85 -85
- data/lib/chef/provider/registry_key.rb +2 -1
- data/lib/chef/provider/remote_directory.rb +6 -6
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
- data/lib/chef/provider/remote_file/content.rb +1 -1
- data/lib/chef/provider/remote_file/fetcher.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +2 -3
- data/lib/chef/provider/remote_file.rb +2 -2
- data/lib/chef/provider/route.rb +10 -10
- data/lib/chef/provider/ruby_block.rb +1 -1
- data/lib/chef/provider/script.rb +8 -8
- data/lib/chef/provider/service/aix.rb +2 -2
- data/lib/chef/provider/service/aixinit.rb +6 -6
- data/lib/chef/provider/service/arch.rb +6 -6
- data/lib/chef/provider/service/debian.rb +8 -8
- data/lib/chef/provider/service/freebsd.rb +7 -7
- data/lib/chef/provider/service/gentoo.rb +6 -6
- data/lib/chef/provider/service/init.rb +3 -3
- data/lib/chef/provider/service/insserv.rb +3 -3
- data/lib/chef/provider/service/invokercd.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +1 -1
- data/lib/chef/provider/service/openbsd.rb +7 -7
- data/lib/chef/provider/service/redhat.rb +6 -6
- data/lib/chef/provider/service/solaris.rb +3 -3
- data/lib/chef/provider/service/systemd.rb +3 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/service.rb +1 -1
- data/lib/chef/provider/subversion.rb +10 -10
- data/lib/chef/provider/systemd_unit.rb +3 -3
- data/lib/chef/provider/template/content.rb +1 -1
- data/lib/chef/provider/template.rb +2 -2
- data/lib/chef/provider/template_finder.rb +1 -1
- data/lib/chef/provider/user/aix.rb +4 -4
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/user/linux.rb +8 -3
- data/lib/chef/provider/user/mac.rb +2 -2
- data/lib/chef/provider/user/pw.rb +4 -4
- data/lib/chef/provider/user/solaris.rb +8 -8
- data/lib/chef/provider/user.rb +7 -4
- data/lib/chef/provider/windows_script.rb +2 -2
- data/lib/chef/provider/yum_repository.rb +2 -4
- data/lib/chef/provider/zypper_repository.rb +2 -2
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/providers.rb +3 -1
- data/lib/chef/pwsh.rb +1 -1
- data/lib/chef/recipe.rb +9 -6
- data/lib/chef/request_id.rb +1 -1
- data/lib/chef/resource/_rest_resource.rb +156 -11
- data/lib/chef/resource/action_class.rb +1 -1
- data/lib/chef/resource/alternatives.rb +44 -43
- data/lib/chef/resource/apt_package.rb +38 -33
- data/lib/chef/resource/apt_preference.rb +25 -24
- data/lib/chef/resource/apt_repository.rb +16 -11
- data/lib/chef/resource/apt_update.rb +5 -4
- data/lib/chef/resource/archive_file.rb +21 -21
- data/lib/chef/resource/bash.rb +132 -131
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +18 -17
- data/lib/chef/resource/breakpoint.rb +46 -45
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/cab_package.rb +23 -23
- data/lib/chef/resource/chef_client_config.rb +73 -72
- data/lib/chef/resource/chef_client_cron.rb +21 -19
- data/lib/chef/resource/chef_client_hab_ca_cert.rb +141 -0
- data/lib/chef/resource/chef_client_launchd.rb +6 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +35 -32
- data/lib/chef/resource/chef_client_systemd_timer.rb +21 -18
- data/lib/chef/resource/chef_client_trusted_certificate.rb +29 -29
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/chef_handler.rb +108 -108
- data/lib/chef/resource/chef_sleep.rb +3 -2
- data/lib/chef/resource/chef_vault_secret.rb +1 -1
- data/lib/chef/resource/chocolatey_config.rb +15 -15
- data/lib/chef/resource/chocolatey_feature.rb +2 -2
- data/lib/chef/resource/chocolatey_installer.rb +32 -47
- data/lib/chef/resource/chocolatey_package.rb +1 -1
- data/lib/chef/resource/chocolatey_source.rb +16 -16
- data/lib/chef/resource/conditional.rb +1 -1
- data/lib/chef/resource/cookbook_file.rb +3 -2
- data/lib/chef/resource/cron/_cron_shared.rb +1 -1
- data/lib/chef/resource/cron/cron.rb +72 -71
- data/lib/chef/resource/cron/cron_d.rb +3 -2
- data/lib/chef/resource/cron_access.rb +3 -2
- data/lib/chef/resource/csh.rb +3 -2
- data/lib/chef/resource/directory.rb +4 -3
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +2 -2
- data/lib/chef/resource/dpkg_package.rb +9 -6
- data/lib/chef/resource/dsc_resource.rb +1 -1
- data/lib/chef/resource/dsc_script.rb +1 -1
- data/lib/chef/resource/execute.rb +8 -1
- data/lib/chef/resource/file/verification/json.rb +1 -1
- data/lib/chef/resource/file/verification/systemd_unit.rb +5 -2
- data/lib/chef/resource/file/verification/yaml.rb +2 -2
- data/lib/chef/resource/file/verification.rb +4 -1
- data/lib/chef/resource/file.rb +3 -2
- data/lib/chef/resource/freebsd_package.rb +4 -3
- data/lib/chef/resource/gem_package.rb +1 -1
- data/lib/chef/resource/group.rb +33 -30
- data/lib/chef/resource/habitat/_habitat_shared.rb +1 -1
- data/lib/chef/resource/habitat/habitat_package.rb +83 -81
- data/lib/chef/resource/habitat/habitat_sup.rb +96 -95
- data/lib/chef/resource/habitat/habitat_sup_systemd.rb +14 -13
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +5 -4
- data/lib/chef/resource/habitat_config.rb +37 -23
- data/lib/chef/resource/habitat_install.rb +22 -22
- data/lib/chef/resource/habitat_service.rb +9 -5
- data/lib/chef/resource/habitat_user_toml.rb +12 -12
- data/lib/chef/resource/helpers/cron_validations.rb +1 -1
- data/lib/chef/resource/helpers/path_helpers.rb +52 -0
- data/lib/chef/resource/homebrew_cask.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +21 -21
- data/lib/chef/resource/homebrew_tap.rb +10 -2
- data/lib/chef/resource/homebrew_update.rb +1 -1
- data/lib/chef/resource/hostname.rb +14 -11
- data/lib/chef/resource/http_request.rb +5 -4
- data/lib/chef/resource/ifconfig.rb +36 -35
- data/lib/chef/resource/inspec_input.rb +42 -39
- data/lib/chef/resource/inspec_waiver.rb +66 -65
- data/lib/chef/resource/inspec_waiver_file_entry.rb +28 -27
- data/lib/chef/resource/ips_package.rb +4 -3
- data/lib/chef/resource/kernel_module.rb +4 -3
- data/lib/chef/resource/ksh.rb +3 -2
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/link.rb +4 -3
- data/lib/chef/resource/locale.rb +11 -10
- data/lib/chef/resource/log.rb +3 -1
- data/lib/chef/resource/lwrp_base.rb +1 -1
- data/lib/chef/resource/macos_pkg.rb +1 -1
- data/lib/chef/resource/macos_userdefaults.rb +1 -1
- data/lib/chef/resource/macports_package.rb +1 -1
- data/lib/chef/resource/mdadm.rb +33 -33
- data/lib/chef/resource/mount.rb +7 -5
- data/lib/chef/resource/msu_package.rb +2 -2
- data/lib/chef/resource/notify_group.rb +3 -2
- data/lib/chef/resource/ohai.rb +37 -36
- data/lib/chef/resource/ohai_hint.rb +27 -26
- data/lib/chef/resource/openbsd_package.rb +4 -3
- data/lib/chef/resource/openssl_dhparam.rb +1 -1
- data/lib/chef/resource/openssl_ec_private_key.rb +1 -1
- data/lib/chef/resource/openssl_ec_public_key.rb +1 -1
- data/lib/chef/resource/openssl_rsa_private_key.rb +1 -1
- data/lib/chef/resource/openssl_rsa_public_key.rb +1 -1
- data/lib/chef/resource/openssl_x509_certificate.rb +6 -2
- data/lib/chef/resource/openssl_x509_crl.rb +16 -16
- data/lib/chef/resource/openssl_x509_request.rb +2 -2
- data/lib/chef/resource/package.rb +4 -3
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +3 -2
- data/lib/chef/resource/perl.rb +3 -2
- data/lib/chef/resource/plist.rb +4 -4
- data/lib/chef/resource/portage_package.rb +3 -2
- data/lib/chef/resource/powershell_package.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +11 -11
- data/lib/chef/resource/powershell_script.rb +1 -1
- data/lib/chef/resource/python.rb +3 -2
- data/lib/chef/resource/reboot.rb +3 -2
- data/lib/chef/resource/registry_key.rb +78 -83
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +74 -73
- data/lib/chef/resource/resource_notification.rb +1 -1
- data/lib/chef/resource/rhsm_errata.rb +3 -2
- data/lib/chef/resource/rhsm_errata_level.rb +3 -2
- data/lib/chef/resource/rhsm_register.rb +13 -4
- data/lib/chef/resource/rhsm_repo.rb +5 -5
- data/lib/chef/resource/rhsm_subscription.rb +10 -10
- data/lib/chef/resource/route.rb +2 -1
- data/lib/chef/resource/rpm_package.rb +3 -2
- data/lib/chef/resource/ruby.rb +4 -2
- data/lib/chef/resource/ruby_block.rb +3 -1
- data/lib/chef/resource/scm/_scm.rb +1 -1
- data/lib/chef/resource/scm/git.rb +82 -81
- data/lib/chef/resource/scm/subversion.rb +12 -11
- data/lib/chef/resource/script.rb +4 -2
- data/lib/chef/resource/selinux/common_helpers.rb +1 -1
- data/lib/chef/resource/selinux/selinux_debian.erb +1 -1
- data/lib/chef/resource/selinux/selinux_default.erb +1 -1
- data/lib/chef/resource/selinux_boolean.rb +14 -13
- data/lib/chef/resource/selinux_fcontext.rb +23 -22
- data/lib/chef/resource/selinux_install.rb +20 -19
- data/lib/chef/resource/selinux_login.rb +13 -12
- data/lib/chef/resource/selinux_module.rb +20 -19
- data/lib/chef/resource/selinux_permissive.rb +10 -9
- data/lib/chef/resource/selinux_port.rb +17 -16
- data/lib/chef/resource/selinux_state.rb +29 -28
- data/lib/chef/resource/selinux_user.rb +16 -15
- data/lib/chef/resource/service.rb +9 -6
- data/lib/chef/resource/smartos_package.rb +4 -3
- data/lib/chef/resource/snap_package.rb +32 -23
- data/lib/chef/resource/solaris_package.rb +3 -2
- data/lib/chef/resource/ssh_known_hosts_entry.rb +13 -12
- data/lib/chef/resource/sudo.rb +71 -70
- data/lib/chef/resource/swap_file.rb +20 -19
- data/lib/chef/resource/sysctl.rb +49 -48
- data/lib/chef/resource/systemd_unit.rb +42 -39
- data/lib/chef/resource/template.rb +3 -2
- data/lib/chef/resource/timezone.rb +23 -22
- data/lib/chef/resource/user/aix_user.rb +4 -3
- data/lib/chef/resource/user/linux_user.rb +4 -4
- data/lib/chef/resource/user/mac_user.rb +5 -4
- data/lib/chef/resource/user/pw_user.rb +4 -3
- data/lib/chef/resource/user/solaris_user.rb +4 -3
- data/lib/chef/resource/user/windows_user.rb +2 -1
- data/lib/chef/resource/user.rb +8 -7
- data/lib/chef/resource/user_ulimit.rb +25 -24
- data/lib/chef/resource/windows_ad_join.rb +22 -22
- data/lib/chef/resource/windows_audit_policy.rb +35 -35
- data/lib/chef/resource/windows_auto_run.rb +9 -9
- data/lib/chef/resource/windows_certificate.rb +20 -20
- data/lib/chef/resource/windows_defender.rb +23 -23
- data/lib/chef/resource/windows_defender_exclusion.rb +18 -18
- data/lib/chef/resource/windows_dfs_folder.rb +1 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +1 -1
- data/lib/chef/resource/windows_dfs_server.rb +1 -1
- data/lib/chef/resource/windows_dns_record.rb +1 -1
- data/lib/chef/resource/windows_dns_zone.rb +1 -1
- data/lib/chef/resource/windows_env.rb +6 -6
- data/lib/chef/resource/windows_feature.rb +43 -43
- data/lib/chef/resource/windows_feature_dism.rb +9 -9
- data/lib/chef/resource/windows_feature_powershell.rb +21 -21
- data/lib/chef/resource/windows_firewall_profile.rb +29 -29
- data/lib/chef/resource/windows_firewall_rule.rb +48 -48
- data/lib/chef/resource/windows_font.rb +7 -7
- data/lib/chef/resource/windows_package.rb +59 -59
- data/lib/chef/resource/windows_pagefile.rb +30 -30
- data/lib/chef/resource/windows_path.rb +13 -13
- data/lib/chef/resource/windows_printer.rb +29 -29
- data/lib/chef/resource/windows_printer_port.rb +22 -22
- data/lib/chef/resource/windows_script.rb +1 -1
- data/lib/chef/resource/windows_security_policy.rb +24 -24
- data/lib/chef/resource/windows_service.rb +107 -107
- data/lib/chef/resource/windows_share.rb +17 -17
- data/lib/chef/resource/windows_shortcut.rb +8 -8
- data/lib/chef/resource/windows_task.rb +103 -105
- data/lib/chef/resource/windows_uac.rb +15 -15
- data/lib/chef/resource/windows_update_settings.rb +27 -27
- data/lib/chef/resource/windows_user_privilege.rb +59 -59
- data/lib/chef/resource/windows_workgroup.rb +11 -11
- data/lib/chef/resource/yum_package.rb +5 -4
- data/lib/chef/resource/yum_repository.rb +37 -36
- data/lib/chef/resource/zypper_package.rb +3 -2
- data/lib/chef/resource/zypper_repository.rb +4 -3
- data/lib/chef/resource.rb +11 -3
- data/lib/chef/resource_builder.rb +1 -1
- data/lib/chef/resource_collection/resource_collection_serialization.rb +1 -1
- data/lib/chef/resource_collection/resource_list.rb +1 -1
- data/lib/chef/resource_collection/resource_set.rb +10 -4
- data/lib/chef/resource_collection.rb +1 -1
- data/lib/chef/resource_definition.rb +1 -1
- data/lib/chef/resource_definition_list.rb +1 -1
- data/lib/chef/resource_inspector.rb +3 -1
- data/lib/chef/resource_reporter.rb +2 -1
- data/lib/chef/resource_resolver.rb +1 -1
- data/lib/chef/resources.rb +2 -2
- data/lib/chef/role.rb +1 -1
- data/lib/chef/run_context/cookbook_compiler.rb +1 -1
- data/lib/chef/run_context.rb +2 -2
- data/lib/chef/run_list/run_list_expansion.rb +1 -1
- data/lib/chef/run_list/run_list_item.rb +5 -5
- data/lib/chef/run_list/versioned_recipe_list.rb +1 -1
- data/lib/chef/run_list.rb +1 -1
- data/lib/chef/run_lock.rb +4 -1
- data/lib/chef/run_status.rb +1 -1
- data/lib/chef/runner.rb +1 -1
- data/lib/chef/scan_access_control.rb +9 -7
- data/lib/chef/search/query.rb +1 -1
- data/lib/chef/secret_fetcher/akeyless_vault.rb +1 -1
- data/lib/chef/secret_fetcher/aws_secrets_manager.rb +1 -1
- data/lib/chef/secret_fetcher/base.rb +1 -1
- data/lib/chef/secret_fetcher/example.rb +1 -1
- data/lib/chef/secret_fetcher/hashi_vault.rb +10 -1
- data/lib/chef/secret_fetcher.rb +1 -1
- data/lib/chef/server_api.rb +1 -1
- data/lib/chef/server_api_versions.rb +1 -1
- data/lib/chef/shell/ext.rb +20 -20
- data/lib/chef/shell/model_wrapper.rb +1 -1
- data/lib/chef/shell/shell_session.rb +2 -2
- data/lib/chef/shell.rb +30 -8
- data/lib/chef/target_io/dir.rb +12 -0
- data/lib/chef/target_io/etc.rb +16 -0
- data/lib/chef/target_io/file.rb +12 -0
- data/lib/chef/target_io/fileutils.rb +12 -0
- data/lib/chef/target_io/http.rb +35 -0
- data/lib/chef/target_io/io.rb +12 -0
- data/lib/chef/target_io/shadow.rb +44 -0
- data/lib/chef/target_io/support.rb +73 -0
- data/lib/chef/target_io/train/dir.rb +86 -0
- data/lib/chef/target_io/train/etc.rb +108 -0
- data/lib/chef/target_io/train/file.rb +219 -0
- data/lib/chef/target_io/train/fileutils.rb +201 -0
- data/lib/chef/target_io/train/http.rb +117 -0
- data/lib/chef/target_io/train/io.rb +13 -0
- data/lib/chef/target_io/train/shadow.rb +54 -0
- data/lib/chef/target_io/train_compat.rb +7 -0
- data/lib/chef/target_io.rb +11 -0
- data/lib/chef/train_transport.rb +1 -1
- data/lib/chef/user.rb +1 -1
- data/lib/chef/user_v1.rb +1 -1
- data/lib/chef/util/backup.rb +2 -2
- data/lib/chef/util/diff.rb +15 -2
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
- data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
- data/lib/chef/util/dsc/resource_store.rb +1 -1
- data/lib/chef/util/editor.rb +1 -1
- data/lib/chef/util/file_edit.rb +5 -5
- data/lib/chef/util/path_helper.rb +1 -1
- data/lib/chef/util/powershell/ps_credential.rb +1 -1
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/threaded_job_queue.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +1 -1
- data/lib/chef/version.rb +2 -2
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/version_constraint.rb +2 -2
- data/lib/chef/win32/api/command_line_helper.rb +1 -1
- data/lib/chef/win32/api/crypto.rb +1 -1
- data/lib/chef/win32/api/error.rb +1 -1
- data/lib/chef/win32/api/file.rb +3 -2
- data/lib/chef/win32/api/installer.rb +1 -1
- data/lib/chef/win32/api/memory.rb +1 -1
- data/lib/chef/win32/api/net.rb +1 -1
- data/lib/chef/win32/api/process.rb +1 -1
- data/lib/chef/win32/api/psapi.rb +1 -1
- data/lib/chef/win32/api/registry.rb +1 -1
- data/lib/chef/win32/api/security.rb +1 -1
- data/lib/chef/win32/api/synchronization.rb +1 -1
- data/lib/chef/win32/api/system.rb +1 -1
- data/lib/chef/win32/api/unicode.rb +1 -1
- data/lib/chef/win32/api.rb +1 -1
- data/lib/chef/win32/crypto.rb +1 -1
- data/lib/chef/win32/error.rb +3 -2
- data/lib/chef/win32/eventlog.rb +1 -1
- data/lib/chef/win32/file/info.rb +1 -1
- data/lib/chef/win32/file/version_info.rb +1 -1
- data/lib/chef/win32/file.rb +1 -1
- data/lib/chef/win32/handle.rb +1 -1
- data/lib/chef/win32/memory.rb +1 -1
- data/lib/chef/win32/mutex.rb +1 -1
- data/lib/chef/win32/net.rb +1 -1
- data/lib/chef/win32/process.rb +1 -1
- data/lib/chef/win32/registry.rb +4 -2
- data/lib/chef/win32/security/ace.rb +1 -1
- data/lib/chef/win32/security/acl.rb +1 -1
- data/lib/chef/win32/security/securable_object.rb +1 -1
- data/lib/chef/win32/security/security_descriptor.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/lib/chef/win32/security/token.rb +1 -1
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/system.rb +1 -1
- data/lib/chef/win32/unicode.rb +1 -1
- data/lib/chef/win32/version.rb +2 -3
- data/lib/chef/workstation_config_loader.rb +1 -1
- data/lib/chef.rb +3 -1
- metadata +125 -84
- data/lib/chef/resource/osx_profile.rb +0 -334
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#
|
|
2
2
|
# Author:: Marc Paradise (<marc@chef.io>)
|
|
3
|
-
# Copyright:: Copyright (c)
|
|
3
|
+
# Copyright:: Copyright (c) 2009-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
4
4
|
# License:: Apache License, Version 2.0
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -18,6 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
require_relative "base"
|
|
20
20
|
require "aws-sdk-core" # Support for aws instance profile auth
|
|
21
|
+
|
|
22
|
+
# The vault gem mutates OpenSSL::SSL::SSLContext::DEFAULT_PARAMS as it loads.
|
|
23
|
+
# Ruby 3.4 can ship that hash frozen (seen on Windows builds), so duplicate it
|
|
24
|
+
# before requiring vault to avoid a FrozenError during load.
|
|
25
|
+
if defined?(OpenSSL::SSL::SSLContext::DEFAULT_PARAMS) && OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.frozen?
|
|
26
|
+
mutable_defaults = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.dup
|
|
27
|
+
OpenSSL::SSL::SSLContext.const_set(:DEFAULT_PARAMS, mutable_defaults)
|
|
28
|
+
end
|
|
29
|
+
|
|
21
30
|
require "vault"
|
|
22
31
|
class Chef
|
|
23
32
|
class SecretFetcher
|
data/lib/chef/secret_fetcher.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#
|
|
2
2
|
# Author:: Marc Paradise (<marc@chef.io>)
|
|
3
|
-
# Copyright:: Copyright (c)
|
|
3
|
+
# Copyright:: Copyright (c) 2009-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
4
4
|
# License:: Apache License, Version 2.0
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/chef/server_api.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#
|
|
2
2
|
# Author:: John Keiser (<jkeiser@chef.io>)
|
|
3
|
-
# Copyright:: Copyright (c)
|
|
3
|
+
# Copyright:: Copyright (c) 2009-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
4
4
|
# License:: Apache License, Version 2.0
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright:: Copyright (c)
|
|
2
|
+
# Copyright:: Copyright (c) 2009-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/lib/chef/shell/ext.rb
CHANGED
|
@@ -239,9 +239,9 @@ module Shell
|
|
|
239
239
|
|
|
240
240
|
desc "returns an object to control a paused #{ChefUtils::Dist::Infra::PRODUCT} run"
|
|
241
241
|
subcommands resume: "resume the #{ChefUtils::Dist::Infra::PRODUCT} run",
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
step: "run only the next resource",
|
|
243
|
+
skip_back: "move back in the run list",
|
|
244
|
+
skip_forward: "move forward in the run list"
|
|
245
245
|
def chef_run
|
|
246
246
|
Shell.session.resource_collection.iterator
|
|
247
247
|
end
|
|
@@ -393,17 +393,17 @@ module Shell
|
|
|
393
393
|
This will strip the admin privileges from any client named after borat.
|
|
394
394
|
E
|
|
395
395
|
subcommands all: "list all api clients",
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
show: "load an api client by name",
|
|
397
|
+
search: "search for API clients",
|
|
398
|
+
transform: "edit all api clients via a code block and save them"
|
|
399
399
|
def clients
|
|
400
400
|
@clients ||= Shell::ModelWrapper.new(Chef::ApiClient, :client)
|
|
401
401
|
end
|
|
402
402
|
|
|
403
403
|
desc "Find and edit cookbooks"
|
|
404
404
|
subcommands all: "list all cookbooks",
|
|
405
|
-
|
|
406
|
-
|
|
405
|
+
show: "load a cookbook by name",
|
|
406
|
+
transform: "edit all cookbooks via a code block and save them"
|
|
407
407
|
def cookbooks
|
|
408
408
|
@cookbooks ||= Shell::ModelWrapper.new(Chef::CookbookVersion)
|
|
409
409
|
end
|
|
@@ -455,9 +455,9 @@ module Shell
|
|
|
455
455
|
This will assign the attribute to every node with a FQDN matching the regex.
|
|
456
456
|
E
|
|
457
457
|
subcommands all: "list all nodes",
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
458
|
+
show: "load a node by name",
|
|
459
|
+
search: "search for nodes",
|
|
460
|
+
transform: "edit all nodes via a code block and save them"
|
|
461
461
|
def nodes
|
|
462
462
|
@nodes ||= Shell::ModelWrapper.new(Chef::Node)
|
|
463
463
|
end
|
|
@@ -477,9 +477,9 @@ module Shell
|
|
|
477
477
|
See the help for +nodes+ for more information about the subcommands.
|
|
478
478
|
E
|
|
479
479
|
subcommands all: "list all roles",
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
480
|
+
show: "load a role by name",
|
|
481
|
+
search: "search for roles",
|
|
482
|
+
transform: "edit all roles via a code block and save them"
|
|
483
483
|
def roles
|
|
484
484
|
@roles ||= Shell::ModelWrapper.new(Chef::Role)
|
|
485
485
|
end
|
|
@@ -503,9 +503,9 @@ module Shell
|
|
|
503
503
|
|
|
504
504
|
E
|
|
505
505
|
subcommands all: "list all items in the data bag",
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
506
|
+
show: "load a data bag item by id",
|
|
507
|
+
search: "search for items in the data bag",
|
|
508
|
+
transform: "edit all items via a code block and save them"
|
|
509
509
|
def databags(databag_name)
|
|
510
510
|
@named_databags_wrappers ||= {}
|
|
511
511
|
@named_databags_wrappers[databag_name] ||= Shell::NamedDataBagWrapper.new(databag_name)
|
|
@@ -526,9 +526,9 @@ module Shell
|
|
|
526
526
|
See the help for +nodes+ for more information about the subcommands.
|
|
527
527
|
E
|
|
528
528
|
subcommands all: "list all environments",
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
529
|
+
show: "load an environment by name",
|
|
530
|
+
search: "search for environments",
|
|
531
|
+
transform: "edit all environments via a code block and save them"
|
|
532
532
|
def environments
|
|
533
533
|
@environments ||= Shell::ModelWrapper.new(Chef::Environment)
|
|
534
534
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
|
3
|
-
# Copyright:: Copyright (c)
|
|
3
|
+
# Copyright:: Copyright (c) 2009-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
4
4
|
# License:: Apache License, Version 2.0
|
|
5
5
|
#
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
|
3
3
|
# Author:: Tim Hinderliter (<tim@chef.io>)
|
|
4
4
|
# Copyright:: Copyright 2009-2016, Daniel DeLeo
|
|
5
|
-
# Copyright:: Copyright (c)
|
|
5
|
+
# Copyright:: Copyright (c) 2009-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
|
|
6
6
|
# License:: Apache License, Version 2.0
|
|
7
7
|
#
|
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -268,7 +268,7 @@ module Shell
|
|
|
268
268
|
|
|
269
269
|
def register
|
|
270
270
|
@rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url], client_name: Chef::Config[:node_name],
|
|
271
|
-
|
|
271
|
+
signing_key_filename: Chef::Config[:client_key])
|
|
272
272
|
end
|
|
273
273
|
|
|
274
274
|
end
|
data/lib/chef/shell.rb
CHANGED
|
@@ -38,6 +38,8 @@ require_relative "workstation_config_loader"
|
|
|
38
38
|
require_relative "shell/ext"
|
|
39
39
|
require_relative "json_compat"
|
|
40
40
|
require_relative "util/path_helper"
|
|
41
|
+
require "chef-licensing/cli_flags/mixlib_cli"
|
|
42
|
+
require_relative "licensing"
|
|
41
43
|
|
|
42
44
|
# = Shell
|
|
43
45
|
# Shell is Chef in an IRB session. Shell can interact with a Chef server via the
|
|
@@ -57,17 +59,19 @@ module Shell
|
|
|
57
59
|
def self.start
|
|
58
60
|
setup_logger
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
irb_help = [:help, :irb_help, IRB::ExtendCommandBundle::NO_OVERRIDE]
|
|
65
|
-
IRB::ExtendCommandBundle.instance_variable_get(:@ALIASES).delete(irb_help)
|
|
66
|
-
end
|
|
62
|
+
IRB::Command.register(
|
|
63
|
+
:help,
|
|
64
|
+
proc { Shell::Options.print_help }
|
|
65
|
+
)
|
|
67
66
|
|
|
68
67
|
parse_opts
|
|
69
68
|
Chef::Config[:shell_config] = options.config
|
|
70
69
|
|
|
70
|
+
if ChefUtils::Dist::Infra::SHELL == "chef-shell"
|
|
71
|
+
Chef::Licensing.fetch_and_persist
|
|
72
|
+
Chef::Licensing.check_software_entitlement!
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
# HACK: this duplicates the functions of IRB.start, but we have to do it
|
|
72
76
|
# to get access to the main object before irb starts.
|
|
73
77
|
::IRB.setup(nil)
|
|
@@ -140,7 +144,7 @@ module Shell
|
|
|
140
144
|
# remove this clause for any Chef version that has upgraded to ruby >= 3.3.0
|
|
141
145
|
if RUBY_VERSION >= "3.3.0"
|
|
142
146
|
conf.prompt_c = "#{ChefUtils::Dist::Infra::EXEC}#{leader(m)} > "
|
|
143
|
-
|
|
147
|
+
# prompt_n deprecation warnings as of 3.4.x
|
|
144
148
|
conf.prompt_s = "#{ChefUtils::Dist::Infra::EXEC}#{leader(m)}%l> "
|
|
145
149
|
else
|
|
146
150
|
# there's a bug if you use a left arrow and the alternative prompts
|
|
@@ -227,6 +231,7 @@ module Shell
|
|
|
227
231
|
class Options
|
|
228
232
|
include Mixlib::CLI
|
|
229
233
|
include ChefConfig::Mixin::DotD
|
|
234
|
+
include ChefLicensing::CLIFlags::MixlibCLI
|
|
230
235
|
|
|
231
236
|
def self.footer(text = nil)
|
|
232
237
|
@footer = text if text
|
|
@@ -337,12 +342,29 @@ module Shell
|
|
|
337
342
|
description: "Use cached cookbooks without overwriting local differences from the server",
|
|
338
343
|
boolean: false
|
|
339
344
|
|
|
345
|
+
if ChefUtils::Dist::Infra::SHELL == "chef-shell"
|
|
346
|
+
option :license_add,
|
|
347
|
+
long: "--license-add",
|
|
348
|
+
description: "Add a license key to the license pool.",
|
|
349
|
+
boolean: true,
|
|
350
|
+
proc: lambda { |v| Chef::Licensing.license_add },
|
|
351
|
+
exit: 0
|
|
352
|
+
|
|
353
|
+
option :license_list,
|
|
354
|
+
long: "--license-list",
|
|
355
|
+
description: "List all license keys in the license pool.",
|
|
356
|
+
boolean: true,
|
|
357
|
+
proc: lambda { |v| Chef::Licensing.license_list },
|
|
358
|
+
exit: 0
|
|
359
|
+
end
|
|
360
|
+
|
|
340
361
|
def self.print_help
|
|
341
362
|
instance = new
|
|
342
363
|
instance.parse_options([])
|
|
343
364
|
puts instance.opt_parser
|
|
344
365
|
puts
|
|
345
366
|
puts footer
|
|
367
|
+
puts Chef::Licensing.licensing_help if ChefUtils::Dist::Infra::SHELL == "chef-shell"
|
|
346
368
|
puts
|
|
347
369
|
exit 1
|
|
348
370
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module TargetIO
|
|
2
|
+
class Dir
|
|
3
|
+
class << self
|
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
|
5
|
+
Chef::Log.debug format("Dir::%s(%s)", m.to_s, args.join(", "))
|
|
6
|
+
|
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::Dir : ::Dir
|
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module TargetIO
|
|
2
|
+
class Etc
|
|
3
|
+
class << self
|
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
|
5
|
+
Chef::Log.debug format("Etc::%s(%s)", m.to_s, args.join(", "))
|
|
6
|
+
|
|
7
|
+
if ChefConfig::Config.target_mode? && !Chef.run_context.transport_connection.os.unix?
|
|
8
|
+
raise "Etc support only on Unix, this is " + Chef.run_context.transport_connection.platform.title
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::Etc : ::Etc
|
|
12
|
+
backend.send(m, *args, **kwargs, &block)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module TargetIO
|
|
2
|
+
class File
|
|
3
|
+
class << self
|
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
|
5
|
+
Chef::Log.debug format("File::%s(%s)", m.to_s, args.join(", "))
|
|
6
|
+
|
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::File : ::File
|
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module TargetIO
|
|
2
|
+
class FileUtils
|
|
3
|
+
class << self
|
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
|
5
|
+
Chef::Log.debug format("FileUtils::%s(%s)", m.to_s, args.join(", "))
|
|
6
|
+
|
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::FileUtils : ::FileUtils
|
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "forwardable" unless defined?(Forwardable)
|
|
2
|
+
|
|
3
|
+
require_relative "../http/simple"
|
|
4
|
+
require_relative "../json_compat"
|
|
5
|
+
require_relative "train/http"
|
|
6
|
+
|
|
7
|
+
module TargetIO
|
|
8
|
+
class HTTP
|
|
9
|
+
extend Forwardable
|
|
10
|
+
def_delegators :@http_class, :get, :head, :patch, :post, :put, :delete
|
|
11
|
+
|
|
12
|
+
# Only for Chef::Provider::RemoteFile::HTTP
|
|
13
|
+
def_delegators :@http_class, :streaming_request, :streaming_request_with_progress, :last_response
|
|
14
|
+
|
|
15
|
+
def initialize(url, http_client_opts = {})
|
|
16
|
+
if ::ChefConfig::Config.target_mode?
|
|
17
|
+
@http_class = TargetIO::TrainCompat::HTTP.new(url, http_client_opts)
|
|
18
|
+
else
|
|
19
|
+
@http_class = Chef::HTTP::Simple.new(url, http_client_opts)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class SimpleJSON
|
|
24
|
+
def initialize(url, http_client_opts = {})
|
|
25
|
+
@http_class = TargetIO::HTTP.new(url, http_client_opts)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get(path, headers = {})
|
|
29
|
+
response = @http_class.get(path, headers)
|
|
30
|
+
|
|
31
|
+
Chef::JSONCompat.from_json(response)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module TargetIO
|
|
2
|
+
class IO
|
|
3
|
+
class << self
|
|
4
|
+
def method_missing(m, *args, **kwargs, &block)
|
|
5
|
+
Chef::Log.debug format("IO::%s(%s)", m.to_s, args.join(", "))
|
|
6
|
+
|
|
7
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::IO : ::IO
|
|
8
|
+
backend.send(m, *args, **kwargs, &block)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module TargetIO
|
|
2
|
+
module Shadow
|
|
3
|
+
# sp_namp - pointer to null-terminated user name.
|
|
4
|
+
# sp_pwdp - pointer to null-terminated password.
|
|
5
|
+
# sp_lstchg - days since Jan 1, 1970 password was last
|
|
6
|
+
# changed.
|
|
7
|
+
# sp_min - days before which password may not be changed.
|
|
8
|
+
# sp_max - days after which password must be changed.
|
|
9
|
+
# sp_warn - days before password is to expire that user is
|
|
10
|
+
# warned of pending password expiration.
|
|
11
|
+
# sp_inact - days after password expires that account is
|
|
12
|
+
# considered inactive and disabled.
|
|
13
|
+
# sp_expire - days since Jan 1, 1970 when account will be
|
|
14
|
+
# disabled
|
|
15
|
+
# sp_loginclass - pointer to null-terminated user login class.
|
|
16
|
+
Entry = Struct.new(
|
|
17
|
+
:sp_namp,
|
|
18
|
+
:sp_pwdp,
|
|
19
|
+
:sp_lstchg,
|
|
20
|
+
:sp_min,
|
|
21
|
+
:sp_max,
|
|
22
|
+
:sp_warn,
|
|
23
|
+
:sp_inact,
|
|
24
|
+
:sp_expire,
|
|
25
|
+
:sp_loginclass
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
class Passwd
|
|
29
|
+
class << self
|
|
30
|
+
|
|
31
|
+
def method_missing(m, *args, **kwargs, &block)
|
|
32
|
+
Chef::Log.debug format("Shadow::Passwd::%s(%s)", m.to_s, args.join(", "))
|
|
33
|
+
|
|
34
|
+
if ChefConfig::Config.target_mode? && !Chef.run_context.transport_connection.os.unix?
|
|
35
|
+
raise "Shadow support only on Unix, this is " + Chef.run_context.transport_connection.platform.title
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
backend = ChefConfig::Config.target_mode? ? TrainCompat::Shadow::Passwd : ::Shadow::Passwd
|
|
39
|
+
backend.send(m, *args, **kwargs, &block)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require "tempfile" unless defined?(::Tempfile)
|
|
2
|
+
|
|
3
|
+
module TargetIO
|
|
4
|
+
module Support
|
|
5
|
+
# "sudo" based connections need a staging area for file reading/writing
|
|
6
|
+
def read_file(filename)
|
|
7
|
+
accessible_file = filename
|
|
8
|
+
|
|
9
|
+
if sudo?
|
|
10
|
+
accessible_file = staging_file(filename)
|
|
11
|
+
::TargetIO::FileUtils.cp(filename, accessible_file)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
content = transport_connection.file(accessible_file).content
|
|
15
|
+
|
|
16
|
+
clean_staging(accessible_file) if sudo?
|
|
17
|
+
|
|
18
|
+
content
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def write_file(remote_file, content)
|
|
22
|
+
tempfile = ::Tempfile.new
|
|
23
|
+
tempfile.write(tempfile, content)
|
|
24
|
+
tempfile.close
|
|
25
|
+
|
|
26
|
+
upload(tempfile.path, remote_file)
|
|
27
|
+
tempfile.unlink
|
|
28
|
+
|
|
29
|
+
remote_file
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def upload(local_file, remote_file)
|
|
33
|
+
accessible_file = remote_file
|
|
34
|
+
accessible_file = staging_file(remote_file) if sudo?
|
|
35
|
+
|
|
36
|
+
transport_connection.upload(local_file, accessible_file)
|
|
37
|
+
|
|
38
|
+
if sudo?
|
|
39
|
+
::TargetIO::FileUtils.mv(accessible_file, remote_file)
|
|
40
|
+
clean_staging(accessible_file)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def staging_file(filename)
|
|
45
|
+
staging_dir = ::TargetIO::Dir.mktmpdir(filename)
|
|
46
|
+
::File.join(staging_dir, ::File.basename(filename))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def clean_staging(filename)
|
|
50
|
+
::TargetIO::FileUtils.rm(filename)
|
|
51
|
+
|
|
52
|
+
staging_dir = ::File.dirname(filename)
|
|
53
|
+
::TargetIO::FileUtils.rmdir(staging_dir)
|
|
54
|
+
rescue Errno::ENOENT
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def run_command(cmd)
|
|
58
|
+
transport_connection.run_command(cmd)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def sudo?
|
|
62
|
+
transport_connection.transport_options[:sudo]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def remote_user
|
|
66
|
+
transport_connection.transport_options[:user]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def transport_connection
|
|
70
|
+
Chef.run_context&.transport_connection
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require_relative "file"
|
|
2
|
+
require_relative "fileutils"
|
|
3
|
+
|
|
4
|
+
require_relative "../support"
|
|
5
|
+
|
|
6
|
+
module TargetIO
|
|
7
|
+
module TrainCompat
|
|
8
|
+
class Dir
|
|
9
|
+
class << self
|
|
10
|
+
include TargetIO::Support
|
|
11
|
+
|
|
12
|
+
def [](*patterns, base: ".", sort: true)
|
|
13
|
+
Dir.glob(patterns, 0, base, sort)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def delete(dir_name)
|
|
17
|
+
::TargetIO::FileUtils.rm_rf(dir_name)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def directory?(dir_name)
|
|
21
|
+
::TargetIO::File.directory? dir_name
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def entries(dirname)
|
|
25
|
+
cmd = "ls -1a #{dirname}"
|
|
26
|
+
output = run_command(cmd).stdout
|
|
27
|
+
output.split("\n")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def glob(pattern, flags = 0, base: ".", sort: true)
|
|
31
|
+
raise "Dir.glob flags not supported except FNM_DOTMATCH" unless [0, ::File::FNM_DOTMATCH].include? flags
|
|
32
|
+
|
|
33
|
+
pattern = Array(pattern)
|
|
34
|
+
matchdot = flags || ::File::FNM_DOTMATCH ? "dotglob" : ""
|
|
35
|
+
|
|
36
|
+
cmd += <<-BASH4
|
|
37
|
+
shopt -s globstar #{matchdot}
|
|
38
|
+
cd #{base}
|
|
39
|
+
for f in #{pattern.join(" ")}; do
|
|
40
|
+
printf '%s\n' "$f";
|
|
41
|
+
done
|
|
42
|
+
BASH4
|
|
43
|
+
|
|
44
|
+
output = run_command(cmd).stdout
|
|
45
|
+
files = output.split("\n")
|
|
46
|
+
files.sort! if sort
|
|
47
|
+
|
|
48
|
+
files
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def mkdir(dir_name, mode = nil)
|
|
52
|
+
::TargetIO::FileUtils.mkdir(dir_name)
|
|
53
|
+
::TargetIO::FileUtils.chmod(dir_name, mode) if mode
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Borrowed and adapted from Ruby's Dir::tmpdir and Dir::mktmpdir
|
|
57
|
+
def mktmpdir(prefix_suffix = nil, *rest, **options)
|
|
58
|
+
prefix, suffix = ::File.basename(prefix_suffix || "d")
|
|
59
|
+
random = (::Random.urandom(4).unpack1("L") % 36**6).to_s(36)
|
|
60
|
+
|
|
61
|
+
t = Time.now.strftime("%Y%m%d%s")
|
|
62
|
+
path = "#{prefix}#{t}-#{$$}-#{random}" + "#{suffix || ""}"
|
|
63
|
+
path = ::File.join(tmpdir, path)
|
|
64
|
+
|
|
65
|
+
::TargetIO::FileUtils.mkdir(path)
|
|
66
|
+
::TargetIO::FileUtils.chmod(0700, path)
|
|
67
|
+
::TargetIO::FileUtils.chown(remote_user, nil, path) if sudo?
|
|
68
|
+
|
|
69
|
+
at_exit do
|
|
70
|
+
::TargetIO::FileUtils.rm_rf(path)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
path
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def tmpdir
|
|
77
|
+
::Dir.tmpdir
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def unlink(dir_name)
|
|
81
|
+
::TargetIO::FileUtils.rmdir(dir_name)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require_relative "file"
|
|
2
|
+
|
|
3
|
+
module TargetIO
|
|
4
|
+
module TrainCompat
|
|
5
|
+
class Etc
|
|
6
|
+
@@cache = {}
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
def getpwnam(name)
|
|
10
|
+
__getpw { |entry| entry["user"] == name }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def getpwuid(uid)
|
|
14
|
+
__getpw { |entry| entry["uid"] == uid.to_i }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def getgrnam(name)
|
|
18
|
+
__getgr { |entry| entry["name"] == name }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def getgrgid(gid)
|
|
22
|
+
__getgr { |entry| entry["gid"] == gid.to_i }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def __getpw(&block)
|
|
26
|
+
content = ::TargetIO::File.read("/etc/passwd")
|
|
27
|
+
entries = __parse_passwd(content)
|
|
28
|
+
data = entries.detect(&block)
|
|
29
|
+
raise ArgumentError unless data
|
|
30
|
+
|
|
31
|
+
::Etc::Passwd.new(
|
|
32
|
+
data["user"],
|
|
33
|
+
data["password"],
|
|
34
|
+
data["uid"].to_i,
|
|
35
|
+
data["gid"].to_i,
|
|
36
|
+
data["desc"],
|
|
37
|
+
data["home"],
|
|
38
|
+
data["shell"]
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Parse /etc/passwd files.
|
|
43
|
+
# Courtesy of InSpec
|
|
44
|
+
#
|
|
45
|
+
# @param [String] content the raw content of /etc/passwd
|
|
46
|
+
# @return [Array] Collection of passwd entries
|
|
47
|
+
def __parse_passwd(content)
|
|
48
|
+
content.to_s.split("\n").map do |line|
|
|
49
|
+
next if line[0] == "#"
|
|
50
|
+
|
|
51
|
+
__parse_passwd_line(line)
|
|
52
|
+
end.compact
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Parse a line of /etc/passwd
|
|
56
|
+
#
|
|
57
|
+
# @param [String] line a line of /etc/passwd
|
|
58
|
+
# @return [Hash] Map of entries in this line
|
|
59
|
+
def __parse_passwd_line(line)
|
|
60
|
+
x = line.split(":")
|
|
61
|
+
{
|
|
62
|
+
# rubocop:disable Layout/AlignHash
|
|
63
|
+
"user" => x.at(0),
|
|
64
|
+
"password" => x.at(1),
|
|
65
|
+
"uid" => x.at(2),
|
|
66
|
+
"gid" => x.at(3),
|
|
67
|
+
"desc" => x.at(4),
|
|
68
|
+
"home" => x.at(5),
|
|
69
|
+
"shell" => x.at(6),
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def __getgr(&block)
|
|
74
|
+
content = ::TargetIO::File.read("/etc/group")
|
|
75
|
+
entries = __parse_group(content)
|
|
76
|
+
data = entries.detect(&block)
|
|
77
|
+
raise ArgumentError unless data
|
|
78
|
+
|
|
79
|
+
::Etc::Group.new(
|
|
80
|
+
data["name"],
|
|
81
|
+
data["password"],
|
|
82
|
+
data["gid"].to_i,
|
|
83
|
+
String(data["mem"]).split(",")
|
|
84
|
+
)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def __parse_group(content)
|
|
88
|
+
content.to_s.split("\n").map do |line|
|
|
89
|
+
next if line[0] == "#"
|
|
90
|
+
|
|
91
|
+
__parse_group_line(line)
|
|
92
|
+
end.compact
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def __parse_group_line(line)
|
|
96
|
+
x = line.split(":")
|
|
97
|
+
{
|
|
98
|
+
# rubocop:disable Layout/AlignHash
|
|
99
|
+
"name" => x.at(0),
|
|
100
|
+
"password" => x.at(1),
|
|
101
|
+
"gid" => x.at(2),
|
|
102
|
+
"mem" => x.at(3),
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|