Issue #9983 has been updated by Josh Cooper.

Assignee set to Josh Cooper

Did some research, and as expected this is a problem. Using a windows agent, 
Mac puppetmaster, I can backup a binary file from the agent:

<pre>
Z:\work\puppet>puppet filebucket backup --server puppetmaster mynotepad.exe
mynotepad.exe: 3835c0642b59431254a456c4c6204d5e
</pre>

The checksum above is actually incorrect, because puppet uses File.open(path, 
'r') when reading the file. The checksum should be 
7200b516a1a5e86ddafa49206abc8715. On the server I see:

<pre>
info: Could not find file_bucket_file for 
'md5/3835c0642b59431254a456c4c6204d5e/Z:\work/puppet/mynotepad.exe'
info: FileBucket adding {md5}3835c0642b59431254a456c4c6204d5e
</pre>

When I restore the file on the agent, I get a corrupted binary:

<pre>
Z:\work\puppet>puppet filebucket restore --server puppetmaster mynotepad2.exe 
3835c0642b59431254a456c4c6204d5e
Z:\work\puppet>dir *.exe
 Volume in drive Z is Shared Folders
 Volume Serial Number is 0000-0064

 Directory of Z:\work\puppet

03/25/2005  05:00 AM            88,064 mynotepad.exe
10/12/2011  04:57 PM            43,062 mynotepad2.exe
</pre>


</pre>
----------------------------------------
Bug #9983: Files should be opened in binary mode
https://projects.puppetlabs.com/issues/9983

Author: Josh Cooper
Status: Accepted
Priority: Normal
Assignee: Josh Cooper
Category: windows
Target version: 2.7.x
Affected Puppet version: 
Keywords: 
Branch: 


Windows has a concept of text and binary file modes, where text mode 
automatically converts \r\n. This is not an issue when files are opened, read, 
etc within the context of a single Windows machine. But it is an issue if say a 
binary file is restored from a Unix file bucket, as the Windows agent will 
substitute each occurrence of '\n' to '\r\n', and in doing so corrupt the file.

We should always open files in binary mode, which is a no-op on Unix.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to