summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-05-19 16:43:35 -0700
committerPete Higgins <pete@peterhiggins.org>2020-05-19 16:55:31 -0700
commit60f2c4a8dfed08656def3abef6f6a11fa2ef8f2f (patch)
treeffd4cbffd190416fb8689c025ecd77e8ac0a67ec
parente2a948c23a2622fccffd3a956d04b19bd147e19c (diff)
downloadchef-60f2c4a8dfed08656def3abef6f6a11fa2ef8f2f.tar.gz
Downcase checksums when they come into the system.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--lib/chef/provider/file.rb2
-rw-r--r--lib/chef/provider/package/windows.rb2
-rw-r--r--lib/chef/resource/file.rb1
3 files changed, 3 insertions, 2 deletions
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index b705283623..0de620bba1 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -334,7 +334,7 @@ class Chef
end
def do_validate_content
- if new_resource.checksum && tempfile && ( new_resource.checksum.downcase != tempfile_checksum )
+ if new_resource.checksum && tempfile && ( new_resource.checksum != tempfile_checksum )
raise Chef::Exceptions::ChecksumMismatch.new(short_cksum(new_resource.checksum), short_cksum(tempfile_checksum))
end
diff --git a/lib/chef/provider/package/windows.rb b/lib/chef/provider/package/windows.rb
index 8ee5b36f5d..79e01804fd 100644
--- a/lib/chef/provider/package/windows.rb
+++ b/lib/chef/provider/package/windows.rb
@@ -38,7 +38,7 @@ class Chef
def define_resource_requirements
if new_resource.checksum
requirements.assert(:install) do |a|
- a.assertion { new_resource.checksum.downcase == checksum(source_location) }
+ a.assertion { new_resource.checksum == checksum(source_location) }
a.failure_message Chef::Exceptions::Package, "Checksum on resource (#{short_cksum(new_resource.checksum)}) does not match checksum on content (#{short_cksum(source_location)})"
end
end
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
index 68affe5dbb..e4838d85f9 100644
--- a/lib/chef/resource/file.rb
+++ b/lib/chef/resource/file.rb
@@ -67,6 +67,7 @@ class Chef
property :checksum, [ String, nil ],
regex: /^\h{64}$/,
+ coerce: lambda { |s| s.is_a?(String) ? s.downcase : s },
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."
property :content, [ String, nil ], desired_state: false,