Digging through the code, it looks like salt-cp does this to read
the file (at least in 2014.7.5):
with salt.utils.fopen(fn_, 'r') as fp_:
data = fp_.read()
salt.utils.fopen() is simply a wrapper for python's open() and passes all the
args directly to it without modification, so it's doing an open(fn_, 'r').
Since this doesn't include the 'b' flag, it's potentially not opening the file
in binary mode.
The open() docs on
docs.python.com say this:
The default is to use text mode, which may convert '\n' characters to a
platform-specific representation on writing and back on reading. Thus,
when opening a binary file, you should append 'b' to the mode value to
open the file in binary mode, which will improve portability.
So, I'm guessing it's corrupting the file because it's not enforcing binary
mode while reading the file.
You could test this by manually editing the salt/cli/cp.py file and making the
following change in the _file_dict() function:
- with salt.utils.fopen(fn_, 'r') as fp_:
+ with salt.utils.fopen(fn_, 'rb') as fp_:
Though, you probably also have to modify the code when writing the file too.
That would be in salt/modules/cp.py in the recv() function:
- salt.utils.fopen(final, 'w+').write(data)
+ salt.utils.fopen(final, 'w+b').write(data)
Todd
> --
> You received this message because you are subscribed to the Google Groups "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
salt-users+...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.