chef 18.9.4-universal-mingw-ucrt → 19.1.164-universal-mingw-ucrt
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 -22
- data/README.md +6 -2
- data/Rakefile +12 -7
- data/chef-universal-mingw-ucrt.gemspec +1 -1
- data/chef.gemspec +18 -20
- 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 +31 -4
- data/lib/chef/application/base.rb +38 -7
- data/lib/chef/application/client.rb +15 -1
- data/lib/chef/application/exit_code.rb +4 -2
- 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 +8 -7
- 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 +1 -1
- 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 +3 -4
- 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 +11 -2
- data/lib/chef/compliance/default_attributes.rb +1 -1
- data/lib/chef/compliance/fetcher/chef_server.rb +2 -2
- 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/reporter/cli.rb +2 -2
- 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 +3 -3
- 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 +2 -6
- 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 +2 -6
- 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 +2 -2
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +2 -1
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +2 -1
- 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 +2 -2
- 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 +2 -2
- 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 +1 -1
- 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 +2 -2
- 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 +3 -3
- data/lib/chef/mixin/proxified_socket.rb +1 -1
- data/lib/chef/mixin/securable.rb +3 -3
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/subclass_directive.rb +1 -1
- data/lib/chef/mixin/template.rb +2 -2
- 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 +2 -2
- 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 +2 -3
- 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 +2 -2
- 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 +27 -16
- data/lib/chef/provider/dsc_resource.rb +3 -3
- 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 +9 -9
- 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 +4 -4
- 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 +5 -5
- 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 +1 -1
- 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 +1 -1
- 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 +4 -4
- 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 +19 -3
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/package/snap.rb +20 -8
- 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 +2 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- 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 +3 -3
- 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 +1 -1
- 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 +9 -11
- 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 +2 -2
- 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 +1 -1
- 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 +153 -8
- data/lib/chef/resource/action_class.rb +1 -1
- data/lib/chef/resource/alternatives.rb +5 -4
- data/lib/chef/resource/apt_package.rb +7 -2
- data/lib/chef/resource/apt_preference.rb +3 -2
- data/lib/chef/resource/apt_repository.rb +18 -13
- data/lib/chef/resource/apt_update.rb +5 -4
- data/lib/chef/resource/archive_file.rb +21 -21
- data/lib/chef/resource/bash.rb +3 -2
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +3 -2
- data/lib/chef/resource/breakpoint.rb +2 -1
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/cab_package.rb +1 -1
- data/lib/chef/resource/chef_client_config.rb +5 -8
- data/lib/chef/resource/chef_client_cron.rb +5 -3
- data/lib/chef/resource/chef_client_hab_ca_cert.rb +141 -0
- data/lib/chef/resource/chef_client_launchd.rb +7 -3
- data/lib/chef/resource/chef_client_scheduled_task.rb +6 -3
- data/lib/chef/resource/chef_client_systemd_timer.rb +5 -2
- data/lib/chef/resource/chef_client_trusted_certificate.rb +1 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/chef_handler.rb +1 -1
- 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 +1 -1
- data/lib/chef/resource/chocolatey_feature.rb +1 -1
- data/lib/chef/resource/chocolatey_installer.rb +5 -20
- data/lib/chef/resource/chocolatey_package.rb +1 -1
- data/lib/chef/resource/chocolatey_source.rb +1 -1
- 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 -3
- data/lib/chef/resource/cron/cron.rb +2 -1
- 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 +8 -7
- data/lib/chef/resource/directory.rb +8 -7
- 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 +6 -3
- 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 +7 -4
- data/lib/chef/resource/habitat/_habitat_shared.rb +1 -1
- data/lib/chef/resource/habitat/habitat_package.rb +4 -2
- data/lib/chef/resource/habitat/habitat_sup.rb +17 -18
- data/lib/chef/resource/habitat/habitat_sup_systemd.rb +4 -3
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +2 -1
- data/lib/chef/resource/habitat_config.rb +25 -11
- data/lib/chef/resource/habitat_install.rb +5 -5
- data/lib/chef/resource/habitat_service.rb +9 -5
- data/lib/chef/resource/habitat_user_toml.rb +2 -2
- data/lib/chef/resource/helpers/cron_validations.rb +3 -3
- data/lib/chef/resource/helpers/path_helpers.rb +52 -0
- data/lib/chef/resource/homebrew_cask.rb +2 -2
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +11 -3
- data/lib/chef/resource/homebrew_update.rb +1 -1
- data/lib/chef/resource/hostname.rb +16 -13
- data/lib/chef/resource/http_request.rb +3 -2
- data/lib/chef/resource/ifconfig.rb +2 -1
- data/lib/chef/resource/inspec_input.rb +5 -2
- data/lib/chef/resource/inspec_waiver.rb +3 -2
- data/lib/chef/resource/inspec_waiver_file_entry.rb +3 -2
- data/lib/chef/resource/ips_package.rb +4 -3
- data/lib/chef/resource/kernel_module.rb +4 -3
- data/lib/chef/resource/ksh.rb +8 -7
- data/lib/chef/resource/launchd.rb +1 -1
- data/lib/chef/resource/link.rb +12 -11
- data/lib/chef/resource/locale.rb +5 -4
- data/lib/chef/resource/log.rb +7 -5
- 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 +3 -3
- data/lib/chef/resource/mount.rb +4 -2
- data/lib/chef/resource/msu_package.rb +1 -1
- data/lib/chef/resource/notify_group.rb +3 -2
- data/lib/chef/resource/ohai.rb +5 -4
- data/lib/chef/resource/ohai_hint.rb +3 -2
- 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 +2 -2
- 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 +1 -1
- data/lib/chef/resource/openssl_x509_request.rb +1 -1
- data/lib/chef/resource/package.rb +10 -9
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +3 -2
- data/lib/chef/resource/perl.rb +8 -7
- data/lib/chef/resource/plist.rb +2 -2
- data/lib/chef/resource/portage_package.rb +3 -2
- data/lib/chef/resource/powershell_package.rb +1 -1
- data/lib/chef/resource/powershell_script.rb +1 -1
- data/lib/chef/resource/python.rb +7 -6
- data/lib/chef/resource/reboot.rb +8 -7
- data/lib/chef/resource/registry_key.rb +1 -6
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +4 -3
- data/lib/chef/resource/resource_notification.rb +5 -5
- data/lib/chef/resource/rhsm_errata.rb +3 -2
- data/lib/chef/resource/rhsm_errata_level.rb +4 -3
- data/lib/chef/resource/rhsm_register.rb +12 -3
- 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 +6 -5
- data/lib/chef/resource/scm/subversion.rb +3 -2
- data/lib/chef/resource/script.rb +7 -5
- 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 +2 -1
- data/lib/chef/resource/selinux_fcontext.rb +4 -3
- data/lib/chef/resource/selinux_install.rb +2 -1
- data/lib/chef/resource/selinux_login.rb +2 -1
- data/lib/chef/resource/selinux_module.rb +6 -5
- data/lib/chef/resource/selinux_permissive.rb +3 -2
- data/lib/chef/resource/selinux_port.rb +3 -2
- data/lib/chef/resource/selinux_state.rb +3 -2
- data/lib/chef/resource/selinux_user.rb +2 -1
- data/lib/chef/resource/service.rb +4 -1
- data/lib/chef/resource/smartos_package.rb +4 -3
- data/lib/chef/resource/snap_package.rb +16 -7
- data/lib/chef/resource/solaris_package.rb +3 -2
- data/lib/chef/resource/ssh_known_hosts_entry.rb +3 -2
- data/lib/chef/resource/sudo.rb +11 -10
- data/lib/chef/resource/swap_file.rb +8 -7
- data/lib/chef/resource/sysctl.rb +7 -6
- data/lib/chef/resource/systemd_unit.rb +4 -1
- data/lib/chef/resource/template.rb +3 -2
- data/lib/chef/resource/timezone.rb +7 -6
- 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 +2 -1
- 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 +2 -1
- data/lib/chef/resource/user_ulimit.rb +3 -2
- data/lib/chef/resource/windows_ad_join.rb +2 -2
- data/lib/chef/resource/windows_audit_policy.rb +1 -1
- data/lib/chef/resource/windows_auto_run.rb +2 -2
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +1 -1
- data/lib/chef/resource/windows_defender_exclusion.rb +1 -1
- 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_feature.rb +1 -1
- data/lib/chef/resource/windows_feature_dism.rb +1 -1
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_profile.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +1 -1
- data/lib/chef/resource/windows_font.rb +2 -2
- data/lib/chef/resource/windows_package.rb +2 -2
- data/lib/chef/resource/windows_pagefile.rb +3 -3
- data/lib/chef/resource/windows_path.rb +1 -1
- data/lib/chef/resource/windows_printer.rb +1 -1
- data/lib/chef/resource/windows_printer_port.rb +1 -1
- data/lib/chef/resource/windows_script.rb +1 -1
- data/lib/chef/resource/windows_security_policy.rb +1 -1
- data/lib/chef/resource/windows_service.rb +2 -2
- data/lib/chef/resource/windows_share.rb +4 -4
- data/lib/chef/resource/windows_shortcut.rb +1 -1
- data/lib/chef/resource/windows_task.rb +3 -5
- data/lib/chef/resource/windows_uac.rb +1 -1
- data/lib/chef/resource/windows_update_settings.rb +3 -3
- data/lib/chef/resource/windows_user_privilege.rb +3 -3
- data/lib/chef/resource/windows_workgroup.rb +1 -1
- data/lib/chef/resource/yum_package.rb +5 -4
- data/lib/chef/resource/yum_repository.rb +3 -2
- data/lib/chef/resource/zypper_package.rb +3 -2
- data/lib/chef/resource/zypper_repository.rb +4 -3
- data/lib/chef/resource.rb +12 -4
- 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 +12 -7
- 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 +4 -3
- 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 +2 -2
- 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 -2
- 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 -2
- 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/model_wrapper.rb +1 -1
- data/lib/chef/shell/shell_session.rb +1 -1
- 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 +2 -2
- 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 +127 -87
- data/distro/powershell/chef/chef.psm1 +0 -459
- data/lib/chef/resource/osx_profile.rb +0 -334
|
@@ -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
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
require_relative "../support"
|
|
2
|
+
|
|
3
|
+
module TargetIO
|
|
4
|
+
module TrainCompat
|
|
5
|
+
class File
|
|
6
|
+
class << self
|
|
7
|
+
include TargetIO::Support
|
|
8
|
+
|
|
9
|
+
def foreach(name)
|
|
10
|
+
raise "TargetIO does not implement block-less File.foreach yet" unless block_given?
|
|
11
|
+
|
|
12
|
+
contents = readlines(name)
|
|
13
|
+
contents.each { |line| yield(line) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def binread(name, length = nil, offset = 0)
|
|
17
|
+
content = read(file_name)
|
|
18
|
+
length = content.size - offset if length.nil?
|
|
19
|
+
|
|
20
|
+
content[offset, length]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def expand_path(file_name, dir_string = "")
|
|
24
|
+
require "pathname" unless defined?(Pathname)
|
|
25
|
+
|
|
26
|
+
# Will just collapse relative paths inside
|
|
27
|
+
pn = Pathname.new File.join(dir_string, file_name)
|
|
28
|
+
pn.cleanpath
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def new(filename, mode = "r")
|
|
32
|
+
# Would need to hook into io.close (Closure?)
|
|
33
|
+
raise NotImplementedError, "TargetIO does not implement File.new yet"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def read(file_name)
|
|
37
|
+
readlines(file_name)&.join("\n") || ""
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def open(file_name, mode = "r")
|
|
41
|
+
raise "TargetIO does not implement block-less File.open with modes other than read yet" if mode != "r" && !block_given?
|
|
42
|
+
|
|
43
|
+
content = exist?(file_name) ? read(file_name) : ""
|
|
44
|
+
new_content = content.dup
|
|
45
|
+
|
|
46
|
+
io = StringIO.new(new_content)
|
|
47
|
+
|
|
48
|
+
if mode.start_with? "w"
|
|
49
|
+
io.truncate(0)
|
|
50
|
+
elsif mode.start_with? "a"
|
|
51
|
+
io.seek(0, IO::SEEK_END)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
if block_given?
|
|
55
|
+
yield(io)
|
|
56
|
+
|
|
57
|
+
# Return name of new remote file to be used in later operations
|
|
58
|
+
file_name = write_file(file_name, new_content) if (content != new_content) && !mode.start_with?("r")
|
|
59
|
+
|
|
60
|
+
return file_name
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
io
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def readlines(file_name)
|
|
67
|
+
content = read_file(file_name)
|
|
68
|
+
raise Errno::ENOENT if content.nil? # Not found
|
|
69
|
+
|
|
70
|
+
content.split("\n")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def executable?(file_name)
|
|
74
|
+
mode(file_name) & 0111 != 0
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def readable?(file_name)
|
|
78
|
+
cmd = format("test -r %s", file_name)
|
|
79
|
+
run_command(cmd).exit_status == 0
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def writable?(file_name)
|
|
83
|
+
cmd = format("test -w %s", file_name)
|
|
84
|
+
run_command(cmd).exit_status == 0
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# def ftype(file_name)
|
|
88
|
+
# case type(file_name)
|
|
89
|
+
# when :block_device
|
|
90
|
+
# "blockSpecial"
|
|
91
|
+
# when :character_device
|
|
92
|
+
# "characterSpecial"
|
|
93
|
+
# when :symlink
|
|
94
|
+
# "link"
|
|
95
|
+
# else
|
|
96
|
+
# type(file_name).to_s
|
|
97
|
+
# end
|
|
98
|
+
# end
|
|
99
|
+
|
|
100
|
+
def realpath(file_name)
|
|
101
|
+
cmd = "realpath #{file_name}" # coreutils, not MacOSX
|
|
102
|
+
Chef::Log.debug cmd
|
|
103
|
+
|
|
104
|
+
run_command(cmd).stdout.chop
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def readlink(file_name)
|
|
108
|
+
raise Errno::EINVAL unless symlink?(file_name)
|
|
109
|
+
|
|
110
|
+
cmd = "readlink #{file_name}"
|
|
111
|
+
Chef::Log.debug cmd
|
|
112
|
+
|
|
113
|
+
run_command(cmd).stdout.chop
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def setgid?(file_name)
|
|
117
|
+
mode(file_name) & 04000 != 0
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def setuid?(file_name)
|
|
121
|
+
mode(file_name) & 02000 != 0
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def sticky?(file_name)
|
|
125
|
+
mode(file_name) & 01000 != 0
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def size?(file_name)
|
|
129
|
+
exist?(file_name) && size(file_name) > 0
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def world_readable?(file_name)
|
|
133
|
+
mode(file_name) & 0001 != 0
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def world_writable?(file_name)
|
|
137
|
+
mode(file_name) & 0002 != 0
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def zero?(file_name)
|
|
141
|
+
exists?(file_name) && size(file_name) == 0
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def tempfile(filename)
|
|
145
|
+
tempdir = ::TargetIO::Dir.mktmpdir(path)
|
|
146
|
+
::File.join(tempdir, filename)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# passthrough or map calls to third parties
|
|
150
|
+
def method_missing(m, *args, **kwargs, &block)
|
|
151
|
+
nonio = %i{extname join dirname path split}
|
|
152
|
+
passthru = %i{basename directory? exist? exists? file? path pipe? socket? symlink?}
|
|
153
|
+
redirect_train = {
|
|
154
|
+
blockdev?: :block_device?,
|
|
155
|
+
chardev?: :character_device?,
|
|
156
|
+
}
|
|
157
|
+
redirect_utils = {
|
|
158
|
+
chown: :chown,
|
|
159
|
+
chmod: :chmod,
|
|
160
|
+
symlink: :ln_s,
|
|
161
|
+
delete: :rm,
|
|
162
|
+
unlink: :rm,
|
|
163
|
+
}
|
|
164
|
+
filestat = %i{gid group mode owner selinux_label size uid}
|
|
165
|
+
|
|
166
|
+
if %i{stat lstat}.include? m
|
|
167
|
+
Chef::Log.debug "File::#{m} passed to Train.file.stat"
|
|
168
|
+
|
|
169
|
+
follow_symlink = m == :stat
|
|
170
|
+
tfile = transport_connection.file(args[0], follow_symlink).stat
|
|
171
|
+
|
|
172
|
+
require "ostruct" unless defined?(OpenStruct)
|
|
173
|
+
OpenStruct.new(tfile)
|
|
174
|
+
|
|
175
|
+
# Non-IO methods can be issued locally
|
|
176
|
+
elsif nonio.include? m
|
|
177
|
+
::File.send(m, *args, **kwargs) # TODO: pass block
|
|
178
|
+
|
|
179
|
+
elsif passthru.include? m
|
|
180
|
+
Chef::Log.debug "File::#{m} passed to Train.file.#{m}"
|
|
181
|
+
|
|
182
|
+
file_name, other_args = args[0], args[1..]
|
|
183
|
+
|
|
184
|
+
file = transport_connection.file(file_name)
|
|
185
|
+
file.send(m, *other_args, **kwargs) # block?
|
|
186
|
+
|
|
187
|
+
elsif m == :mtime
|
|
188
|
+
# Solve a data type disparity between Train.file and File
|
|
189
|
+
timestamp = transport_connection.file(args[0]).mtime
|
|
190
|
+
Time.at(timestamp)
|
|
191
|
+
|
|
192
|
+
elsif filestat.include? m
|
|
193
|
+
Chef::Log.debug "File::#{m} passed to Train.file.stat.#{m}"
|
|
194
|
+
|
|
195
|
+
transport_connection.file(args[0]).stat[m]
|
|
196
|
+
|
|
197
|
+
elsif redirect_utils.key?(m)
|
|
198
|
+
new_method = redirect_utils[m]
|
|
199
|
+
Chef::Log.debug "File::#{m} redirected to TargetIO::FileUtils.#{new_method}"
|
|
200
|
+
|
|
201
|
+
::TargetIO::FileUtils.send(new_method, *args, **kwargs) # TODO: pass block
|
|
202
|
+
|
|
203
|
+
elsif redirect_train.key?(m)
|
|
204
|
+
new_method = redirect_train[m]
|
|
205
|
+
Chef::Log.debug "File::#{m} redirected to Train.file.#{new_method}"
|
|
206
|
+
|
|
207
|
+
file_name, other_args = args[0], args[1..]
|
|
208
|
+
|
|
209
|
+
file = transport_connection.file(file_name)
|
|
210
|
+
file.send(redirect[m], *other_args, **kwargs) # TODO: pass block
|
|
211
|
+
|
|
212
|
+
else
|
|
213
|
+
raise "Unsupported File method #{m}"
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
require_relative "../support"
|
|
2
|
+
|
|
3
|
+
module TargetIO
|
|
4
|
+
module TrainCompat
|
|
5
|
+
class FileUtils
|
|
6
|
+
class << self
|
|
7
|
+
include TargetIO::Support
|
|
8
|
+
|
|
9
|
+
def chmod(mode, list, noop: nil, verbose: nil)
|
|
10
|
+
cmd = sprintf("chmod %s %s", __mode_to_s(mode), Array(list).join(" "))
|
|
11
|
+
|
|
12
|
+
Chef::Log.debug cmd if verbose
|
|
13
|
+
return if noop
|
|
14
|
+
|
|
15
|
+
run_command(cmd)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def chmod_R(mode, list, noop: nil, verbose: nil, force: nil)
|
|
19
|
+
cmd = sprintf("chmod -R%s %s %s", (force ? "f" : ""), mode_to_s(mode), Array(list).join(" "))
|
|
20
|
+
|
|
21
|
+
Chef::Log.debug cmd if verbose
|
|
22
|
+
return if noop
|
|
23
|
+
|
|
24
|
+
run_command(cmd)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def chown(user, group, list, noop: nil, verbose: nil)
|
|
28
|
+
cmd = sprintf("chown %s %s", (group ? "#{user}:#{group}" : user || ":"), Array(list).join(" "))
|
|
29
|
+
|
|
30
|
+
Chef::Log.debug cmd if verbose
|
|
31
|
+
return if noop
|
|
32
|
+
|
|
33
|
+
run_command(cmd)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
|
|
37
|
+
cmd = sprintf("chown -R%s %s %s", (force ? "f" : ""), (group ? "#{user}:#{group}" : user || ":"), Array(list).join(" "))
|
|
38
|
+
|
|
39
|
+
Chef::Log.debug cmd if verbose
|
|
40
|
+
return if noop
|
|
41
|
+
|
|
42
|
+
run_command(cmd)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
|
|
46
|
+
cmd = "cp#{preserve ? " -p" : ""} #{[src, dest].flatten.join(" ")}"
|
|
47
|
+
|
|
48
|
+
Chef::Log.debug cmd if verbose
|
|
49
|
+
return if noop
|
|
50
|
+
|
|
51
|
+
run_command(cmd)
|
|
52
|
+
end
|
|
53
|
+
alias_method :copy, :cp
|
|
54
|
+
|
|
55
|
+
def cp_lr(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false)
|
|
56
|
+
cmd = "cp -lr#{remove_destination ? " --remove-destination" : ""} #{[src, dest].flatten.join(" ")}"
|
|
57
|
+
|
|
58
|
+
Chef::Log.debug cmd if verbose
|
|
59
|
+
return if noop
|
|
60
|
+
|
|
61
|
+
run_command(cmd)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def cp_r(src, dest, preserve: nil, noop: nil, verbose: nil, dereference_root: true, remove_destination: nil)
|
|
65
|
+
cmd = "cp -r#{preserve ? "p" : ""}#{remove_destination ? " --remove-destination" : ""} #{[src, dest].flatten.join(" ")}"
|
|
66
|
+
|
|
67
|
+
Chef::Log.debug cmd if verbose
|
|
68
|
+
return if noop
|
|
69
|
+
|
|
70
|
+
run_command(cmd)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# getwd (alias pwd)
|
|
74
|
+
# have_option?
|
|
75
|
+
# identical? (alias compare_file)
|
|
76
|
+
|
|
77
|
+
def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil, noop: nil, verbose: nil)
|
|
78
|
+
cmd = "install -c"
|
|
79
|
+
cmd << " -p" if preserve
|
|
80
|
+
cmd << " -m " << mode_to_s(mode) if mode
|
|
81
|
+
cmd << " -o #{owner}" if owner
|
|
82
|
+
cmd << " -g #{group}" if group
|
|
83
|
+
cmd << " " << [src, dest].flatten.join(" ")
|
|
84
|
+
|
|
85
|
+
Chef::Log.debug cmd if verbose
|
|
86
|
+
return if noop
|
|
87
|
+
|
|
88
|
+
run_command(cmd)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def ln(src, dest, force: nil, noop: nil, verbose: nil)
|
|
92
|
+
cmd = "ln#{force ? " -f" : ""} #{[src, dest].flatten.join(" ")}"
|
|
93
|
+
|
|
94
|
+
Chef::Log.debug cmd if verbose
|
|
95
|
+
return if noop
|
|
96
|
+
|
|
97
|
+
run_command(cmd)
|
|
98
|
+
end
|
|
99
|
+
alias_method :link, :ln
|
|
100
|
+
|
|
101
|
+
def ln_s(src, dest, force: nil, noop: nil, verbose: nil)
|
|
102
|
+
cmd = "ln -s#{force ? "f" : ""} #{[src, dest].flatten.join(" ")}"
|
|
103
|
+
|
|
104
|
+
Chef::Log.debug cmd if verbose
|
|
105
|
+
return if noop
|
|
106
|
+
|
|
107
|
+
run_command(cmd)
|
|
108
|
+
end
|
|
109
|
+
alias_method :symlink, :ln_s
|
|
110
|
+
|
|
111
|
+
def ln_sf(src, dest, noop: nil, verbose: nil)
|
|
112
|
+
ln_s(src, dest, force: true, noop: noop, verbose: verbose)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def mkdir(list, mode: nil, noop: nil, verbose: nil)
|
|
116
|
+
cmd = "mkdir #{mode ? ("-m %03o " % mode) : ""}#{Array(list).join(" ")}"
|
|
117
|
+
|
|
118
|
+
Chef::Log.debug cmd if verbose
|
|
119
|
+
return if noop
|
|
120
|
+
|
|
121
|
+
run_command(cmd)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def mkdir_p(list, mode: nil, noop: nil, verbose: nil)
|
|
125
|
+
cmd = "mkdir -p #{mode ? ("-m %03o " % mode) : ""}#{Array(list).join(" ")}"
|
|
126
|
+
|
|
127
|
+
Chef::Log.debug cmd if verbose
|
|
128
|
+
return if noop
|
|
129
|
+
|
|
130
|
+
run_command(cmd)
|
|
131
|
+
end
|
|
132
|
+
alias_method :makedirs, :mkdir_p
|
|
133
|
+
alias_method :mkpath, :mkdir_p
|
|
134
|
+
|
|
135
|
+
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
|
|
136
|
+
cmd = "mv#{force ? " -f" : ""} #{[src, dest].flatten.join(" ")}"
|
|
137
|
+
|
|
138
|
+
Chef::Log.debug cmd if verbose
|
|
139
|
+
return if noop
|
|
140
|
+
|
|
141
|
+
run_command(cmd)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def rm(list, force: nil, noop: nil, verbose: nil)
|
|
145
|
+
cmd = "rm#{force ? " -f" : ""} #{Array(list).join(" ")}"
|
|
146
|
+
|
|
147
|
+
Chef::Log.debug cmd if verbose
|
|
148
|
+
return if noop
|
|
149
|
+
|
|
150
|
+
run_command(cmd)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def rm_f(list, force: nil, noop: nil, verbose: nil, secure: nil)
|
|
154
|
+
rm(list, force: true, noop: noop, verbose: verbose)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
|
|
158
|
+
cmd = "rm -r#{force ? "f" : ""} #{Array(list).join(" ")}"
|
|
159
|
+
|
|
160
|
+
Chef::Log.debug cmd if verbose
|
|
161
|
+
return if noop
|
|
162
|
+
|
|
163
|
+
run_command(cmd)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
|
|
167
|
+
rm_r(list, force: true, noop: noop, verbose: verbose, secure: secure)
|
|
168
|
+
end
|
|
169
|
+
alias_method :remove_entry, :rm_rf
|
|
170
|
+
alias_method :rmtree, :rm_rf
|
|
171
|
+
alias_method :safe_unlink, :rm_rf
|
|
172
|
+
|
|
173
|
+
def rmdir(list, parents: nil, noop: nil, verbose: nil)
|
|
174
|
+
cmd = "rmdir #{parents ? "-p " : ""}#{Array(list).join(" ")}"
|
|
175
|
+
|
|
176
|
+
Chef::Log.debug cmd if verbose
|
|
177
|
+
return if noop
|
|
178
|
+
|
|
179
|
+
run_command(cmd)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def touch(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)
|
|
183
|
+
return if noop
|
|
184
|
+
|
|
185
|
+
run_command "touch #{nocreate ? "-c " : ""}#{mtime ? mtime.strftime("-t %Y%m%d%H%M.%S ") : ""}#{Array(list).join(" ")}"
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def method_missing(m, *_args, **_kwargs, &_block)
|
|
189
|
+
raise "Unsupported #{self.class} method #{m}"
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
private
|
|
193
|
+
|
|
194
|
+
# TODO: Symbolic modes
|
|
195
|
+
def __mode_to_s(mode)
|
|
196
|
+
mode.to_s(8)
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require_relative "../support"
|
|
2
|
+
|
|
3
|
+
module TargetIO
|
|
4
|
+
module TrainCompat
|
|
5
|
+
class HTTP
|
|
6
|
+
include TargetIO::Support
|
|
7
|
+
|
|
8
|
+
attr_reader :last_response
|
|
9
|
+
|
|
10
|
+
def initialize(url, options = {})
|
|
11
|
+
@url = url.is_a?(URI) ? url.to_s : url
|
|
12
|
+
@options = options
|
|
13
|
+
@last_response = ""
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Send an HTTP HEAD request to the path
|
|
17
|
+
#
|
|
18
|
+
# === Parameters
|
|
19
|
+
# path:: path part of the request URL
|
|
20
|
+
def head(path, headers = {})
|
|
21
|
+
request(:HEAD, path, headers)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Send an HTTP GET request to the path
|
|
25
|
+
#
|
|
26
|
+
# === Parameters
|
|
27
|
+
# path:: The path to GET
|
|
28
|
+
def get(path, headers = {})
|
|
29
|
+
request(:GET, path, headers)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Send an HTTP PUT request to the path
|
|
33
|
+
#
|
|
34
|
+
# === Parameters
|
|
35
|
+
# path:: path part of the request URL
|
|
36
|
+
def put(path, json, headers = {})
|
|
37
|
+
request(:PUT, path, headers, json)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Send an HTTP POST request to the path
|
|
41
|
+
#
|
|
42
|
+
# === Parameters
|
|
43
|
+
# path:: path part of the request URL
|
|
44
|
+
def post(path, json, headers = {})
|
|
45
|
+
request(:POST, path, headers, json)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Send an HTTP DELETE request to the path
|
|
49
|
+
#
|
|
50
|
+
# === Parameters
|
|
51
|
+
# path:: path part of the request URL
|
|
52
|
+
def delete(path, headers = {})
|
|
53
|
+
request(:DELETE, path, headers)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Used inside Chef::Provider::RemoteFile::HTTPS
|
|
57
|
+
def streaming_request(path, headers = {}, tempfile = nil)
|
|
58
|
+
content = get(path, headers)
|
|
59
|
+
@last_response = content
|
|
60
|
+
|
|
61
|
+
tempfile.write(content)
|
|
62
|
+
tempfile.close
|
|
63
|
+
|
|
64
|
+
tempfile
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def request(method, path, headers = {}, data = false)
|
|
68
|
+
cmd = nil
|
|
69
|
+
path = path.is_a?(URI) ? path.to_s : path
|
|
70
|
+
headers.merge!(@options[:headers] || {})
|
|
71
|
+
|
|
72
|
+
SUPPORTED_COMMANDS.each do |command_name|
|
|
73
|
+
executable = which(command_name).chop
|
|
74
|
+
next if !executable || executable.empty?
|
|
75
|
+
|
|
76
|
+
# There are different ways to call (constructor, argument, combination of both)
|
|
77
|
+
full_url = if path.start_with?("http")
|
|
78
|
+
path
|
|
79
|
+
elsif path.empty? || @url.end_with?(path)
|
|
80
|
+
@url
|
|
81
|
+
else
|
|
82
|
+
File.join(@url, path)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
cmd = send(command_name.to_sym, executable, method.to_s.upcase, full_url, headers, data)
|
|
86
|
+
break
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
raise "Target needs one of #{SUPPORTED_COMMANDS.join("/")} for HTTP requests to work" unless cmd
|
|
90
|
+
|
|
91
|
+
run_command(cmd).stdout
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
SUPPORTED_COMMANDS = %w{curl wget}.freeze
|
|
95
|
+
|
|
96
|
+
# Sending data is not yet supported
|
|
97
|
+
def curl(cmd, method, url, headers, _data)
|
|
98
|
+
cmd += headers.map { |name, value| " --header '#{name}: #{value}'" }.join
|
|
99
|
+
cmd += " --request #{method} "
|
|
100
|
+
cmd += url
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Sending data is not yet supported
|
|
104
|
+
def wget(cmd, method, url, headers, _data)
|
|
105
|
+
cmd += headers.map { |name, value| " --header '#{name}: #{value}'" }.join
|
|
106
|
+
cmd += " --method #{method}"
|
|
107
|
+
cmd += " --output-document=- "
|
|
108
|
+
cmd += url
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# extend Chef::Mixin::Which
|
|
112
|
+
def which(cmd)
|
|
113
|
+
run_command("which #{cmd}").stdout
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require_relative "../support"
|
|
2
|
+
|
|
3
|
+
module TargetIO
|
|
4
|
+
module TrainCompat
|
|
5
|
+
module Shadow
|
|
6
|
+
# @see https://www.rubydoc.info/gems/ruby-shadow/2.5.0
|
|
7
|
+
class Passwd
|
|
8
|
+
class << self
|
|
9
|
+
def getspnam(name)
|
|
10
|
+
content = ::TargetIO::File.read("/etc/shadow")
|
|
11
|
+
entries = __parse_shadow(content)
|
|
12
|
+
data = entries.detect { |entry| entry["name"] == name }
|
|
13
|
+
return ::TargetIO::Shadow::Entry.new unless data
|
|
14
|
+
|
|
15
|
+
::TargetIO::Shadow::Entry.new(
|
|
16
|
+
data["sp_namp"],
|
|
17
|
+
data["sp_pwdp"],
|
|
18
|
+
data["sp_lstchg"],
|
|
19
|
+
data["sp_min"],
|
|
20
|
+
data["sp_max"],
|
|
21
|
+
data["sp_warn"],
|
|
22
|
+
data["sp_inact"],
|
|
23
|
+
data["sp_expire"],
|
|
24
|
+
data["sp_loginclass"]
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def __parse_shadow(content)
|
|
29
|
+
content.to_s.split("\n").map do |line|
|
|
30
|
+
next if line[0] == "#"
|
|
31
|
+
|
|
32
|
+
__parse_shadow_line(line)
|
|
33
|
+
end.compact
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def __parse_shadow_line(line)
|
|
37
|
+
x = line.split(":")
|
|
38
|
+
{
|
|
39
|
+
# rubocop:disable Layout/AlignHash
|
|
40
|
+
"sp_namp" => x.at(0),
|
|
41
|
+
"sp_pwdp" => x.at(1),
|
|
42
|
+
"sp_lstchg" => x.at(2),
|
|
43
|
+
"sp_min" => x.at(3),
|
|
44
|
+
"sp_max" => x.at(4),
|
|
45
|
+
"sp_warn" => x.at(5),
|
|
46
|
+
"sp_inact" => x.at(6),
|
|
47
|
+
"sp_expire" => x.at(7),
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|