diff options
32 files changed, 492 insertions, 80 deletions
diff --git a/.expeditor/release.omnibus.yml b/.expeditor/release.omnibus.yml index edc24e028e..d4cd857f8e 100644 --- a/.expeditor/release.omnibus.yml +++ b/.expeditor/release.omnibus.yml @@ -40,12 +40,15 @@ builder-to-testers-map: sles-12-x86_64: - sles-12-x86_64 - sles-15-x86_64 + sles-15-aarch64: + - sles-15-aarch64 # solaris2-5.11-i386: # - solaris2-5.11-i386 # solaris2-5.11-sparc: # - solaris2-5.11-sparc ubuntu-18.04-aarch64: - ubuntu-18.04-aarch64 + - ubuntu-20.04-aarch64 ubuntu-16.04-x86_64: - ubuntu-16.04-x86_64 - ubuntu-18.04-x86_64 diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index d2389cde90..11827bd89b 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -1,5 +1,7 @@ --- expeditor: + cached_folders: + - vendor defaults: buildkite: retry: @@ -44,8 +46,6 @@ steps: - bundle exec rake spec:unit - bundle exec rake component_specs expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 @@ -80,8 +80,6 @@ steps: - bundle exec rake spec:unit - bundle exec rake component_specs expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/centos-7 @@ -118,8 +116,6 @@ steps: - bundle exec rake spec:unit - bundle exec rake component_specs expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/opensuse-15 @@ -157,8 +153,6 @@ steps: - bundle exec rake spec:unit - bundle exec rake component_specs expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/fedora-latest @@ -167,8 +161,6 @@ steps: commands: - /workdir/scripts/bk_tests/bk_win_integration.ps1 expeditor: - cached_folders: - - vendor executor: docker: host_os: windows @@ -181,8 +173,6 @@ steps: commands: - scripts/bk_tests/bk_win_functional.ps1 expeditor: - cached_folders: - - vendor executor: windows: privileged: true @@ -192,8 +182,6 @@ steps: commands: - /workdir/scripts/bk_tests/bk_run_choco.ps1 expeditor: - cached_folders: - - vendor executor: docker: host_os: windows @@ -203,8 +191,6 @@ steps: commands: - /workdir/scripts/bk_tests/bk_win_unit.ps1 expeditor: - cached_folders: - - vendor executor: docker: host_os: windows @@ -219,8 +205,6 @@ steps: - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen ruby_prof - bundle exec rake style expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 @@ -260,8 +244,6 @@ steps: - bundle exec rake spec:unit - bundle exec rake component_specs expeditor: - cached_folders: - - vendor executor: docker: image: ruby:2.7-buster @@ -276,8 +258,6 @@ steps: - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen - bundle exec tasks/bin/run_external_test chef/chef-sugar master rake expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 @@ -288,8 +268,6 @@ steps: - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen - bundle exec tasks/bin/run_external_test chef/chef-zero master rake pedant expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 @@ -303,8 +281,6 @@ steps: - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen - bundle exec tasks/bin/run_external_test chef/cheffish master rake spec expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 @@ -315,8 +291,6 @@ steps: - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen - bundle exec tasks/bin/run_external_test chefspec/chefspec master rake expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 @@ -327,8 +301,6 @@ steps: - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen - bundle exec tasks/bin/run_external_test chef/knife-windows master rake spec expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 @@ -342,8 +314,6 @@ steps: - bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package docgen - bundle exec tasks/bin/run_external_test berkshelf/berkshelf master rake expeditor: - cached_folders: - - vendor executor: docker: image: rubydistros/ubuntu-18.04 diff --git a/CHANGELOG.md b/CHANGELOG.md index 86b6ec5506..00933a7a47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,22 @@ <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ --> -<!-- latest_release 16.0.234 --> -## [v16.0.234](https://github.com/chef/chef/tree/v16.0.234) (2020-04-21) +<!-- latest_release 16.0.239 --> +## [v16.0.239](https://github.com/chef/chef/tree/v16.0.239) (2020-04-23) #### Merged Pull Requests -- Update omnibus-software again to bring in double pry fixes [#9704](https://github.com/chef/chef/pull/9704) ([tas50](https://github.com/tas50)) +- Minor improvements to the resource descriptions [#9725](https://github.com/chef/chef/pull/9725) ([tas50](https://github.com/tas50)) +- Enable caching of all our buildkite jobs again [#9672](https://github.com/chef/chef/pull/9672) ([tas50](https://github.com/tas50)) <!-- latest_release --> <!-- release_rollup since=15.6.10 --> ### Changes not yet released to stable #### Merged Pull Requests +- Minor improvements to the resource descriptions [#9725](https://github.com/chef/chef/pull/9725) ([tas50](https://github.com/tas50)) <!-- 16.0.239 --> +- Enable caching of all our buildkite jobs again [#9672](https://github.com/chef/chef/pull/9672) ([tas50](https://github.com/tas50)) <!-- 16.0.238 --> +- Make sure all the non-multipackage packge resources can't take arrays [#9721](https://github.com/chef/chef/pull/9721) ([tas50](https://github.com/tas50)) <!-- 16.0.238 --> +- Fix for Chocolate_resource options causing extra quotes [#9509](https://github.com/chef/chef/pull/9509) ([kapilchouhan99](https://github.com/kapilchouhan99)) <!-- 16.0.237 --> +- Use the new Chef definition w/o appbundler [#9710](https://github.com/chef/chef/pull/9710) ([tas50](https://github.com/tas50)) <!-- 16.0.236 --> +- Add Ubuntu 20.04 + SLES 15 aarch64 Testers [#9712](https://github.com/chef/chef/pull/9712) ([christopher-snapp](https://github.com/christopher-snapp)) <!-- 16.0.235 --> - Update omnibus-software again to bring in double pry fixes [#9704](https://github.com/chef/chef/pull/9704) ([tas50](https://github.com/tas50)) <!-- 16.0.234 --> - Remove the unused simplecov depedency [#9699](https://github.com/chef/chef/pull/9699) ([tas50](https://github.com/tas50)) <!-- 16.0.233 --> - Bump omnibus-software to avoid double pry [#9700](https://github.com/chef/chef/pull/9700) ([tas50](https://github.com/tas50)) <!-- 16.0.232 --> diff --git a/Gemfile.lock b/Gemfile.lock index 40c81471a0..288e7eeab2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,12 +27,12 @@ GIT PATH remote: . specs: - chef (16.0.234) + chef (16.0.239) addressable bcrypt_pbkdf (~> 1.0) bundler (>= 1.10) - chef-config (= 16.0.234) - chef-utils (= 16.0.234) + chef-config (= 16.0.239) + chef-utils (= 16.0.239) chef-vault chef-zero (>= 14.0.11) diff-lcs (~> 1.2, >= 1.2.4) @@ -61,12 +61,12 @@ PATH train-winrm (>= 0.2.5) tty-screen (~> 0.6) uuidtools (~> 2.1.5) - chef (16.0.234-universal-mingw32) + chef (16.0.239-universal-mingw32) addressable bcrypt_pbkdf (~> 1.0) bundler (>= 1.10) - chef-config (= 16.0.234) - chef-utils (= 16.0.234) + chef-config (= 16.0.239) + chef-utils (= 16.0.239) chef-vault chef-zero (>= 14.0.11) diff-lcs (~> 1.2, >= 1.2.4) @@ -111,15 +111,15 @@ PATH PATH remote: chef-bin specs: - chef-bin (16.0.234) - chef (= 16.0.234) + chef-bin (16.0.239) + chef (= 16.0.239) PATH remote: chef-config specs: - chef-config (16.0.234) + chef-config (16.0.239) addressable - chef-utils (= 16.0.234) + chef-utils (= 16.0.239) fuzzyurl mixlib-config (>= 2.2.12, < 4.0) mixlib-shellout (>= 2.0, < 4.0) @@ -128,7 +128,7 @@ PATH PATH remote: chef-utils specs: - chef-utils (16.0.234) + chef-utils (16.0.239) GEM remote: https://rubygems.org/ diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 2e957e4d20..ee282e862f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,36 @@ This file holds "in progress" release notes for the current release under development and is intended for consumption by the Chef Documentation team. Please see <https://docs.chef.io/release_notes/> for the official Chef release notes. + +# Chef Infra Client 15.10 + +## Improvements + +- The `systemd_unit` resource now respects the `sensitive` property and will no longer output the contents of the unit file to logs if this is set. +- A new `arm?` helper has been added which can be used in recipes and resources to determine if a system is on the ARM architecture. + +## Bug Fixes + +- Resolved a bug that prevented users from bootstrapping nodes using knife when specifying the `--use_sudo_password`. +- Resolved a bug that prevented the `--bootstrap-version` flag from being honored when bootstrapping in knife. + +## Chef InSpec 4.18.104 + +- Resolved a regression that prevented the `service` resource from working correctly on Windows. Thanks [@Axuba](https://github.com/Axuba) +- Implemented VMware and Hyper-V detection on Linux systems +- Implemented VMware, Hyper-V, Virtualbox, KVM and Xen detection on Windows systems +- Added helpers `virtual_system?` and `physical_system?`. Thanks [@tecracer-theinen](https://github.com/tecracer-theinen) + +## Ohai 15.9 + +- Improve the resilency of the `Shard` plugin when `dmidecode` cannot be found on a system. Thanks [@jaymzh](https://github.com/jaymzh) +- Fixed detection of Openstack guests via DMI data. Thanks [@ramereth](https://github.com/ramereth) + +## Platform Support + +### Amazon Linux 2 + +Chef Infra Client is now tested on Amazon Linux 2 running on x86_64 and aarch64 with packages available on the [Chef Downloads Page](https://downloads.chef.io/chef). + # Chef Infra Client 15.9 ## Chef InSpec 4.18.100 @@ -7,7 +38,7 @@ This file holds "in progress" release notes for the current release under develo Chef InSpec has been updated from 4.18.85 to 4.18.100: - Resolved several failures in executing resources -- Fixed auditd resource processing of action and list +- Fixed `auditd` resource processing of action and list - Fixed platform detection when running in Habitat - "inspec schema" has been revised to be in the JSON Schema draft 7 format - Improved the functionality of the `oracledb_session` resource @@ -1130,6 +1161,177 @@ The `refresh_plugins` method in the `Ohai::System` class has been removed as it The `Virtualization` plugin will no longer detect systems running on the circa ~2005 VirtualPC or VirtualServer hypervisors. These hypervisors were long ago deprecated by Microsoft and support can no longer be tested. +# Chef Client Release Notes 14.15 + +## Updated Resources + +### ifconfig + +The `ifconfig` resource has been updated to properly support interfaces with a hyphen in their name. This is most commonly encountered with bridge interfaces that are named `br-1234`. Additionally, the `ifconfig` resource now supports the latest ifconfig binaries found in OS releases such as Debian 10. + +### windows_task + +The `windows_task` resource now supports the Start When Available option with a new `start_when_available` property. Issues that prevented the resource from being idempotent on Windows 2016 and 2019 hosts have also been resolved. + +## Platform Support + +### New Platforms + +Chef Infra Client is now tested against the following platforms with packages available on [downloads.chef.io](https://downloads.chef.io): + +- Ubuntu 20.04 +- Ubuntu 18.04 aarch64 +- Debian 10 + +### Retired Platforms + + - Chef Infra Clients packages are no longer produced for Windows 2008 R2 as this release reached its end of life on Jan 14th, 2020. + - Chef Infra Client packages are no longer produced for RHEL 6 on the s390x platform. + +## Security Updates + +### OpenSSL + +OpenSSL has been updated to 1.0.2u to resolve [CVE-2019-1551](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-1551) + +### Ruby + +Ruby has been updated from 2.5.7 to 2.5.8 to resolve the following CVEs: + + - [CVE-2020-16255](https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/): Unsafe Object Creation Vulnerability in JSON (Additional fix) + - [CVE-2020-10933](https://www.ruby-lang.org/en/news/2020/03/31/heap-exposure-in-socket-cve-2020-10933/): Heap exposure vulnerability in the socket library + + +# Chef Client Release Notes 14.14.29 + +## Bug Fixes + + - Fixed an error with the `service` and `systemd_unit` resources which would try to re-enable services with an indirect status. + - The `systemd_unit` resource now logs at the info level. + - Fixed knife config when it returned a `TypeError: no implicit conversion of nil into String` error. + +## Security Updates + +### libxslt + +libxslt has been updated to 1.1.34 to resolve [CVE-2019-13118](https://nvd.nist.gov/vuln/detail/CVE-2019-13118). + +# Chef Client Release Notes 14.14.25 + +## Bug Fixes + +- Resolved a regression introduced in Chef Infra Client 14.14.14 that broke installation of gems in some scenarios +- Fixed Habitat packaging of `chef-client` artifacts +- Fixed crash in knife when displaying a missing profile error message +- Fixed knife subcommand --help not working as intended for some commands +- Fixed knife ssh interactive mode exit error +- Fixed for `:day`` option not accepting integer value in the `windows_task` resource +- Fixed for `user` resource not handling a GID if it is specified as a string +- Fixed the `ifconfig` resource to support interfaces with a `-` in the name + +# Chef Client Release Notes 14.14 + +## Platform Updates + +### Newly Supported Platforms + +The following platforms are now packaged and tested for Chef Infra Client: + +- Red Hat 8 +- FreeBSD 12 +- macOS 10.15 +- Windows 2019 +- AIX 7.2 + +### Deprecated Platforms + +The following platforms have reached EOL status and are no longer packaged or tested for Chef Infra Client: + +- FreeBSD 10 +- macOS 10.12 +- SUSE Linux Enterprise Server (SLES) 11 +- Ubuntu 14.04 + +See Chef's [Platform End-of-Life Policy](https://docs.chef.io/platforms.html#platform-end-of-life-policy) for more information on when Chef ends support for an OS release. + +## Updated Resources + +### dnf_package + +The `dnf_package` resource has been updated to fully support RHEL 8. + +### zypper_package + +The `zypper_package` resource has been updated to properly update packages when using the `:upgrade` action. + +### remote_file + +The `remote_file` resource now properly shows download progress when the `show_progress` property is set to true. + +## Improvements + +## Custom Resource Unified Mode + +Chef Infra Client 14.14 introduces an exciting new way to easily write custom resources that mix built-in Chef Infra resources with Ruby code. Previously, custom resources would use Chef Infra's standard compile and converge phases, which meant that Ruby would be evaluated first and then the resources would be converged. This often results in confusing and undesirable behavior when you are trying to mix resources with Ruby logic. Many custom resource authors would attempt to get around this by forcing resources to run at compile time so that all the code in their resource would execute during the compile phase. + +An example of forcing a resource to run at compile time: + +```ruby +resource_name 'foo' do + action :nothing +end.run_action(:some_action) +``` + +With unified mode, you opt in to a single phase per resource where all Ruby and Chef Infra resources are executed at once. This makes it far easier to determine how your code will be evaluated and run. Additionally, you no longer need to force any resources to run at compile time, as all code is run in the compile phase. To enable this new mode just add `unified_mode true` to your resources like this: + +```ruby +property :Some_property, String + +unified_mode true + +action :create do + # some code +end +``` + +### New Options for installing Ruby Gems From metadata.rb + +Chef Infra Client allows gems to be specified in the cookbook metadata.rb, which can be problematic in some environments. When a cookbook is running in an airgapped environment, Chef Infra Client attempts to connect to rubygems.org even if the gem is already on the system. There are now two additional configuration options that can be set in your `client.rb` config: + - `gem_installer_bundler_options`: This allows setting additional bundler options for the install such as --local to install from local cache. Example: ["--local", "--clean"]. + - `skip_gem_metadata_installation`: If set to true skip gem metadata installation if all gems are already installed. + +### SLES / openSUSE 15 detection + +Ohai now properly detects SLES and openSUSE 15.x. Thanks for this fix [@balasankarc](https://gitlab.com/balasankarc). + +### Performance Improvements + +We have improved the performance of Chef Infra Client by resolving bundler errors in our packaging. + +### Bootstrapping Chef Infra Client 15 will no fail + +Knife now fails with a descriptive error message when attempting to bootstrap nodes with Chef Infra Client 15. You will need to bootstrap these nodes using Knife from Chef Infra Client 15.x. We recommend performing this bootstrap from Chef Workstation, which includes the Knife CLI in addition to other useful tools for managing your infrastructure with Chef Infra. + +## Security Updates + +### Ruby + +Ruby has been updated from 2.5.5 to 2.5.7 in order to resolve the following CVEs: + - [CVE-2012-6708](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-6708) + - [CVE-2015-9251](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-9251). + - [CVE-2019-16201](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-15845). + - [CVE-2019-15845](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-9251). + - [CVE-2019-16254](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-16254). + - [CVE-2019-16255](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-16255). + +### openssl + +openssl has been updated from 1.0.2s to 1.0.2t in order to resolve [CVE-2019-1563](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-1563) and [CVE-2019-1547](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-1547). + +### nokogiri + +nokogori has been updated from 1.10.2 to 1.10.4 in order to resolve [CVE-2019-5477](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-5477). + # Chef Infra Client Release Notes 14.13: ## Updated Resources @@ -1171,7 +1373,19 @@ The `CHEF-25` deprecation for resource collisions between cookbooks and resource - openssl 1.0.2r -> 1.0.2s (bugfix only release) - cacerts 2019-01-23 -> 2019-05-15 -# Chef Infra Client Release Notes 14.12: +# Chef Client Release Notes 14.12.9: + +## License Acceptance Placeholder Flag + +In preparation for Chef Infra Client 15.0 we've added a placeholder `--chef-license` flag to the chef-client command. This allows you to use the new `--chef-license` flag on both Chef Infra Client 14.12.9+ and 15+ notes without producing errors on Chef Infra Client 14. + +## Important Bug Fixes + +- Blacklisting and whiteliting default and override level attributes is once again possible. +- You may now encrypt a previously unencrypted data bag. +- Resolved a regression introduced in Chef Infra Client 14.12.3 that resulted in errors when managing Windows services + +# Chef Infra Client Release Notes 14.12.3: ## Updated Resources @@ -1244,8 +1458,6 @@ RubyGems has been updated to 2.7.9 in order to resolve the following CVEs: - [CVE-2019-8324](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-8324): Installing a malicious gem may lead to arbitrary code execution - [CVE-2019-8325](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-8325): Escape sequence injection vulnerability in errors - - # Chef Client Release Notes 14.10: ## Updated Resources @@ -1469,7 +1681,7 @@ macOS support has been added to the timezone resource. ### windows_task -A regression in Chef 14.6’s windows_task resource which resulted in tasks being created with the "Run only when user is logged on" option being set when created with a specific user other than SYSTEM, has been resolved. +A regression in Chef 14.6's windows_task resource which resulted in tasks being created with the "Run only when user is logged on" option being set when created with a specific user other than SYSTEM, has been resolved. # Chef Client Release Notes 14.6: @@ -1971,7 +2183,7 @@ Ohai now detects the virtualization hypervisor `amazonec2` when running on Amazo # Chef Client Release Notes 14.1.12: -This release resolves a number of regressions in 14.1: +This release resolves a number of regressions in 14.1.1: - `git` resource: don't use `--prune-tags` as it's really new. - `rhsm_repo` resource: now works @@ -1 +1 @@ -16.0.234
\ No newline at end of file +16.0.239
\ No newline at end of file diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb index 80030dab54..8b97e20153 100644 --- a/chef-bin/lib/chef-bin/version.rb +++ b/chef-bin/lib/chef-bin/version.rb @@ -21,7 +21,7 @@ module ChefBin CHEFBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "16.0.234".freeze + VERSION = "16.0.239".freeze end # diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 5179fe71ac..6ca2eff159 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -15,5 +15,5 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) - VERSION = "16.0.234".freeze + VERSION = "16.0.239".freeze end diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb index 143e78af75..5b6a3f1011 100644 --- a/chef-utils/lib/chef-utils/version.rb +++ b/chef-utils/lib/chef-utils/version.rb @@ -15,5 +15,5 @@ module ChefUtils CHEFUTILS_ROOT = File.expand_path("../..", __FILE__) - VERSION = "16.0.234".freeze + VERSION = "16.0.239".freeze end diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb index f1f7dac8ce..f1f2307f5b 100644 --- a/lib/chef/provider/package/chocolatey.rb +++ b/lib/chef/provider/package/chocolatey.rb @@ -17,14 +17,15 @@ require_relative "../package" require_relative "../../resource/chocolatey_package" +require_relative "../../win32/api/command_line_helper" if ChefUtils.windows? class Chef class Provider class Package class Chocolatey < Chef::Provider::Package + include Chef::ReservedNames::Win32::API::CommandLineHelper if ChefUtils.windows? provides :chocolatey_package - # Declare that our arguments should be arrays use_multipackage_api @@ -207,7 +208,7 @@ class Chef # @param include_source [Boolean] should the source parameter be added # @return [String] options from new_resource or empty string def cmd_args(include_source: true) - cmd_args = [ new_resource.options ] + cmd_args = new_resource.options.is_a?(String) ? command_line_to_argv_w_helper(new_resource.options) : Array(new_resource.options) cmd_args += common_options(include_source: include_source) cmd_args end diff --git a/lib/chef/resource/bff_package.rb b/lib/chef/resource/bff_package.rb index 297cdb93a4..625d48626e 100644 --- a/lib/chef/resource/bff_package.rb +++ b/lib/chef/resource/bff_package.rb @@ -27,6 +27,13 @@ class Chef description "Use the bff_package resource to manage packages for the AIX platform using the installp utility. When a package is installed from a local file, it must be added to the node using the remote_file or cookbook_file resources." introduced "12.0" + + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." end end end diff --git a/lib/chef/resource/cab_package.rb b/lib/chef/resource/cab_package.rb index 37a8e32548..f0a6063477 100644 --- a/lib/chef/resource/cab_package.rb +++ b/lib/chef/resource/cab_package.rb @@ -32,6 +32,13 @@ class Chef allowed_actions :install, :remove + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + property :source, String, description: "The local file path or URL for the CAB package.", coerce: (proc do |s| diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb index 2d6613b771..bee7c265b0 100644 --- a/lib/chef/resource/chef_gem.rb +++ b/lib/chef/resource/chef_gem.rb @@ -38,6 +38,13 @@ class Chef unified_mode true provides :chef_gem + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + property :gem_binary, default: "#{RbConfig::CONFIG["bindir"]}/gem", default_description: "Chef's built-in gem binary.", description: "The path of a gem binary to use for the installation. By default, the same version of Ruby that is used by the #{Chef::Dist::CLIENT} will be installed.", callbacks: { diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb index 18ba96624d..eda415526e 100644 --- a/lib/chef/resource/gem_package.rb +++ b/lib/chef/resource/gem_package.rb @@ -27,6 +27,13 @@ class Chef description "Use the gem_package resource to manage gem packages that are only included in recipes. When a package is installed from a local file, it must be added to the node using the remote_file or cookbook_file resources." + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + # the source can either be a path to a package source like: # source /var/tmp/mygem-1.2.3.4.gem # or it can be a url rubygems source like: diff --git a/lib/chef/resource/ips_package.rb b/lib/chef/resource/ips_package.rb index fd8e1617b5..4a6c745b8c 100644 --- a/lib/chef/resource/ips_package.rb +++ b/lib/chef/resource/ips_package.rb @@ -31,6 +31,13 @@ class Chef allowed_actions :install, :remove, :upgrade + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + property :accept_license, [TrueClass, FalseClass], default: false, desired_state: false, description: "Accept an end-user license agreement, automatically." diff --git a/lib/chef/resource/macports_package.rb b/lib/chef/resource/macports_package.rb index 96d9dceabf..acc10900f4 100644 --- a/lib/chef/resource/macports_package.rb +++ b/lib/chef/resource/macports_package.rb @@ -24,7 +24,14 @@ class Chef unified_mode true provides :macports_package - description "Use the macports_package resource to manage packages for the macOS platform." + description "Use the macports_package resource to manage packages for the macOS platform using the MacPorts package management system." + + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." end end end diff --git a/lib/chef/resource/msu_package.rb b/lib/chef/resource/msu_package.rb index d07d7893a3..29a9538995 100644 --- a/lib/chef/resource/msu_package.rb +++ b/lib/chef/resource/msu_package.rb @@ -33,6 +33,13 @@ class Chef allowed_actions :install, :remove default_action :install + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + property :source, String, description: "The local file path or URL for the MSU package.", coerce: (proc do |s| diff --git a/lib/chef/resource/openbsd_package.rb b/lib/chef/resource/openbsd_package.rb index ce4b1fc0ce..645aea12c8 100644 --- a/lib/chef/resource/openbsd_package.rb +++ b/lib/chef/resource/openbsd_package.rb @@ -31,6 +31,13 @@ class Chef description "Use the openbsd_package resource to manage packages for the OpenBSD platform." introduced "12.1" + + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." end end end diff --git a/lib/chef/resource/paludis_package.rb b/lib/chef/resource/paludis_package.rb index 49ad2cc96c..1d3fb0f44c 100644 --- a/lib/chef/resource/paludis_package.rb +++ b/lib/chef/resource/paludis_package.rb @@ -31,6 +31,13 @@ class Chef allowed_actions :install, :remove, :upgrade + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + property :timeout, [String, Integer], description: "The amount of time (in seconds) to wait before timing out.", default: 3600, diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb index 9da03b4221..28fa1d6217 100644 --- a/lib/chef/resource/portage_package.rb +++ b/lib/chef/resource/portage_package.rb @@ -27,6 +27,13 @@ class Chef description "Use the portage_package resource to manage packages for the Gentoo platform." + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + property :timeout, [String, Integer], default: 3600, description: "The amount of time (in seconds) to wait before timing out.", diff --git a/lib/chef/resource/rpm_package.rb b/lib/chef/resource/rpm_package.rb index 3661ca1daa..b944142dcb 100644 --- a/lib/chef/resource/rpm_package.rb +++ b/lib/chef/resource/rpm_package.rb @@ -25,10 +25,16 @@ class Chef provides :rpm_package - description "Use the rpm_package resource to manage packages for the RPM Package Manager platform." + description "Use the rpm_package resource to manage packages using the RPM Package Manager." property :allow_downgrade, [ true, false ], default: true, desired_state: false + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." end end end diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb index 88a5621c9f..f7e1a013ef 100644 --- a/lib/chef/resource/script.rb +++ b/lib/chef/resource/script.rb @@ -47,10 +47,13 @@ class Chef end end - property :code, String, required: true + property :code, String, required: true, + description: "A quoted string of code to be executed." + property :interpreter, String - property :flags, String + property :flags, String, + description: "One or more command line flags that are passed to the interpreter when a command is invoked." end end end diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb index 25cc84b163..50a7dda437 100644 --- a/lib/chef/resource/service.rb +++ b/lib/chef/resource/service.rb @@ -82,7 +82,7 @@ class Chef # specify overrides for the start_command, stop_command and # restart_command properties. property :init_command, String, - description: "The path to the init script that is associated with the service. Use init_command to prevent the need to specify overrides for the start_command, stop_command, and restart_command properties. When this property is not specified, the #{Chef::Dist::CLIENT} will use the default init command for the service provider being used.", + description: "The path to the init script that is associated with the service. Use init_command to prevent the need to specify overrides for the start_command, stop_command, and restart_command properties. When this property is not specified, the #{Chef::Dist::PRODUCT} will use the default init command for the service provider being used.", desired_state: false # if the service is enabled or not diff --git a/lib/chef/resource/smartos_package.rb b/lib/chef/resource/smartos_package.rb index a11b642d56..eb37b804d5 100644 --- a/lib/chef/resource/smartos_package.rb +++ b/lib/chef/resource/smartos_package.rb @@ -27,6 +27,13 @@ class Chef provides :package, platform_family: "smartos" description "Use the smartos_package resource to manage packages for the SmartOS platform." + + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." end end end diff --git a/lib/chef/resource/solaris_package.rb b/lib/chef/resource/solaris_package.rb index 46550386c7..6a07cede40 100644 --- a/lib/chef/resource/solaris_package.rb +++ b/lib/chef/resource/solaris_package.rb @@ -29,6 +29,13 @@ class Chef provides :package, os: "solaris2", platform_family: "solaris2", platform_version: "<= 5.10" description "The solaris_package resource is used to manage packages for the Solaris platform." + + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." end end end diff --git a/lib/chef/resource/windows_firewall_rule.rb b/lib/chef/resource/windows_firewall_rule.rb index 7bb69a271f..fcba0dc569 100644 --- a/lib/chef/resource/windows_firewall_rule.rb +++ b/lib/chef/resource/windows_firewall_rule.rb @@ -78,6 +78,7 @@ class Chef property :displayname, String, description: "The displayname to assign to the firewall rule.", default: lazy { rule_name }, + default_description: "The rule_name property value.", introduced: "16.0" property :group, String, diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb index 0d9a5f39fa..ccedd654bd 100644 --- a/lib/chef/resource/windows_package.rb +++ b/lib/chef/resource/windows_package.rb @@ -40,6 +40,13 @@ class Chef @source ||= source(@package_name) if @package_name.downcase.end_with?(".msi") end + property :package_name, String, + description: "An optional property to set the package name if it differs from the resource block's name.", + identity: true + + property :version, String, + description: "The version of a package to be installed or upgraded." + # windows can't take array options yet property :options, String, description: "One (or more) additional options that are passed to the command." diff --git a/lib/chef/version.rb b/lib/chef/version.rb index 1ab34aa2f4..350f838402 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -23,7 +23,7 @@ require_relative "version_string" class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = Chef::VersionString.new("16.0.234") + VERSION = Chef::VersionString.new("16.0.239") end # diff --git a/lib/chef/win32/api/command_line_helper.rb b/lib/chef/win32/api/command_line_helper.rb new file mode 100644 index 0000000000..6ddc74ae0f --- /dev/null +++ b/lib/chef/win32/api/command_line_helper.rb @@ -0,0 +1,89 @@ +# +# Author:: Kapil Chouhan <kapil.chouhan@msystechnologies.com> +# Copyright:: Copyright 2013-2020, Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require_relative "../api" + +class Chef + module ReservedNames::Win32 + module API + module CommandLineHelper + # extend Chef::ReservedNames::Win32 + extend Chef::ReservedNames::Win32::API + + ############################################### + # Win32 API Bindings + ############################################### + + ffi_lib "Shell32" + +=begin +LPWSTR * CommandLineToArgvW( + LPCWSTR lpCmdLine, + int *pNumArgs +); +=end + + safe_attach_function :command_line_to_argv_w, :CommandLineToArgvW, %i{pointer pointer}, :pointer + + ffi_lib "Kernel32" + +=begin +LPSTR GetCommandLineA(); +=end + + safe_attach_function :get_command_line, :GetCommandLineA, [], :pointer + +=begin +HLOCAL LocalFree( + _Frees_ptr_opt_ HLOCAL hMem +); +=end + + safe_attach_function :local_free, :LocalFree, [:pointer], :pointer + + ############################################### + # Helpers + ############################################### + + # It takes the supplied string and splits it into an array. + def command_line_to_argv_w_helper(args) + arguments_list = [] + argv = args.to_wstring + result = get_command_line + argc = FFI::MemoryPointer.new(:int) + + # Parses a Unicode command line string + # It is return an array of pointers to the command line arguments. + # Along with a count of such arguments + result = command_line_to_argv_w(argv, argc) + str_ptr = result.read_pointer + offset = 0 + number_of_agrs = argc.read_int + number_of_agrs.times do + new_str_pointer = str_ptr.+(offset) + argument = new_str_pointer.read_wstring + arguments_list << argument + offset = offset + argument.length * 2 + 2 + end + local_free(result) + arguments_list + end + end + end + end +end diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock index cb83206f8f..68cce7cbc7 100644 --- a/omnibus/Gemfile.lock +++ b/omnibus/Gemfile.lock @@ -18,7 +18,7 @@ GIT GIT remote: https://github.com/chef/omnibus-software - revision: e51e5dcb73dce1777fad51f273837d0931956a96 + revision: 9b8f0d93b99395d91be29dea3f33f94cfa5a8633 branch: master specs: omnibus-software (4.0.0) @@ -32,7 +32,7 @@ GEM artifactory (3.0.12) awesome_print (1.8.0) aws-eventstream (1.1.0) - aws-partitions (1.299.0) + aws-partitions (1.301.0) aws-sdk-core (3.94.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) @@ -41,7 +41,7 @@ GEM aws-sdk-kms (1.30.0) aws-sdk-core (~> 3, >= 3.71.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.62.0) + aws-sdk-s3 (1.63.0) aws-sdk-core (~> 3, >= 3.83.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) @@ -64,12 +64,12 @@ GEM solve (~> 4.0) thor (>= 0.20) builder (3.2.4) - chef (15.9.17) + chef (15.10.12) addressable bcrypt_pbkdf (~> 1.0) bundler (>= 1.10) - chef-config (= 15.9.17) - chef-utils (= 15.9.17) + chef-config (= 15.10.12) + chef-utils (= 15.10.12) chef-zero (>= 14.0.11) diff-lcs (~> 1.2, >= 1.2.4) ed25519 (~> 1.2) @@ -92,16 +92,16 @@ GEM plist (~> 3.2) proxifier (~> 1.0) syslog-logger (~> 1.6) - train-core (~> 3.1) + train-core (~> 3.2, >= 3.2.28) train-winrm (>= 0.2.5) tty-screen (~> 0.6) uuidtools (~> 2.1.5) - chef (15.9.17-universal-mingw32) + chef (15.10.12-universal-mingw32) addressable bcrypt_pbkdf (~> 1.0) bundler (>= 1.10) - chef-config (= 15.9.17) - chef-utils (= 15.9.17) + chef-config (= 15.10.12) + chef-utils (= 15.10.12) chef-zero (>= 14.0.11) diff-lcs (~> 1.2, >= 1.2.4) ed25519 (~> 1.2) @@ -125,7 +125,7 @@ GEM plist (~> 3.2) proxifier (~> 1.0) syslog-logger (~> 1.6) - train-core (~> 3.1) + train-core (~> 3.2, >= 3.2.28) train-winrm (>= 0.2.5) tty-screen (~> 0.6) uuidtools (~> 2.1.5) @@ -141,15 +141,15 @@ GEM win32-taskscheduler (~> 2.0) wmi-lite (~> 1.0) chef-cleanroom (1.0.2) - chef-config (15.9.17) + chef-config (15.10.12) addressable - chef-utils (= 15.9.17) + chef-utils (= 15.10.12) fuzzyurl mixlib-config (>= 2.2.12, < 4.0) mixlib-shellout (>= 2.0, < 4.0) tomlrb (~> 1.2) chef-sugar (5.1.9) - chef-utils (15.9.17) + chef-utils (15.10.12) chef-zero (15.0.0) ffi-yajl (~> 2.2) hashie (>= 2.0, < 5.0) @@ -242,7 +242,7 @@ GEM octokit (4.18.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) - ohai (15.8.0) + ohai (15.9.1) chef-config (>= 12.8, < 16) ffi (~> 1.9) ffi-yajl (~> 2.2) diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb index 7567718363..e8b175f487 100644 --- a/spec/functional/resource/chocolatey_package_spec.rb +++ b/spec/functional/resource/chocolatey_package_spec.rb @@ -32,6 +32,11 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do new_resource end + let(:provider) do + provider = subject.provider_for_action(subject.action) + provider + end + context "installing a package" do after { remove_package } @@ -88,6 +93,30 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do expect(package_list.call).to eq("#{package_name}|2.0") end + context "when multiple options passed as string" do + before do + subject.options "--force --confirm" + subject.source nil + end + + it "splits a string into an array of options" do + expect(provider.send(:cmd_args)).to eq(["--force", "--confirm"]) + end + + it "calls command_line_to_argv_w_helper method" do + expect(provider).to receive(:command_line_to_argv_w_helper).with(subject.options).and_return(["--force", "--confirm"]) + provider.send(:cmd_args) + end + end + + context "when multiple options passed as array" do + it "Does not call command_line_to_argv_w_helper method" do + subject.options [ "--force", "--confirm" ] + expect(provider).not_to receive(:command_line_to_argv_w_helper) + provider.send(:cmd_args) + end + end + it "installs with multiple options as an array" do subject.options [ "--force", "--confirm" ] subject.run_action(:install) diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index f3d07a903a..4c1ccc7834 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -18,7 +18,7 @@ require "spec_helper" -describe Chef::Provider::Package::Chocolatey do +describe Chef::Provider::Package::Chocolatey, :windows_only do let(:timeout) { 900 } let(:new_resource) { Chef::Resource::ChocolateyPackage.new("git") } |