chef 16.1.0 → 16.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +15 -1
- data/lib/chef/chef_fs/file_system/chef_server/acls_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/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +3 -3
- data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +2 -2
- data/lib/chef/data_collector.rb +1 -1
- data/lib/chef/data_collector/error_handlers.rb +1 -1
- data/lib/chef/decorator/lazy_array.rb +2 -2
- data/lib/chef/digester.rb +4 -4
- data/lib/chef/dsl/declare_resource.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +1 -1
- data/lib/chef/formatters/base.rb +1 -1
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/decompressor.rb +1 -1
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +5 -5
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -1
- data/lib/chef/knife/bootstrap/client_builder.rb +1 -1
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +1 -1
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
- data/lib/chef/knife/key_create_base.rb +1 -1
- data/lib/chef/knife/key_edit_base.rb +1 -1
- data/lib/chef/knife/ssh.rb +1 -1
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/mixin/checksum.rb +0 -1
- data/lib/chef/mixin/openssl_helper.rb +4 -4
- data/lib/chef/mixin/properties.rb +2 -2
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node/immutable_collections.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/property.rb +2 -2
- data/lib/chef/provider.rb +3 -3
- data/lib/chef/provider/directory.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/portage.rb +1 -0
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/windows.rb +2 -2
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +2 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +2 -2
- data/lib/chef/provider/user/mac.rb +10 -6
- data/lib/chef/provider/windows_task.rb +4 -2
- data/lib/chef/resource.rb +3 -3
- data/lib/chef/resource/chef_handler.rb +2 -2
- data/lib/chef/resource/chef_vault_secret.rb +1 -1
- data/lib/chef/resource/cron.rb +1 -1
- data/lib/chef/resource/cron_d.rb +1 -1
- data/lib/chef/resource/execute.rb +1 -1
- data/lib/chef/resource/file.rb +10 -8
- data/lib/chef/resource/hostname.rb +1 -1
- data/lib/chef/resource/locale.rb +3 -3
- data/lib/chef/resource/macos_userdefaults.rb +11 -6
- data/lib/chef/resource/scm/git.rb +1 -1
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_dfs_server.rb +1 -1
- data/lib/chef/resource/windows_pagefile.rb +1 -1
- data/lib/chef/resource/windows_task.rb +6 -6
- data/lib/chef/resource/windows_user_privilege.rb +3 -3
- data/lib/chef/resource_inspector.rb +4 -3
- data/lib/chef/run_context/cookbook_compiler.rb +1 -1
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +2 -2
- data/lib/chef/win32/api/error.rb +3 -1
- data/lib/chef/win32/api/file.rb +1 -1
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/win32/mutex.rb +1 -1
- data/lib/chef/win32/net.rb +1 -0
- data/lib/chef/win32/security/sid.rb +4 -4
- data/spec/functional/resource/dnf_package_spec.rb +2 -2
- data/spec/functional/resource/git_spec.rb +6 -6
- data/spec/functional/resource/windows_task_spec.rb +4 -4
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +1 -1
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +4 -4
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +7 -1
- data/spec/unit/mixin/openssl_helper_spec.rb +4 -4
- data/spec/unit/node/attribute_spec.rb +1 -1
- data/spec/unit/provider/group/groupadd_spec.rb +1 -1
- data/spec/unit/provider/package/portage_spec.rb +2 -2
- data/spec/unit/provider/package/powershell_spec.rb +1 -1
- data/spec/unit/win32/registry_spec.rb +1 -1
- metadata +6 -6
data/lib/chef/resource.rb
CHANGED
@@ -930,7 +930,7 @@ class Chef
|
|
930
930
|
end
|
931
931
|
|
932
932
|
#
|
933
|
-
# A hook called after a resource is created. Meant to be
|
933
|
+
# A hook called after a resource is created. Meant to be overridden by
|
934
934
|
# subclasses.
|
935
935
|
#
|
936
936
|
def after_created
|
@@ -1114,7 +1114,7 @@ class Chef
|
|
1114
1114
|
# `action_class` method, the presence of either indicates that this is
|
1115
1115
|
# going to be a Chef-12.5 custom resource. If we never see one of these
|
1116
1116
|
# directives then we are constructing an old-style Resource+Provider or
|
1117
|
-
# LWRP or
|
1117
|
+
# LWRP or whatever.
|
1118
1118
|
#
|
1119
1119
|
# If a block is passed, the action_class is always created and the block is
|
1120
1120
|
# run inside it.
|
@@ -1327,7 +1327,7 @@ class Chef
|
|
1327
1327
|
# Once we no longer care about supporting chef < 14.4 then we can deprecate
|
1328
1328
|
# this API.
|
1329
1329
|
#
|
1330
|
-
# @param arg [String] version
|
1330
|
+
# @param arg [String] version constraint to match against (e.g. "> 14")
|
1331
1331
|
#
|
1332
1332
|
def self.chef_version_for_provides(constraint)
|
1333
1333
|
@chef_version_for_provides = constraint
|
@@ -107,7 +107,7 @@ class Chef
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
# Walks down the namespace
|
110
|
+
# Walks down the namespace hierarchy to return the class object for the given class name.
|
111
111
|
# If the class is not available, NameError is thrown.
|
112
112
|
#
|
113
113
|
# @param class_full_name [String] full class name such as 'Chef::Handler::Foo' or 'MyHandler'.
|
@@ -118,7 +118,7 @@ class Chef
|
|
118
118
|
class_name = ancestors.pop
|
119
119
|
|
120
120
|
# We need to search the ancestors only for the first/uppermost namespace of the class, so we
|
121
|
-
# need to enable the #const_get inherit
|
121
|
+
# need to enable the #const_get inherit parameter only when we are searching in Kernel scope
|
122
122
|
# (see COOK-4117).
|
123
123
|
parent = ancestors.inject(Kernel) { |scope, const_name| scope.const_get(const_name, scope === Kernel) }
|
124
124
|
child = parent.const_get(class_name, parent === Kernel)
|
data/lib/chef/resource/cron.rb
CHANGED
@@ -136,7 +136,7 @@ class Chef
|
|
136
136
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
137
137
|
end
|
138
138
|
unless h.values.all? { |x| x =~ TIMEOUT_REGEX }
|
139
|
-
error_msg = "Values of option time_out should be non-empty string without any leading
|
139
|
+
error_msg = "Values of option time_out should be non-empty string without any leading whitespace."
|
140
140
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
141
141
|
end
|
142
142
|
h
|
data/lib/chef/resource/cron_d.rb
CHANGED
@@ -175,7 +175,7 @@ class Chef
|
|
175
175
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
176
176
|
end
|
177
177
|
unless h.values.all? { |x| x =~ TIMEOUT_REGEX }
|
178
|
-
error_msg = "Values of option time_out should be non-empty string without any leading
|
178
|
+
error_msg = "Values of option time_out should be non-empty string without any leading whitespace."
|
179
179
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
180
180
|
end
|
181
181
|
h
|
@@ -84,7 +84,7 @@ class Chef
|
|
84
84
|
desired_state: false
|
85
85
|
|
86
86
|
property :user, [ String, Integer ],
|
87
|
-
description: "The user name of the user identity with which to launch the new process. The user name may optionally be
|
87
|
+
description: "The user name of the user identity with which to launch the new process. The user name may optionally be specified with a domain, i.e. domainuser or user@my.dns.domain.com via Universal Principal Name (UPN)format. It can also be specified without a domain simply as user if the domain is instead specified using the domain property. On Windows only, if this property is specified, the password property must be specified."
|
88
88
|
|
89
89
|
property :domain, String,
|
90
90
|
introduced: "12.21",
|
data/lib/chef/resource/file.rb
CHANGED
@@ -56,28 +56,30 @@ class Chef
|
|
56
56
|
allowed_actions :create, :delete, :touch, :create_if_missing
|
57
57
|
|
58
58
|
property :path, String, name_property: true,
|
59
|
-
|
59
|
+
description: "The full path to the file, including the file name and its extension. For example: /files/file.txt. Default value: the name of the resource block. Microsoft Windows: A path that begins with a forward slash (/) will point to the root of the current working directory of the #{Chef::Dist::CLIENT} process. This path can vary from system to system. Therefore, using a path that begins with a forward slash (/) is not recommended."
|
60
60
|
|
61
61
|
property :atomic_update, [ TrueClass, FalseClass ], desired_state: false, default: lazy { docker? && special_docker_files?(path) ? false : Chef::Config[:file_atomic_update] },
|
62
|
-
|
63
|
-
|
62
|
+
default_description: "False if modifying /etc/hosts, /etc/hostname, or /etc/resolv.conf within Docker containers. Otherwise default to the client.rb 'file_atomic_update' config value.",
|
63
|
+
description: "Perform atomic file updates on a per-resource basis. Set to true for atomic file updates. Set to false for non-atomic file updates. This setting overrides `file_atomic_update`, which is a global setting found in the `client.rb` file."
|
64
64
|
|
65
65
|
property :backup, [ Integer, FalseClass ], desired_state: false, default: 5,
|
66
|
-
|
66
|
+
description: "The number of backups to be kept in `/var/chef/backup` (for UNIX- and Linux-based platforms) or `C:/chef/backup` (for the Microsoft Windows platform). Set to `false` to prevent backups from being kept."
|
67
67
|
|
68
|
-
property :checksum, [
|
68
|
+
property :checksum, [ String, nil ],
|
69
|
+
regex: /^\h{64}$/,
|
70
|
+
coerce: lambda { |s| s.is_a?(String) ? s.downcase : s },
|
69
71
|
description: "The SHA-256 checksum of the file. Use to ensure that a specific file is used. If the checksum does not match, the file is not used."
|
70
72
|
|
71
73
|
property :content, [ String, nil ], desired_state: false,
|
72
|
-
|
74
|
+
description: "A string that is written to the file. The contents of this property replace any previous content when this property has something other than the default value. The default behavior will not modify content."
|
73
75
|
|
74
76
|
property :diff, [ String, nil ], desired_state: false, skip_docs: true
|
75
77
|
|
76
78
|
property :force_unlink, [ TrueClass, FalseClass ], desired_state: false, default: false,
|
77
|
-
|
79
|
+
description: "How #{Chef::Dist::PRODUCT} handles certain situations when the target file turns out not to be a file. For example, when a target file is actually a symlink. Set to true for #{Chef::Dist::PRODUCT} to delete the non-file target and replace it with the specified file. Set to false for #{Chef::Dist::PRODUCT} to raise an error."
|
78
80
|
|
79
81
|
property :manage_symlink_source, [ TrueClass, FalseClass ], desired_state: false,
|
80
|
-
|
82
|
+
description: "Change the behavior of the file resource if it is pointed at a symlink. When this value is set to true, #{Chef::Dist::PRODUCT} will manage the symlink's permissions or will replace the symlink with a normal file if the resource has content. When this value is set to false, #{Chef::Dist::PRODUCT} will follow the symlink and will manage the permissions and content of symlink's target file. The default behavior is true but emits a warning that the default value will be changed to false in a future version; setting this explicitly to true or false suppresses this warning."
|
81
83
|
|
82
84
|
property :verifications, Array, default: lazy { [] }
|
83
85
|
|
@@ -149,7 +149,7 @@ class Chef
|
|
149
149
|
# this must come before other methods like /etc/hostname and /etc/sysconfig/network
|
150
150
|
declare_resource(:execute, "hostnamectl set-hostname #{new_resource.hostname}") do
|
151
151
|
notifies :reload, "ohai[reload hostname]"
|
152
|
-
not_if { shell_out!("hostnamectl status",
|
152
|
+
not_if { shell_out!("hostnamectl status", returns: [0, 1]).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ }
|
153
153
|
end
|
154
154
|
when ::File.exist?("/etc/hostname")
|
155
155
|
# debian family uses /etc/hostname
|
data/lib/chef/resource/locale.rb
CHANGED
@@ -45,7 +45,7 @@ class Chef
|
|
45
45
|
property :lang, String,
|
46
46
|
description: "Sets the default system language.",
|
47
47
|
regex: [LOCALE_REGEX],
|
48
|
-
validation_message: "The provided lang is not valid. It should be a non-empty string without any leading
|
48
|
+
validation_message: "The provided lang is not valid. It should be a non-empty string without any leading whitespace."
|
49
49
|
|
50
50
|
property :lc_env, Hash,
|
51
51
|
description: "A Hash of LC_* env variables in the form of `({ 'LC_ENV_VARIABLE' => 'VALUE' })`.",
|
@@ -59,7 +59,7 @@ class Chef
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
unless h.values.all? { |x| x =~ LOCALE_REGEX }
|
62
|
-
error_msg = "Values of option lc_env should be non-empty string without any leading
|
62
|
+
error_msg = "Values of option lc_env should be non-empty string without any leading whitespace."
|
63
63
|
raise Chef::Exceptions::ValidationFailed, error_msg
|
64
64
|
end
|
65
65
|
h
|
@@ -120,7 +120,7 @@ class Chef
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
# Generates the
|
123
|
+
# Generates the localization files from templates using locale-gen.
|
124
124
|
# @see http://manpages.ubuntu.com/manpages/cosmic/man8/locale-gen.8.html
|
125
125
|
# @raise [Mixlib::ShellOut::ShellCommandFailed] not a supported language or locale
|
126
126
|
#
|
@@ -74,12 +74,17 @@ class Chef
|
|
74
74
|
|
75
75
|
load_current_value do |desired|
|
76
76
|
value = coerce_booleans(desired.value)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
vc =
|
82
|
-
|
77
|
+
cmd = "defaults read '#{desired.domain}' "
|
78
|
+
cmd << "'#{desired.key}' " if desired.key
|
79
|
+
cmd << " | grep -qx '#{value}'"
|
80
|
+
|
81
|
+
vc = if desired.user.nil?
|
82
|
+
shell_out(cmd)
|
83
|
+
else
|
84
|
+
shell_out(cmd, user: desired.user)
|
85
|
+
end
|
86
|
+
|
87
|
+
is_set !vc.error?
|
83
88
|
end
|
84
89
|
|
85
90
|
action :write do
|
@@ -53,7 +53,7 @@ class Chef
|
|
53
53
|
description: "The path to the wrapper script used when running SSH with git. The `GIT_SSH` environment variable is set to this."
|
54
54
|
|
55
55
|
property :checkout_branch, String,
|
56
|
-
description: "Set this to use a local branch to avoid checking SHAs or tags to a
|
56
|
+
description: "Set this to use a local branch to avoid checking SHAs or tags to a detached head state."
|
57
57
|
|
58
58
|
alias :branch :revision
|
59
59
|
alias :reference :revision
|
@@ -308,7 +308,7 @@ class Chef
|
|
308
308
|
#
|
309
309
|
def import_certificates(cert_objs, is_pfx)
|
310
310
|
[cert_objs].flatten.each do |cert_obj|
|
311
|
-
thumbprint = OpenSSL::Digest
|
311
|
+
thumbprint = OpenSSL::Digest.new("SHA1", cert_obj.to_der).to_s # Fetch its thumbprint
|
312
312
|
# Need to check if return value is Boolean:true
|
313
313
|
# If not then the given certificate should be added in certstore
|
314
314
|
if verify_cert(thumbprint) == true
|
@@ -50,7 +50,7 @@ class Chef
|
|
50
50
|
ps_results = powershell_out("Get-DfsnServerConfiguration -ComputerName '#{ENV["COMPUTERNAME"]}' | Select LdapTimeoutSec, PreferLogonDC, EnableSiteCostedReferrals, SyncIntervalSec, UseFqdn | ConvertTo-Json")
|
51
51
|
|
52
52
|
if ps_results.error?
|
53
|
-
raise "The dfs_server resource failed to fetch the current state via the Get-DfsnServerConfiguration PowerShell
|
53
|
+
raise "The dfs_server resource failed to fetch the current state via the Get-DfsnServerConfiguration PowerShell cmdlet. Is the DFS Windows feature installed?"
|
54
54
|
end
|
55
55
|
|
56
56
|
Chef::Log.debug("The Get-DfsnServerConfiguration results were #{ps_results.stdout}")
|
@@ -124,7 +124,7 @@ class Chef
|
|
124
124
|
# @return [Boolean]
|
125
125
|
def exists?(pagefile)
|
126
126
|
@exists ||= begin
|
127
|
-
logger.trace("Checking if #{pagefile} exists by
|
127
|
+
logger.trace("Checking if #{pagefile} exists by running: wmic.exe pagefileset where SettingID=\"#{get_setting_id(pagefile)}\" list /format:list")
|
128
128
|
cmd = shell_out("wmic.exe pagefileset where SettingID=\"#{get_setting_id(pagefile)}\" list /format:list", returns: [0])
|
129
129
|
cmd.stderr.empty? && (cmd.stdout =~ /SettingID=#{get_setting_id(pagefile)}/i)
|
130
130
|
end
|
@@ -274,7 +274,7 @@ class Chef
|
|
274
274
|
|
275
275
|
## Resource is not idempotent when day, start_day is not provided with frequency :weekly
|
276
276
|
## we set start_day when not given by user as current date based on which we set the day property for current current date day is monday ..
|
277
|
-
## we set the monday as the day so at next run when new_resource.day is nil and current_resource day is monday due to which
|
277
|
+
## we set the monday as the day so at next run when new_resource.day is nil and current_resource day is monday due to which update gets called
|
278
278
|
def idempotency_warning_for_frequency_weekly(day, start_day)
|
279
279
|
if start_day.nil? && day.nil?
|
280
280
|
logger.warn "To maintain idempotency for frequency :weekly provide start_day, start_time and day."
|
@@ -295,19 +295,19 @@ class Chef
|
|
295
295
|
end
|
296
296
|
|
297
297
|
def validate_frequency_monthly(frequency_modifier, months, day)
|
298
|
-
# validates the frequency :monthly and raises error if frequency_modifier is first, second,
|
298
|
+
# validates the frequency :monthly and raises error if frequency_modifier is first, second, third etc and day is not provided
|
299
299
|
if (frequency_modifier != 1) && (frequency_modifier_includes_days_of_weeks?(frequency_modifier)) && !(day)
|
300
|
-
raise ArgumentError, "Please select day on which you want to run the task e.g. 'Mon, Tue'. Multiple values must be
|
300
|
+
raise ArgumentError, "Please select day on which you want to run the task e.g. 'Mon, Tue'. Multiple values must be separated by comma."
|
301
301
|
end
|
302
302
|
|
303
|
-
#
|
304
|
-
# Not checking value 1 here for
|
303
|
+
# frequency_modifier 2-12 is used to set every (n) months, so using :months property with frequency_modifier is not valid since they both used to set months.
|
304
|
+
# Not checking value 1 here for frequency_modifier since we are setting that as default value it won't break anything since preference is given to months property
|
305
305
|
if (frequency_modifier.to_i.between?(2, 12)) && !(months.nil?)
|
306
306
|
raise ArgumentError, "For frequency :monthly either use property months or frequency_modifier to set months."
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
|
-
# returns true if
|
310
|
+
# returns true if frequency_modifier has values First, second, third, fourth, last, lastday
|
311
311
|
def frequency_modifier_includes_days_of_weeks?(frequency_modifier)
|
312
312
|
frequency_modifier = frequency_modifier.to_s.split(",")
|
313
313
|
frequency_modifier.map! { |value| value.strip.upcase }
|
@@ -76,7 +76,7 @@ class Chef
|
|
76
76
|
**Set the SeNetworkLogonRight Privilege for the Builtin Administrators Group and Authenticated Users**:
|
77
77
|
|
78
78
|
```ruby
|
79
|
-
windows_user_privilege '
|
79
|
+
windows_user_privilege 'Network Logon Rights' do
|
80
80
|
privilege 'SeNetworkLogonRight'
|
81
81
|
users ['BUILTIN\Administrators', 'NT AUTHORITY\Authenticated Users']
|
82
82
|
action :set
|
@@ -126,8 +126,8 @@ class Chef
|
|
126
126
|
required: true,
|
127
127
|
coerce: proc { |v| v.is_a?(String) ? Array[v] : v },
|
128
128
|
callbacks: {
|
129
|
-
"Option privilege must include any of the: #{privilege_opts}" => lambda {
|
130
|
-
|
129
|
+
"Option privilege must include any of the: #{privilege_opts}" => lambda { |v|
|
130
|
+
(privilege_opts & v).size == v.size
|
131
131
|
},
|
132
132
|
}
|
133
133
|
|
@@ -69,8 +69,8 @@ module ResourceInspector
|
|
69
69
|
dir, name = File.split(path)
|
70
70
|
Chef::Cookbook::FileVendor.fetch_from_disk(path)
|
71
71
|
loader = Chef::CookbookLoader.new(dir)
|
72
|
-
|
73
|
-
resources =
|
72
|
+
cookbook = loader.load_cookbook(name)
|
73
|
+
resources = cookbook.files_for(:resources)
|
74
74
|
|
75
75
|
resources.each_with_object({}) do |r, res|
|
76
76
|
pth = r["full_path"]
|
@@ -83,13 +83,14 @@ module ResourceInspector
|
|
83
83
|
# otherwise, if we have a path then extract all the resources from the cookbook
|
84
84
|
# or else do a list of built in resources
|
85
85
|
#
|
86
|
+
# @param arguments [Array, String] One of more paths to a cookbook or a resource file to inspect
|
86
87
|
# @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class
|
87
88
|
# @return [String] JSON formatting of all resources
|
88
89
|
def self.inspect(arguments = [], complete: false)
|
89
90
|
output = if arguments.empty?
|
90
91
|
ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) }
|
91
92
|
else
|
92
|
-
arguments.each_with_object({}) do |arg, acc|
|
93
|
+
Array(arguments).each_with_object({}) do |arg, acc|
|
93
94
|
if File.directory?(arg)
|
94
95
|
extract_cookbook(arg, complete).each { |k, v| acc[k] = v }
|
95
96
|
else
|
@@ -101,7 +101,7 @@ class Chef
|
|
101
101
|
@events.library_load_start(count_files_by_segment(:libraries))
|
102
102
|
cookbook_order.each do |cookbook|
|
103
103
|
eager_load_libraries = cookbook_collection[cookbook].metadata.eager_load_libraries
|
104
|
-
if eager_load_libraries == true #
|
104
|
+
if eager_load_libraries == true # actually true, not truthy
|
105
105
|
load_libraries_from_cookbook(cookbook)
|
106
106
|
else
|
107
107
|
$LOAD_PATH.unshift File.expand_path("libraries", cookbook_collection[cookbook].root_dir)
|
data/lib/chef/shell/ext.rb
CHANGED
@@ -37,7 +37,7 @@ module Shell
|
|
37
37
|
module ObjectCoreExtensions
|
38
38
|
|
39
39
|
def ensure_session_select_defined
|
40
|
-
# irb breaks if you prematurely define IRB::
|
40
|
+
# irb breaks if you prematurely define IRB::JobManager
|
41
41
|
# so these methods need to be defined at the latest possible time.
|
42
42
|
unless jobs.respond_to?(:select_session_by_context)
|
43
43
|
def jobs.select_session_by_context(&block) # rubocop:disable Lint/NestedMethodDefinition
|
data/lib/chef/version.rb
CHANGED
data/lib/chef/win32/api.rb
CHANGED
@@ -94,7 +94,7 @@ class Chef
|
|
94
94
|
host.typedef :ulong, :HMENU # (L) Handle to a menu. http://msdn.microsoft.com/en-us/library/ms646977%28VS.85%29.aspx
|
95
95
|
host.typedef :ulong, :HMETAFILE # (L) Handle to a metafile. http://msdn.microsoft.com/en-us/library/dd145051%28VS.85%29.aspx
|
96
96
|
host.typedef :ulong, :HMODULE # (L) Handle to an instance. Same as HINSTANCE today, but was different in 16-bit Windows.
|
97
|
-
host.typedef :ulong, :HMONITOR # (L)
|
97
|
+
host.typedef :ulong, :HMONITOR # (L) Handle to a display monitor. WinDef.h: if(WINVER >= 0x0500) host.typedef HANDLE HMONITOR;
|
98
98
|
host.typedef :ulong, :HPALETTE # (L) Handle to a palette.
|
99
99
|
host.typedef :ulong, :HPEN # (L) Handle to a pen. http://msdn.microsoft.com/en-us/library/dd162786%28VS.85%29.aspx
|
100
100
|
host.typedef :long, :HRESULT # Return code used by COM interfaces. For more info, Structure of the COM Error Codes.
|
@@ -115,7 +115,7 @@ class Chef
|
|
115
115
|
host.typedef :uint32, :LCID # Locale identifier. For more information, see Locales.
|
116
116
|
host.typedef :uint32, :LCTYPE # Locale information type. For a list, see Locale Information Constants.
|
117
117
|
host.typedef :uint32, :LGRPID # Language group identifier. For a list, see EnumLanguageGroupLocales.
|
118
|
-
host.typedef :pointer, :LMSTR # Pointer to null
|
118
|
+
host.typedef :pointer, :LMSTR # Pointer to null terminated string of unicode characters
|
119
119
|
host.typedef :long, :LONG # 32-bit signed integer. The range is -2,147,483,648 through +...647 decimal.
|
120
120
|
host.typedef :int32, :LONG32 # 32-bit signed integer. The range is -2,147,483,648 through +...647 decimal.
|
121
121
|
host.typedef :int64, :LONG64 # 64-bit signed integer. The range is –9,223,372,036,854,775,808 through +...807
|
data/lib/chef/win32/api/error.rb
CHANGED
@@ -64,7 +64,7 @@ class Chef
|
|
64
64
|
ERROR_SHARING_VIOLATION = 32
|
65
65
|
ERROR_LOCK_VIOLATION = 33
|
66
66
|
ERROR_WRONG_DISK = 34
|
67
|
-
ERROR_FCB_UNAVAILABLE = 35
|
67
|
+
ERROR_FCB_UNAVAILABLE = 35 # gets returned for some unsuccessful DeviceIoControl calls
|
68
68
|
ERROR_SHARING_BUFFER_EXCEEDED = 36
|
69
69
|
ERROR_HANDLE_EOF = 38
|
70
70
|
ERROR_HANDLE_DISK_FULL = 39
|
@@ -90,6 +90,7 @@ class Chef
|
|
90
90
|
ERROR_TOO_MANY_NAMES = 68
|
91
91
|
ERROR_TOO_MANY_SESS = 69
|
92
92
|
ERROR_SHARING_PAUSED = 70
|
93
|
+
# cspell:disable-next-line
|
93
94
|
ERROR_REQ_NOT_ACCEP = 71
|
94
95
|
ERROR_REDIR_PAUSED = 72
|
95
96
|
|
@@ -876,6 +877,7 @@ class Chef
|
|
876
877
|
|
877
878
|
# Flags for LoadLibraryEx
|
878
879
|
|
880
|
+
# cspell:disable-next-line
|
879
881
|
DONT_RESOLVE_DLL_REFERENCES = 0x00000001
|
880
882
|
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010
|
881
883
|
LOAD_LIBRARY_AS_DATAFILE = 0x00000002
|
data/lib/chef/win32/api/file.rb
CHANGED
@@ -540,7 +540,7 @@ BOOL WINAPI VerQueryValue(
|
|
540
540
|
def file_search_handle(path)
|
541
541
|
# Workaround for CHEF-4419:
|
542
542
|
# Make sure paths starting with "/" has a drive letter
|
543
|
-
# assigned from the current working
|
543
|
+
# assigned from the current working directory.
|
544
544
|
# Note: With CHEF-4427 this issue will be fixed with a
|
545
545
|
# broader fix to map all the paths starting with "/" to
|
546
546
|
# SYSTEM_DRIVE on windows.
|
data/lib/chef/win32/api/net.rb
CHANGED
data/lib/chef/win32/mutex.rb
CHANGED
@@ -95,7 +95,7 @@ if other threads attempt to acquire the mutex.")
|
|
95
95
|
@handle = OpenMutexW(SYNCHRONIZE, true, name.to_wstring)
|
96
96
|
|
97
97
|
if @handle == 0
|
98
|
-
#
|
98
|
+
# Mutex doesn't exist so create one.
|
99
99
|
# In the initial creation of the mutex initial_owner is set to
|
100
100
|
# false so that mutex will not be acquired until someone calls
|
101
101
|
# acquire.
|
data/lib/chef/win32/net.rb
CHANGED
@@ -261,7 +261,7 @@ class Chef
|
|
261
261
|
|
262
262
|
SYSTEM_USER = SERVICE_ACCOUNT_USERS + BUILT_IN_GROUPS
|
263
263
|
|
264
|
-
#
|
264
|
+
# Check if the user belongs to service accounts category
|
265
265
|
#
|
266
266
|
# @return [Boolean] True or False
|
267
267
|
#
|
@@ -269,7 +269,7 @@ class Chef
|
|
269
269
|
SERVICE_ACCOUNT_USERS.include?(user.to_s.upcase)
|
270
270
|
end
|
271
271
|
|
272
|
-
#
|
272
|
+
# Check if the user is in builtin system group
|
273
273
|
#
|
274
274
|
# @return [Boolean] True or False
|
275
275
|
#
|
@@ -277,7 +277,7 @@ class Chef
|
|
277
277
|
BUILT_IN_GROUPS.include?(user.to_s.upcase)
|
278
278
|
end
|
279
279
|
|
280
|
-
#
|
280
|
+
# Check if the user belongs to system users category
|
281
281
|
#
|
282
282
|
# @return [Boolean] True or False
|
283
283
|
#
|
@@ -325,7 +325,7 @@ class Chef
|
|
325
325
|
Array.new(entriesread.read_long) do |i|
|
326
326
|
user_info = USER_INFO_3.new(bufptr.read_pointer + i * USER_INFO_3.size)
|
327
327
|
# Check if the account is the Administrator account
|
328
|
-
# RID for the Administrator account is always 500 and it's
|
328
|
+
# RID for the Administrator account is always 500 and it's privilege is set to USER_PRIV_ADMIN
|
329
329
|
if user_info[:usri3_user_id] == 500 && user_info[:usri3_priv] == 2 # USER_PRIV_ADMIN (2) - Administrator
|
330
330
|
admin_account_name = user_info[:usri3_name].read_wstring
|
331
331
|
break
|