| While working on a patch to address SERVER-2167 I was trying to pass binary data on stdin to a command (gpg) run by Puppet::Util::Execution.execute using the stdinfile option. GPG was returning errors indicating the input data was corrupted so I did some digging. I believe that the 'r' in this line https://github.com/puppetlabs/puppet/blob/d4348e02c5eba0222d400ab0883f53cc8e2a086f/lib/puppet/util/execution.rb#L199 should be 'rb' to indicate to Ruby that the encoding should be treated as ASCII-8BIT instead of the default (in my environment UTF-8). It should be safe to pass binary data in via execute's stdinfile option and if the current behavior cannot be changed then there should be an option which indicates that stdinfile should be treated as binary data. In this instance, I was able to work around the issue by passing the file directly to gpg as a command line argument instead of using stdinfile (and it worked), but it may not be possible to do that in every use case. My testing was within Puppetserver in PE 2018.1.3. |