| When using Puppet::Util.replace_file, contents are written to the underlying Uniquefile in text mode instead of binary. On POSIX, this is a noop. On Windows, it will cause the sequence "\r\n" to be written as "\n". replace_file is also used by Puppet::Util::Execution (the child process' stdout is written to a Uniquefile. If the child process emits binary data, then it could be become corrupt if the output happens to contain the \r\n sequence. The Uniquefile implementation is missing the following:
diff --git a/lib/puppet/file_system/uniquefile.rb b/lib/puppet/file_system/uniquefile.rb |
index fdba62e7a4..058f6deea9 100644 |
--- a/lib/puppet/file_system/uniquefile.rb |
+++ b/lib/puppet/file_system/uniquefile.rb |
@@ -26,7 +26,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File) |
|
def initialize(basename, *rest) |
create_tmpname(basename, *rest) do |tmpname, n, opts| |
- mode = File::RDWR|File::CREAT|File::EXCL |
+ mode = File::RDWR|File::CREAT|File::EXCL|File::BINARY |
perm = 0600 |
if opts |
mode |= opts.delete(:mode) || 0
|
|