chef 17.10.163 → 18.7.10
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 +25 -21
- data/README.md +7 -7
- data/Rakefile +3 -22
- data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
- data/chef.gemspec +33 -27
- data/lib/chef/api_client_v1.rb +9 -1
- data/lib/chef/application/base.rb +20 -2
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +21 -7
- data/lib/chef/chef_fs/path_utils.rb +7 -9
- data/lib/chef/client.rb +186 -2
- data/lib/chef/compliance/default_attributes.rb +2 -2
- data/lib/chef/compliance/input.rb +1 -1
- data/lib/chef/compliance/profile.rb +1 -1
- data/lib/chef/compliance/profile_collection.rb +0 -1
- data/lib/chef/compliance/runner.rb +6 -1
- data/lib/chef/compliance/waiver.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +4 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
- data/lib/chef/cookbook/synchronizer.rb +21 -3
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- data/lib/chef/cookbook_manifest.rb +2 -2
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/data_collector.rb +14 -0
- data/lib/chef/delayed_evaluator.rb +4 -0
- data/lib/chef/dsl/reader_helpers.rb +1 -1
- data/lib/chef/dsl/rest_resource.rb +77 -0
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +0 -1
- data/lib/chef/exceptions.rb +9 -1
- data/lib/chef/file_access_control/windows.rb +4 -1
- data/lib/chef/file_cache.rb +17 -2
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
- data/lib/chef/http/authenticator.rb +253 -3
- data/lib/chef/http/ssl_policies.rb +2 -2
- data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
- data/lib/chef/mixin/openssl_helper.rb +1 -16
- data/lib/chef/mixin/powershell_exec.rb +5 -28
- data/lib/chef/monkey_patches/net-http.rb +127 -0
- data/lib/chef/node/attribute.rb +3 -11
- data/lib/chef/node/attribute_collections.rb +10 -1
- data/lib/chef/node/immutable_collections.rb +17 -6
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/node/mixin/state_tracking.rb +7 -4
- data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
- data/lib/chef/node.rb +23 -1
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/policy_builder/policyfile.rb +8 -0
- data/lib/chef/property.rb +13 -6
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/http_request.rb +11 -9
- data/lib/chef/provider/launchd.rb +2 -1
- data/lib/chef/provider/mount/linux.rb +6 -1
- data/lib/chef/provider/mount/mount.rb +13 -5
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package/apt.rb +11 -2
- data/lib/chef/provider/package/chocolatey.rb +260 -22
- data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
- data/lib/chef/provider/package/homebrew.rb +6 -9
- data/lib/chef/provider/package/powershell.rb +1 -0
- data/lib/chef/provider/package/rubygems.rb +5 -1
- data/lib/chef/provider/package/snap.rb +3 -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/yum/yum_helper.py +3 -3
- data/lib/chef/provider/package/zypper/version.rb +60 -0
- data/lib/chef/provider/package/zypper.rb +47 -3
- data/lib/chef/provider/powershell_script.rb +96 -6
- data/lib/chef/provider/registry_key.rb +2 -0
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +23 -8
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/service.rb +14 -0
- data/lib/chef/provider/user/aix.rb +5 -0
- data/lib/chef/provider/user/linux.rb +29 -0
- data/lib/chef/provider/user/mac.rb +1 -1
- data/lib/chef/provider/user/windows.rb +5 -0
- data/lib/chef/provider/user.rb +45 -9
- data/lib/chef/provider/yum_repository.rb +13 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/recipe.rb +4 -12
- data/lib/chef/resource/_rest_resource.rb +389 -0
- data/lib/chef/resource/alternatives.rb +0 -1
- data/lib/chef/resource/apt_package.rb +21 -1
- data/lib/chef/resource/apt_preference.rb +0 -1
- data/lib/chef/resource/apt_repository.rb +138 -18
- data/lib/chef/resource/apt_update.rb +0 -1
- data/lib/chef/resource/archive_file.rb +0 -1
- data/lib/chef/resource/bash.rb +13 -1
- data/lib/chef/resource/batch.rb +0 -1
- data/lib/chef/resource/bff_package.rb +0 -1
- data/lib/chef/resource/breakpoint.rb +0 -1
- data/lib/chef/resource/build_essential.rb +0 -1
- data/lib/chef/resource/cab_package.rb +0 -1
- data/lib/chef/resource/chef_client_config.rb +12 -14
- data/lib/chef/resource/chef_client_cron.rb +1 -2
- data/lib/chef/resource/chef_client_launchd.rb +2 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
- data/lib/chef/resource/chef_client_systemd_timer.rb +5 -1
- data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -2
- data/lib/chef/resource/chef_handler.rb +0 -1
- data/lib/chef/resource/chef_sleep.rb +1 -3
- data/lib/chef/resource/chef_vault_secret.rb +0 -1
- data/lib/chef/resource/chocolatey_config.rb +0 -1
- data/lib/chef/resource/chocolatey_feature.rb +0 -1
- data/lib/chef/resource/chocolatey_installer.rb +207 -0
- data/lib/chef/resource/chocolatey_package.rb +8 -1
- data/lib/chef/resource/chocolatey_source.rb +0 -1
- data/lib/chef/resource/cookbook_file.rb +0 -1
- data/lib/chef/resource/cron/_cron_shared.rb +0 -1
- data/lib/chef/resource/cron/cron.rb +0 -1
- data/lib/chef/resource/cron/cron_d.rb +15 -1
- data/lib/chef/resource/cron_access.rb +0 -1
- data/lib/chef/resource/csh.rb +0 -1
- data/lib/chef/resource/directory.rb +0 -1
- data/lib/chef/resource/dmg_package.rb +2 -1
- data/lib/chef/resource/dnf_package.rb +0 -1
- data/lib/chef/resource/dpkg_package.rb +0 -1
- data/lib/chef/resource/dsc_resource.rb +0 -1
- data/lib/chef/resource/dsc_script.rb +1 -2
- data/lib/chef/resource/execute.rb +8 -7
- data/lib/chef/resource/file.rb +0 -1
- data/lib/chef/resource/freebsd_package.rb +2 -1
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +25 -2
- data/lib/chef/resource/habitat/habitat_package.rb +0 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
- data/lib/chef/resource/habitat_config.rb +0 -1
- data/lib/chef/resource/habitat_install.rb +2 -2
- data/lib/chef/resource/habitat_service.rb +0 -1
- data/lib/chef/resource/habitat_user_toml.rb +0 -1
- data/lib/chef/resource/homebrew_cask.rb +21 -33
- data/lib/chef/resource/homebrew_package.rb +3 -2
- data/lib/chef/resource/homebrew_tap.rb +32 -18
- data/lib/chef/resource/homebrew_update.rb +4 -6
- data/lib/chef/resource/hostname.rb +0 -1
- data/lib/chef/resource/http_request.rb +0 -1
- data/lib/chef/resource/ifconfig.rb +0 -1
- data/lib/chef/resource/inspec_input.rb +0 -1
- data/lib/chef/resource/inspec_waiver.rb +0 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
- data/lib/chef/resource/ips_package.rb +0 -1
- data/lib/chef/resource/kernel_module.rb +0 -1
- data/lib/chef/resource/ksh.rb +0 -1
- data/lib/chef/resource/launchd.rb +9 -3
- data/lib/chef/resource/link.rb +0 -1
- data/lib/chef/resource/locale.rb +0 -1
- data/lib/chef/resource/log.rb +0 -1
- data/lib/chef/resource/lwrp_base.rb +0 -4
- data/lib/chef/resource/macos_pkg.rb +111 -0
- data/lib/chef/resource/macos_userdefaults.rb +3 -4
- data/lib/chef/resource/macosx_service.rb +0 -1
- data/lib/chef/resource/macports_package.rb +2 -1
- data/lib/chef/resource/mdadm.rb +0 -1
- data/lib/chef/resource/mount.rb +0 -1
- data/lib/chef/resource/msu_package.rb +0 -1
- data/lib/chef/resource/notify_group.rb +0 -2
- data/lib/chef/resource/ohai.rb +0 -1
- data/lib/chef/resource/ohai_hint.rb +0 -1
- data/lib/chef/resource/openbsd_package.rb +2 -1
- data/lib/chef/resource/openssl_dhparam.rb +0 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
- data/lib/chef/resource/openssl_x509_crl.rb +0 -2
- data/lib/chef/resource/openssl_x509_request.rb +0 -2
- data/lib/chef/resource/osx_profile.rb +0 -1
- data/lib/chef/resource/package.rb +0 -1
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +0 -1
- data/lib/chef/resource/perl.rb +0 -1
- data/lib/chef/resource/plist.rb +7 -3
- data/lib/chef/resource/portage_package.rb +2 -1
- data/lib/chef/resource/powershell_package.rb +4 -1
- data/lib/chef/resource/powershell_package_source.rb +0 -1
- data/lib/chef/resource/powershell_script.rb +5 -2
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +6 -1
- data/lib/chef/resource/remote_directory.rb +0 -1
- data/lib/chef/resource/remote_file.rb +0 -1
- data/lib/chef/resource/rhsm_errata.rb +0 -1
- data/lib/chef/resource/rhsm_errata_level.rb +0 -1
- data/lib/chef/resource/rhsm_register.rb +2 -4
- data/lib/chef/resource/rhsm_repo.rb +0 -1
- data/lib/chef/resource/rhsm_subscription.rb +0 -1
- data/lib/chef/resource/route.rb +0 -1
- data/lib/chef/resource/rpm_package.rb +2 -1
- data/lib/chef/resource/ruby.rb +0 -1
- data/lib/chef/resource/ruby_block.rb +0 -1
- data/lib/chef/resource/scm/_scm.rb +0 -2
- data/lib/chef/resource/scm/git.rb +0 -2
- data/lib/chef/resource/scm/subversion.rb +0 -2
- data/lib/chef/resource/script.rb +0 -1
- data/lib/chef/resource/selinux/common_helpers.rb +47 -0
- data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
- data/lib/chef/resource/selinux/selinux_default.erb +15 -0
- data/lib/chef/resource/selinux_boolean.rb +101 -0
- data/lib/chef/resource/selinux_fcontext.rb +160 -0
- data/lib/chef/resource/selinux_install.rb +107 -0
- data/lib/chef/resource/selinux_login.rb +129 -0
- data/lib/chef/resource/selinux_module.rb +143 -0
- data/lib/chef/resource/selinux_permissive.rb +64 -0
- data/lib/chef/resource/selinux_port.rb +118 -0
- data/lib/chef/resource/selinux_state.rb +166 -0
- data/lib/chef/resource/selinux_user.rb +137 -0
- data/lib/chef/resource/service.rb +4 -2
- data/lib/chef/resource/smartos_package.rb +2 -1
- data/lib/chef/resource/snap_package.rb +25 -1
- data/lib/chef/resource/solaris_package.rb +2 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
- data/lib/chef/resource/sudo.rb +37 -3
- data/lib/chef/resource/support/client.erb +2 -2
- data/lib/chef/resource/support/ulimit.erb +40 -0
- data/lib/chef/resource/swap_file.rb +0 -1
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +0 -1
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +0 -1
- data/lib/chef/resource/user/aix_user.rb +0 -1
- data/lib/chef/resource/user/linux_user.rb +0 -1
- data/lib/chef/resource/user/mac_user.rb +0 -1
- data/lib/chef/resource/user/pw_user.rb +0 -1
- data/lib/chef/resource/user/solaris_user.rb +0 -1
- data/lib/chef/resource/user/windows_user.rb +0 -1
- data/lib/chef/resource/user.rb +10 -1
- data/lib/chef/resource/user_ulimit.rb +38 -1
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
- data/lib/chef/resource/windows_ad_join.rb +0 -2
- data/lib/chef/resource/windows_audit_policy.rb +0 -2
- data/lib/chef/resource/windows_auto_run.rb +0 -1
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +0 -1
- data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
- data/lib/chef/resource/windows_dfs_folder.rb +0 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
- data/lib/chef/resource/windows_dfs_server.rb +0 -1
- data/lib/chef/resource/windows_dns_record.rb +0 -1
- data/lib/chef/resource/windows_dns_zone.rb +0 -1
- data/lib/chef/resource/windows_env.rb +0 -1
- data/lib/chef/resource/windows_feature.rb +0 -1
- data/lib/chef/resource/windows_feature_dism.rb +0 -1
- data/lib/chef/resource/windows_feature_powershell.rb +0 -1
- data/lib/chef/resource/windows_firewall_profile.rb +0 -2
- data/lib/chef/resource/windows_firewall_rule.rb +0 -1
- data/lib/chef/resource/windows_font.rb +2 -3
- data/lib/chef/resource/windows_package.rb +3 -4
- data/lib/chef/resource/windows_pagefile.rb +0 -2
- data/lib/chef/resource/windows_path.rb +0 -1
- data/lib/chef/resource/windows_printer.rb +0 -1
- data/lib/chef/resource/windows_printer_port.rb +0 -1
- data/lib/chef/resource/windows_script.rb +0 -2
- data/lib/chef/resource/windows_security_policy.rb +2 -3
- data/lib/chef/resource/windows_service.rb +0 -1
- data/lib/chef/resource/windows_share.rb +0 -1
- data/lib/chef/resource/windows_shortcut.rb +1 -2
- data/lib/chef/resource/windows_task.rb +0 -1
- data/lib/chef/resource/windows_uac.rb +0 -1
- data/lib/chef/resource/windows_update_settings.rb +0 -1
- data/lib/chef/resource/windows_user_privilege.rb +14 -11
- data/lib/chef/resource/windows_workgroup.rb +0 -1
- data/lib/chef/resource/yum_package.rb +2 -1
- data/lib/chef/resource/yum_repository.rb +4 -1
- data/lib/chef/resource/zypper_package.rb +2 -1
- data/lib/chef/resource/zypper_repository.rb +0 -1
- data/lib/chef/resource.rb +23 -5
- data/lib/chef/resource_inspector.rb +25 -7
- data/lib/chef/resource_reporter.rb +4 -0
- data/lib/chef/resources.rb +11 -0
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
- data/lib/chef/util/powershell/ps_credential.rb +10 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/handle.rb +6 -7
- data/lib/chef/win32/registry.rb +12 -4
- data/lib/chef/win32/security.rb +16 -1
- data/spec/data/rubygems.org/sexp_processor-info +2 -1
- data/spec/data/trusted_certs/intermediate.pem +38 -27
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +1 -1
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +26 -42
- data/spec/functional/resource/link_spec.rb +8 -8
- data/spec/functional/resource/plist_spec.rb +25 -0
- data/spec/functional/resource/registry_spec.rb +233 -609
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/user/linux_user_spec.rb +127 -0
- data/spec/functional/resource/windows_certificate_spec.rb +1 -1
- data/spec/functional/resource/windows_font_spec.rb +12 -9
- data/spec/functional/resource/yum_package_spec.rb +1 -1
- data/spec/functional/resource/zypper_package_spec.rb +12 -0
- data/spec/functional/shell_spec.rb +1 -2
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/registry_spec.rb +0 -3
- data/spec/integration/client/client_spec.rb +88 -3
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/fips_spec.rb +5 -5
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/client/open_ssl_spec.rb +3 -3
- data/spec/integration/compliance/compliance_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/remote_directory.rb +1 -1
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/integration/recipes/use_partial_spec.rb +2 -1
- data/spec/integration/solo/solo_spec.rb +2 -2
- data/spec/spec_helper.rb +7 -4
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/platform_helpers.rb +28 -7
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/tiny_server.rb +5 -2
- data/spec/unit/application/client_spec.rb +0 -10
- data/spec/unit/chef_fs/file_system_spec.rb +2 -0
- data/spec/unit/client_spec.rb +80 -4
- data/spec/unit/compliance/runner_spec.rb +8 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/data_collector_spec.rb +106 -2
- data/spec/unit/delayed_evaluator_spec.rb +35 -0
- data/spec/unit/file_cache_spec.rb +64 -0
- data/spec/unit/http/authenticator_spec.rb +121 -0
- data/spec/unit/mixin/homebrew_spec.rb +118 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
- data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
- data/spec/unit/node/vivid_mash_spec.rb +42 -0
- data/spec/unit/node_spec.rb +6 -0
- data/spec/unit/platform/query_helpers_spec.rb +2 -17
- data/spec/unit/property/validation_spec.rb +30 -0
- data/spec/unit/provider/apt_repository_spec.rb +48 -12
- data/spec/unit/provider/cron_spec.rb +2 -0
- data/spec/unit/provider/http_request_spec.rb +60 -72
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +15 -4
- data/spec/unit/provider/mount/mount_spec.rb +8 -8
- data/spec/unit/provider/package/apt_spec.rb +18 -13
- data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
- data/spec/unit/provider/package/homebrew_spec.rb +4 -1
- data/spec/unit/provider/package/rpm_spec.rb +2 -2
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +5 -5
- data/spec/unit/provider/package/zypper_spec.rb +32 -0
- data/spec/unit/provider/powershell_script_spec.rb +100 -4
- data/spec/unit/provider/registry_key_spec.rb +17 -17
- data/spec/unit/provider/remote_file/http_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
- data/spec/unit/provider/user/linux_spec.rb +51 -1
- data/spec/unit/provider/user/windows_spec.rb +1 -0
- data/spec/unit/provider/user_spec.rb +24 -6
- data/spec/unit/resource/apt_repository_spec.rb +5 -0
- data/spec/unit/resource/archive_file_spec.rb +1 -1
- data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
- data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
- data/spec/unit/resource/cron_d_spec.rb +37 -1
- data/spec/unit/resource/macos_pkg_spec.rb +38 -0
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/rest_resource_spec.rb +381 -0
- data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
- data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
- data/spec/unit/resource/selinux_install_spec.rb +60 -0
- data/spec/unit/resource/selinux_login_spec.rb +73 -0
- data/spec/unit/resource/selinux_module_spec.rb +55 -0
- data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
- data/spec/unit/resource/selinux_port_spec.rb +42 -0
- data/spec/unit/resource/selinux_state_spec.rb +46 -0
- data/spec/unit/resource/selinux_user_spec.rb +92 -0
- data/spec/unit/resource/sysctl_spec.rb +2 -2
- data/spec/unit/resource/user/linux_user_spec.rb +42 -0
- data/spec/unit/resource/yum_repository_spec.rb +4 -0
- data/spec/unit/resource_inspector_spec.rb +36 -0
- data/spec/unit/resource_reporter_spec.rb +57 -3
- data/spec/unit/resource_spec.rb +94 -2
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
- data/tasks/rspec.rb +1 -1
- metadata +126 -44
- data/lib/chef/powershell.rb +0 -81
- data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
- /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
|
@@ -23,8 +23,6 @@ class Chef
|
|
|
23
23
|
require_relative "../mixin/openssl_helper"
|
|
24
24
|
include Chef::Mixin::OpenSSLHelper
|
|
25
25
|
|
|
26
|
-
unified_mode true
|
|
27
|
-
|
|
28
26
|
provides(:openssl_dhparam) { true }
|
|
29
27
|
|
|
30
28
|
description "Use the **openssl_dhparam** resource to generate `dhparam.pem` files. If a valid `dhparam.pem` file is found at the specified location, no new file will be created. If a file is found at the specified location but it is not a valid `dhparam.pem` file, it will be overwritten."
|
|
@@ -24,8 +24,6 @@ class Chef
|
|
|
24
24
|
require_relative "../mixin/openssl_helper"
|
|
25
25
|
include Chef::Mixin::OpenSSLHelper
|
|
26
26
|
|
|
27
|
-
unified_mode true
|
|
28
|
-
|
|
29
27
|
provides :openssl_ec_private_key
|
|
30
28
|
|
|
31
29
|
description "Use the **openssl_ec_private_key** resource to generate an elliptic curve (EC) private key file. If a valid EC key file can be opened at the specified location, no new file will be created. If the EC key file cannot be opened, either because it does not exist or because the password to the EC key file does not match the password in the recipe, then it will be overwritten."
|
|
@@ -24,8 +24,6 @@ class Chef
|
|
|
24
24
|
require_relative "../mixin/openssl_helper"
|
|
25
25
|
include Chef::Mixin::OpenSSLHelper
|
|
26
26
|
|
|
27
|
-
unified_mode true
|
|
28
|
-
|
|
29
27
|
provides :openssl_ec_public_key
|
|
30
28
|
|
|
31
29
|
description "Use the **openssl_ec_public_key** resource to generate elliptic curve (EC) public key files from a given EC private key."
|
|
@@ -24,8 +24,6 @@ class Chef
|
|
|
24
24
|
require_relative "../mixin/openssl_helper"
|
|
25
25
|
include Chef::Mixin::OpenSSLHelper
|
|
26
26
|
|
|
27
|
-
unified_mode true
|
|
28
|
-
|
|
29
27
|
provides :openssl_x509_crl
|
|
30
28
|
|
|
31
29
|
description "Use the **openssl_x509_crl** resource to generate PEM-formatted x509 certificate revocation list (CRL) files."
|
|
@@ -24,8 +24,6 @@ class Chef
|
|
|
24
24
|
require_relative "../mixin/openssl_helper"
|
|
25
25
|
include Chef::Mixin::OpenSSLHelper
|
|
26
26
|
|
|
27
|
-
unified_mode true
|
|
28
|
-
|
|
29
27
|
provides :openssl_x509_request
|
|
30
28
|
|
|
31
29
|
description "Use the **openssl_x509_request** resource to generate PEM-formatted x509 certificates requests. If no existing key is specified, the resource will automatically generate a passwordless key with the certificate."
|
|
@@ -21,10 +21,11 @@ require_relative "package"
|
|
|
21
21
|
class Chef
|
|
22
22
|
class Resource
|
|
23
23
|
class PacmanPackage < Chef::Resource::Package
|
|
24
|
-
unified_mode true
|
|
25
24
|
|
|
26
25
|
provides :pacman_package
|
|
27
26
|
|
|
27
|
+
allowed_actions :install, :upgrade, :remove, :purge
|
|
28
|
+
|
|
28
29
|
description "Use the **pacman_package** resource to manage packages (using pacman) on the Arch Linux platform."
|
|
29
30
|
end
|
|
30
31
|
end
|
data/lib/chef/resource/perl.rb
CHANGED
data/lib/chef/resource/plist.rb
CHANGED
|
@@ -22,7 +22,6 @@ class Chef
|
|
|
22
22
|
class Resource
|
|
23
23
|
|
|
24
24
|
class PlistResource < Chef::Resource # we name this PlistResource to avoid confusion with Plist from the plist gem
|
|
25
|
-
unified_mode true
|
|
26
25
|
|
|
27
26
|
provides :plist
|
|
28
27
|
|
|
@@ -85,7 +84,7 @@ class Chef
|
|
|
85
84
|
converge_if_changed :path do
|
|
86
85
|
converge_by "create new plist: '#{new_resource.path}'" do
|
|
87
86
|
file new_resource.path do
|
|
88
|
-
content
|
|
87
|
+
content({}.to_plist)
|
|
89
88
|
owner new_resource.owner
|
|
90
89
|
group new_resource.group
|
|
91
90
|
mode new_resource.mode if property_is_set?(:mode)
|
|
@@ -189,7 +188,12 @@ class Chef
|
|
|
189
188
|
sep = " "
|
|
190
189
|
arg = case subcommand.to_s
|
|
191
190
|
when "add"
|
|
192
|
-
|
|
191
|
+
if value.is_a?(Hash)
|
|
192
|
+
sep = ":"
|
|
193
|
+
value.map { |k, v| "#{k} #{type_to_commandline_string(v)}" }
|
|
194
|
+
else
|
|
195
|
+
type_to_commandline_string(value)
|
|
196
|
+
end
|
|
193
197
|
when "set"
|
|
194
198
|
if value.is_a?(Hash)
|
|
195
199
|
sep = ":"
|
|
@@ -21,12 +21,13 @@ require_relative "package"
|
|
|
21
21
|
class Chef
|
|
22
22
|
class Resource
|
|
23
23
|
class PortagePackage < Chef::Resource::Package
|
|
24
|
-
unified_mode true
|
|
25
24
|
|
|
26
25
|
provides :portage_package
|
|
27
26
|
|
|
28
27
|
description "Use the **portage_package** resource to manage packages for the Gentoo platform."
|
|
29
28
|
|
|
29
|
+
allowed_actions :install, :upgrade, :remove, :purge
|
|
30
|
+
|
|
30
31
|
property :package_name, String,
|
|
31
32
|
description: "An optional property to set the package name if it differs from the resource block's name.",
|
|
32
33
|
identity: true
|
|
@@ -20,7 +20,6 @@ require_relative "package"
|
|
|
20
20
|
class Chef
|
|
21
21
|
class Resource
|
|
22
22
|
class PowershellPackage < Chef::Resource::Package
|
|
23
|
-
unified_mode true
|
|
24
23
|
|
|
25
24
|
provides :powershell_package
|
|
26
25
|
|
|
@@ -45,6 +44,10 @@ class Chef
|
|
|
45
44
|
description: "Skip validating module author.",
|
|
46
45
|
default: false, introduced: "14.3", desired_state: false
|
|
47
46
|
|
|
47
|
+
property :allow_clobber, [TrueClass, FalseClass],
|
|
48
|
+
description: "Overrides warning messages about installation conflicts about existing commands on a computer.",
|
|
49
|
+
default: false, introduced: "18.5"
|
|
50
|
+
|
|
48
51
|
end
|
|
49
52
|
end
|
|
50
53
|
end
|
|
@@ -20,9 +20,8 @@ require_relative "windows_script"
|
|
|
20
20
|
class Chef
|
|
21
21
|
class Resource
|
|
22
22
|
class PowershellScript < Chef::Resource::WindowsScript
|
|
23
|
-
unified_mode true
|
|
24
23
|
|
|
25
|
-
set_guard_inherited_attributes(:interpreter)
|
|
24
|
+
set_guard_inherited_attributes(:interpreter, :use_inline_powershell)
|
|
26
25
|
|
|
27
26
|
provides :powershell_script, os: "windows"
|
|
28
27
|
|
|
@@ -40,6 +39,10 @@ class Chef
|
|
|
40
39
|
equal_to: %w{powershell pwsh},
|
|
41
40
|
description: "The interpreter type, `powershell` or `pwsh` (PowerShell Core)"
|
|
42
41
|
|
|
42
|
+
property :use_inline_powershell, [true, false],
|
|
43
|
+
default: false,
|
|
44
|
+
description: "Use inline powershell.dll rather than shelling out - this is faster, but could have different semantics to the traditional method. In particular, it does not allow for streaming output, nor does it allow for passing custom parameters to the interpreter"
|
|
45
|
+
|
|
43
46
|
property :convert_boolean_return, [true, false],
|
|
44
47
|
default: false,
|
|
45
48
|
description: <<~DESC
|
data/lib/chef/resource/python.rb
CHANGED
data/lib/chef/resource/reboot.rb
CHANGED
|
@@ -23,7 +23,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
|
23
23
|
class Chef
|
|
24
24
|
class Resource
|
|
25
25
|
class RegistryKey < Chef::Resource
|
|
26
|
-
unified_mode true
|
|
27
26
|
|
|
28
27
|
provides(:registry_key) { true }
|
|
29
28
|
|
|
@@ -51,6 +50,7 @@ class Chef
|
|
|
51
50
|
:type => :binary,
|
|
52
51
|
:data => [0, 1, 2].map(&:chr).join
|
|
53
52
|
}]
|
|
53
|
+
|
|
54
54
|
action :create
|
|
55
55
|
end
|
|
56
56
|
```
|
|
@@ -151,6 +151,11 @@ class Chef
|
|
|
151
151
|
}
|
|
152
152
|
property :recursive, [TrueClass, FalseClass], default: false
|
|
153
153
|
property :architecture, Symbol, default: :machine, equal_to: %i{machine x86_64 i386}
|
|
154
|
+
property :only_record_changes, [TrueClass, FalseClass],
|
|
155
|
+
default: true,
|
|
156
|
+
introduced: "18.7.3",
|
|
157
|
+
description: "(no-op) disabled functionality to only record registry value changes",
|
|
158
|
+
deprecated: true
|
|
154
159
|
|
|
155
160
|
# Some registry key data types may not be safely reported as json.
|
|
156
161
|
# Example (CHEF-5323):
|
|
@@ -20,7 +20,6 @@ require_relative "../resource"
|
|
|
20
20
|
class Chef
|
|
21
21
|
class Resource
|
|
22
22
|
class RhsmErrata < Chef::Resource
|
|
23
|
-
unified_mode true
|
|
24
23
|
provides(:rhsm_errata) { true }
|
|
25
24
|
|
|
26
25
|
description "Use the **rhsm_errata** resource to install packages associated with a given Red Hat Subscription Manager Errata ID. This is helpful if packages to mitigate a single vulnerability must be installed on your hosts."
|
|
@@ -20,7 +20,6 @@ require_relative "../resource"
|
|
|
20
20
|
class Chef
|
|
21
21
|
class Resource
|
|
22
22
|
class RhsmErrataLevel < Chef::Resource
|
|
23
|
-
unified_mode true
|
|
24
23
|
provides(:rhsm_errata_level) { true }
|
|
25
24
|
|
|
26
25
|
description "Use the **rhsm_errata_level** resource to install all packages of a specified errata level from the Red Hat Subscription Manager. For example, you can ensure that all packages associated with errata marked at a 'Critical' security level are installed."
|
|
@@ -22,7 +22,6 @@ require "shellwords" unless defined?(Shellwords)
|
|
|
22
22
|
class Chef
|
|
23
23
|
class Resource
|
|
24
24
|
class RhsmRegister < Chef::Resource
|
|
25
|
-
unified_mode true
|
|
26
25
|
provides(:rhsm_register) { true }
|
|
27
26
|
|
|
28
27
|
description "Use the **rhsm_register** resource to register a node with the Red Hat Subscription Manager or a local Red Hat Satellite server."
|
|
@@ -93,7 +92,7 @@ class Chef
|
|
|
93
92
|
|
|
94
93
|
property :release,
|
|
95
94
|
[Float, String],
|
|
96
|
-
description: "Sets the operating system minor release to use for subscriptions for the system. Products and updates are limited to the specified minor release version. This is used
|
|
95
|
+
description: "Sets the operating system minor release to use for subscriptions for the system. Products and updates are limited to the specified minor release version. This is used with the `auto_attach` or `activation_key` options. For example, `release '6.4'` will append `--release=6.4` to the register command.",
|
|
97
96
|
introduced: "17.8"
|
|
98
97
|
|
|
99
98
|
action :register, description: "Register the node with RHSM." do
|
|
@@ -137,8 +136,6 @@ class Chef
|
|
|
137
136
|
end
|
|
138
137
|
|
|
139
138
|
action :unregister, description: "Unregister the node from RHSM." do
|
|
140
|
-
description "Unregister the node from RHSM."
|
|
141
|
-
|
|
142
139
|
package flush_package_cache_name do
|
|
143
140
|
action :nothing
|
|
144
141
|
end
|
|
@@ -208,6 +205,7 @@ class Chef
|
|
|
208
205
|
command << "--name=#{Shellwords.shellescape(new_resource.system_name)}" if new_resource.system_name
|
|
209
206
|
command << "--serverurl=#{Shellwords.shellescape(new_resource.server_url)}" if new_resource.server_url
|
|
210
207
|
command << "--baseurl=#{Shellwords.shellescape(new_resource.base_url)}" if new_resource.base_url
|
|
208
|
+
command << "--release=#{Shellwords.shellescape(new_resource.release)}" if new_resource.release
|
|
211
209
|
command << "--force" if new_resource.force
|
|
212
210
|
|
|
213
211
|
return command.join(" ")
|
data/lib/chef/resource/route.rb
CHANGED
|
@@ -21,10 +21,11 @@ require_relative "package"
|
|
|
21
21
|
class Chef
|
|
22
22
|
class Resource
|
|
23
23
|
class RpmPackage < Chef::Resource::Package
|
|
24
|
-
unified_mode true
|
|
25
24
|
|
|
26
25
|
provides :rpm_package
|
|
27
26
|
|
|
27
|
+
allowed_actions :install, :upgrade, :remove
|
|
28
|
+
|
|
28
29
|
description "Use the **rpm_package** resource to manage packages using the RPM Package Manager."
|
|
29
30
|
|
|
30
31
|
property :allow_downgrade, [ TrueClass, FalseClass ],
|
data/lib/chef/resource/ruby.rb
CHANGED
|
@@ -23,8 +23,6 @@ class Chef
|
|
|
23
23
|
class Git < Chef::Resource
|
|
24
24
|
use "scm"
|
|
25
25
|
|
|
26
|
-
unified_mode true
|
|
27
|
-
|
|
28
26
|
provides :git
|
|
29
27
|
|
|
30
28
|
description "Use the **git** resource to manage source control resources that exist in a git repository. git version 1.6.5 (or higher) is required to use all of the functionality in the git resource."
|
|
@@ -24,8 +24,6 @@ class Chef
|
|
|
24
24
|
class Subversion < Chef::Resource
|
|
25
25
|
use "scm"
|
|
26
26
|
|
|
27
|
-
unified_mode true
|
|
28
|
-
|
|
29
27
|
provides :subversion
|
|
30
28
|
|
|
31
29
|
description "Use the **subversion** resource to manage source control resources that exist in a Subversion repository. Warning: The subversion resource has known bugs and may not work as expected. For more information see Chef GitHub issues, particularly [#4050](https://github.com/chef/chef/issues/4050) and [#4257](https://github.com/chef/chef/issues/4257)."
|
data/lib/chef/resource/script.rb
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
#
|
|
14
|
+
class Chef
|
|
15
|
+
module SELinux
|
|
16
|
+
module CommonHelpers
|
|
17
|
+
def selinux_disabled?
|
|
18
|
+
selinux_state.eql?(:disabled)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def selinux_enforcing?
|
|
22
|
+
selinux_state.eql?(:enforcing)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def selinux_permissive?
|
|
26
|
+
selinux_state.eql?(:permissive)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def state_change_reboot_required?
|
|
30
|
+
(selinux_disabled? && %i{enforcing permissive}.include?(action)) || ((selinux_enforcing? || selinux_permissive?) && action == :disabled)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def selinux_state
|
|
34
|
+
state = shell_out!("getenforce").stdout.strip.downcase.to_sym
|
|
35
|
+
raise "Got unknown SELinux state #{state}" unless %i{disabled enforcing permissive}.include?(state)
|
|
36
|
+
|
|
37
|
+
state
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def selinux_activate_required?
|
|
41
|
+
return false unless platform_family?("debian")
|
|
42
|
+
|
|
43
|
+
!File.read("/etc/default/grub").match?("security=selinux")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Chef for <%= node['fqdn'] %>
|
|
2
|
+
# Do NOT modify this file by hand.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
# This file controls the state of SELinux on the system.
|
|
6
|
+
# SELINUX= can take one of these three values:
|
|
7
|
+
# enforcing - SELinux security policy is enforced.
|
|
8
|
+
# permissive - SELinux prints warnings instead of enforcing.
|
|
9
|
+
# disabled - No SELinux policy is loaded.
|
|
10
|
+
SELINUX=<%= @selinux %>
|
|
11
|
+
# SELINUXTYPE= can take one of these three values:
|
|
12
|
+
# default - equivalent to the old strict and targeted policies
|
|
13
|
+
# mls - Multi-Level Security (for military and educational use)
|
|
14
|
+
# src - Custom policy built from source
|
|
15
|
+
SELINUXTYPE=<%= @selinuxtype %>
|
|
16
|
+
|
|
17
|
+
# SETLOCALDEFS= Check local definition changes
|
|
18
|
+
SETLOCALDEFS=0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Generated by Chef for <%= node['fqdn'] %>
|
|
2
|
+
# Do NOT modify this file by hand.
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
# This file controls the state of SELinux on the system.
|
|
6
|
+
# SELINUX= can take one of these three values:
|
|
7
|
+
# enforcing - SELinux security policy is enforced.
|
|
8
|
+
# permissive - SELinux prints warnings instead of enforcing.
|
|
9
|
+
# disabled - No SELinux policy is loaded.
|
|
10
|
+
SELINUX=<%= @selinux %>
|
|
11
|
+
# SELINUXTYPE= can take one of these three values:
|
|
12
|
+
# targeted - Targeted processes are protected,
|
|
13
|
+
# minimum - Modification of targeted policy. Only selected processes are protected.
|
|
14
|
+
# mls - Multi Level Security protection.
|
|
15
|
+
SELINUXTYPE=<%= @selinuxtype %>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
# you may not use this file except in compliance with the License.
|
|
4
|
+
# You may obtain a copy of the License at
|
|
5
|
+
#
|
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
#
|
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
# See the License for the specific language governing permissions and
|
|
12
|
+
# limitations under the License.
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
require_relative "../resource"
|
|
16
|
+
require_relative "selinux/common_helpers"
|
|
17
|
+
|
|
18
|
+
class Chef
|
|
19
|
+
class Resource
|
|
20
|
+
class SelinuxBoolean < Chef::Resource
|
|
21
|
+
unified_mode true
|
|
22
|
+
|
|
23
|
+
provides :selinux_boolean
|
|
24
|
+
|
|
25
|
+
description "Use **selinux_boolean** resource to set SELinux boolean values."
|
|
26
|
+
introduced "18.0"
|
|
27
|
+
examples <<~DOC
|
|
28
|
+
**Set ssh_keysign to true**:
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
selinux_boolean 'ssh_keysign' do
|
|
32
|
+
value true
|
|
33
|
+
end
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Set ssh_sysadm_login to 'on'**:
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
selinux_boolean 'ssh_sysadm_login' do
|
|
40
|
+
value 'on'
|
|
41
|
+
end
|
|
42
|
+
```
|
|
43
|
+
DOC
|
|
44
|
+
|
|
45
|
+
property :boolean, String,
|
|
46
|
+
name_property: true,
|
|
47
|
+
description: "SELinux boolean to set."
|
|
48
|
+
|
|
49
|
+
property :value, [Integer, String, true, false],
|
|
50
|
+
required: true,
|
|
51
|
+
equal_to: %w{on off},
|
|
52
|
+
coerce: proc { |p| selinux_bool(p) },
|
|
53
|
+
description: "SELinux boolean value."
|
|
54
|
+
|
|
55
|
+
property :persistent, [true, false],
|
|
56
|
+
default: true,
|
|
57
|
+
desired_state: false,
|
|
58
|
+
description: "Set to true for value setting to survive reboot."
|
|
59
|
+
|
|
60
|
+
load_current_value do |new_resource|
|
|
61
|
+
value shell_out!("getsebool", new_resource.boolean).stdout.split("-->").map(&:strip).last
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
action_class do
|
|
65
|
+
include Chef::SELinux::CommonHelpers
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
action :set , description: "Set the state of the boolean." do
|
|
69
|
+
if selinux_disabled?
|
|
70
|
+
Chef::Log.warn("Unable to set SELinux boolean #{new_resource.name} as SELinux is disabled")
|
|
71
|
+
return
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
converge_if_changed do
|
|
75
|
+
cmd = "setsebool"
|
|
76
|
+
cmd += " -P" if new_resource.persistent
|
|
77
|
+
cmd += " #{new_resource.boolean} #{new_resource.value}"
|
|
78
|
+
|
|
79
|
+
shell_out!(cmd)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
#
|
|
86
|
+
# Validate and return input boolean value in required format
|
|
87
|
+
# @param bool [String, Integer, Boolean] Input boolean value in allowed formats
|
|
88
|
+
#
|
|
89
|
+
# @return [String] [description] Boolean value in required format
|
|
90
|
+
def selinux_bool(bool)
|
|
91
|
+
if ["on", "true", "1", true, 1].include?(bool)
|
|
92
|
+
"on"
|
|
93
|
+
elsif ["off", "false", "0", false, 0].include?(bool)
|
|
94
|
+
"off"
|
|
95
|
+
else
|
|
96
|
+
raise ArgumentError, "selinux_bool: Invalid selinux boolean value #{bool}"
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|