Issue #11929 has been updated by Daniel Pittman.

Josh Cooper wrote:

> About whether we should always open files in binary mode, in general, yes, 
> except when managing files on Windows that are accessed by other programs 
> that require '\r\n' line endings. The problem, is we don't know what the set 
> of all programs that may require '\r\n' line endings is.

Darn.  I hoped that we could define our behaviour as content-preserving rather 
than content-mutating in all cases, and put that burden on the user.  If they 
need to put a file in place with those line endings, they own the 
responsibility of making it that way on the master.

That way we have a simple, coherent rule that allows us to get things right 
universally, without the headaches that mutating content for user convenience 
inevitably leads to. :/

> We could monkey patch IO.binread for pre-1.9 ruby's, so at least we don't 
> need a puppet-specific method:

That seems like a good deal, at least; having a single method that does the 
right thing seems like the best deal to me.

----------------------------------------
Bug #11929: Cannot serve local binary files on Windows
https://projects.puppetlabs.com/issues/11929

Author: Josh Cooper
Status: In Topic Branch Pending Review
Priority: Normal
Assignee: Josh Cooper
Category: windows
Target version: 2.7.x
Affected Puppet version: 2.7.6
Keywords: 
Branch: https://github.com/puppetlabs/puppet/pull/331


`Puppet::FileServing::Content.content` is not specifying binary mode when 
reading its file. This is okay when the code runs on a Unix master. But if the 
Windows agent is its own fileserver, such as retrieving files from a local 
module, then the file is opened in text mode, which corrupts binaries.

To reproduce:

Given a module:
<pre>
C:\modules
└splunk
    ├files
    │   splunk-4.2.4-110225-x64-release.msi
    └manifests
        init.pp
</pre>

Where init.pp is:

<pre>
class splunk {
  file { 'c:\packages\splunk-4.2.4-110225-x64-release.msi':
    ensure => present,
    source => 'puppet:///modules/splunk/splunk-4.2.4-110225-x64-release.msi',
  }

  package { 'splunk':
    ensure => installed,
    provider => 'msi',
    source => 'c:\packages\splunk-4.2.4-110225-x64-release.msi',
    install_options => { 'INSTALLDIR' => 'C:\splunk' },
    require => File['c:\packages\splunk-4.2.4-110225-x64-release.msi'],
  }
}
</pre>

And site.pp:

<pre>
class { 'splunk': }
</pre>

Trying to apply the local module: 

<pre>
puppet apply c:\modules\site.pp --modulepath c:/modules
</pre>

Puppet corrupts the file while copying it from the local file server:

<pre>
err: /Stage[main]/Splunk/Package[splunk]/ensure: change from absent to present 
failed: Execution of 'msiexec.exe /qn /no
restart /i c:\packages\splunk-4.2.4-110225-x64-release.msi 
INSTALLDIR=C:\splunk' returned 1620: T h i s   i n s t a l l
a t i o n   p a c k a g e   c o u l d   n o t   b e   o p e n e d .     C o n t 
a c t   t h e   a p p l i c a t i o n
v e n d o r   t o   v e r i f y   t h a t   t h i s   i s   a   v a l i d   W i 
n d o w s   I n s t a l l e r   p a c k
a g e .
</pre>


-- 
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