You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if a file has a content attribute set to something that looks
like a checksum, it will display a deprecation warning and then probably
throw an error, as the checksum-link string won't match anything in
filebuckets.
This code is apparently intended to allow a checksum to be passed instead
of actual content, with the effect of replacing file content if it
doesn't match the checksum. It appears that this mecanism is replaced by
"static catalogs" and was scheduled for removal in Puppet 7.
As it is no longer documented (because deprecated), it is surprising to
stumble upon the behavior by just having file content that looks like a
checksum. I had to work around this in a real usecase involving some
proprietary software that uses the same syntax for value to be encrypted
at startup.
This commit introduces a new setting "use_checksum_in_file_content" that
default to true, preserving current behavior. If set to false, it will
never look for checksums in file contents.
This setting should probably be set to false by default in the next
major release.
Copy file name to clipboardExpand all lines: lib/puppet/type/file/content.rb
+38-16Lines changed: 38 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -48,23 +48,43 @@ module Puppet
48
48
ifvalue == :absent
49
49
value
50
50
elsifvalue.is_a?(String) && checksum?(value)
51
-
# XXX This is potentially dangerous because it means users can't write a file whose
52
-
# entire contents are a plain checksum unless it is a Binary content.
53
-
Puppet.puppet_deprecation_warning([
54
-
# TRANSLATORS "content" is an attribute and should not be translated
55
-
_('Using a checksum in a file\'s "content" property is deprecated.'),
56
-
# TRANSLATORS "filebucket" is a resource type and should not be translated. The quoted occurrence of "content" is an attribute and should not be translated.
57
-
_('The ability to use a checksum to retrieve content from the filebucket using the "content" property will be removed in a future release.'),
58
-
# TRANSLATORS "content" is an attribute and should not be translated.
59
-
_('The literal value of the "content" property will be written to the file.'),
60
-
# TRANSLATORS "static catalogs" should not be translated.
61
-
_('The checksum retrieval functionality is being replaced by the use of static catalogs.'),
62
-
_('See https://puppet.com/docs/puppet/latest/static_catalogs.html for more information.')
# Our argument looks like a checksum. Is it the value of the content
52
+
# attribute in Puppet code, that happens to look like a checksum, or is
53
+
# it an actual checksum computed on the actual content?
54
+
if@actual_content || resource.parameter(:source)
55
+
# Actual content is already set, value contains it's checksum
56
+
value
57
+
else
58
+
# The value passed in the "content" attribute of this file looks like a checksum.
59
+
ifPuppet[:use_checksum_in_file_content]
60
+
# Assume user wants the deprecated behavior; display a warning though.
61
+
# XXX This is potentially dangerous because it means users can't write a file whose
62
+
# entire contents are a plain checksum unless it is a Binary content.
63
+
Puppet.puppet_deprecation_warning([
64
+
# TRANSLATORS "content" is an attribute and should not be translated
65
+
_('Using a checksum in a file\'s "content" property is deprecated.'),
66
+
# TRANSLATORS "filebucket" is a resource type and should not be translated. The quoted occurrence of "content" is an attribute and should not be translated.
67
+
_('The ability to use a checksum to retrieve content from the filebucket using the "content" property will be removed in a future release.'),
68
+
# TRANSLATORS "content" is an attribute and should not be translated.
69
+
_('The literal value of the "content" property will be written to the file.'),
70
+
# TRANSLATORS "static catalogs" should not be translated.
71
+
_('The checksum retrieval functionality is being replaced by the use of static catalogs.'),
72
+
_('See https://puppet.com/docs/puppet/latest/static_catalogs.html for more information.')
0 commit comments