Jira (PUP-9559) Puppet's Uniquefile doesn't open files in binary mode

2020-06-11 Thread Josh Cooper (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Josh Cooper commented on  PUP-9559  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Puppet's Uniquefile doesn't open files in binary mode   
 

  
 
 
 
 

 
 File::BINARY is defined to be 0, so adding the constant above does nothing. The real problem is that Uniquefile defaults to mode w+, so calling replace_file containing windows line endings will cause \n to be replaced with \r\n.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.300170.1552553148000.84761.1591856220022%40Atlassian.JIRA.


Jira (PUP-9559) Puppet's Uniquefile doesn't open files in binary mode

2020-06-10 Thread Josh Cooper (Jira)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Josh Cooper commented on  PUP-9559  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Puppet's Uniquefile doesn't open files in binary mode   
 

  
 
 
 
 

 
 Verified this is still an issue, note the double "\r"  
 
 
 
 
 irb(main):020:0> file = Puppet::FileSystem::Uniquefile.new("C:\\Users\\Josh\\uniq.txt")  
 
 
 => #  
 
 
 irb(main):021:0> file.write("hello\r\nworld")  
 
 
 => 12  
 
 
 irb(main):022:0> file.flush  
 
 
 => #  
 
 
 irb(main):023:0> File.binread(file.path)  
 
 
 => "hello\r\r\nworld"
  
 
 
 
   
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 

Jira (PUP-9559) Puppet's Uniquefile doesn't open files in binary mode

2019-03-18 Thread Jorie Tappa (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Jorie Tappa updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Puppet /  PUP-9559  
 
 
  Puppet's Uniquefile doesn't open files in binary mode   
 

  
 
 
 
 

 
Change By: 
 Jorie Tappa  
 
 
Team: 
 Coremunity  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at https://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-9559) Puppet's Uniquefile doesn't open files in binary mode

2019-03-14 Thread Josh Cooper (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Josh Cooper commented on  PUP-9559  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: Puppet's Uniquefile doesn't open files in binary mode   
 

  
 
 
 
 

 
 fyi Ethan Brown  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-bugs@googlegroups.com.
Visit this group at https://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/d/optout.


Jira (PUP-9559) Puppet's Uniquefile doesn't open files in binary mode

2019-03-14 Thread Josh Cooper (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Josh Cooper updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Puppet /  PUP-9559  
 
 
  Puppet's Uniquefile doesn't open files in binary mode   
 

  
 
 
 
 

 
Change By: 
 Josh Cooper  
 

  
 
 
 
 

 
 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 "\ r\ 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  that  happens to contain  the {{  " \ r\ n }} sequence ", then the output will be corrupted .The {{Uniquefile}} implementation is missing the following:{code:diff}diff --git a/lib/puppet/file_system/uniquefile.rb b/lib/puppet/file_system/uniquefile.rbindex 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{code}  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)  
 
 

 

Jira (PUP-9559) Puppet's Uniquefile doesn't open files in binary mode

2019-03-14 Thread Josh Cooper (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Josh Cooper created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Puppet /  PUP-9559  
 
 
  Puppet's Uniquefile doesn't open files in binary mode   
 

  
 
 
 
 

 
Issue Type: 
  Improvement  
 
 
Assignee: 
 Unassigned  
 
 
Created: 
 2019/03/14 1:45 AM  
 
 
Priority: 
  Normal  
 
 
Reporter: 
 Josh Cooper  
 

  
 
 
 
 

 
 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 <