salt.master.AESFuncs._file_recv(), which receives the files transmitted
using the cp.push execution function, is executed once for each chunk
received. However, it was opening the filehandle using a 'w' or 'w+'
mode, which always truncates the file. So, when a file that exceeds the
size of the file_buffer_size minion config option (default: 262144
bytes), is pushed to the minion, and is thus sent in more than one
chunk, the file on the master is truncated. The filehandle then seeks to
the offset location of the chunk that was transmitted and writes the
chunk.
With the file being truncated every time a chunk is written, the result
is a file which contains null bytes everywhere but the final chunk,
causing the file to be corrupted.
This commit changes salt.master.AESFuncs._file_recv() so that it opens
the file for appending (instead of writing) if the destination file on
the master exists and the offset is nonzero. Otherwise, the file is
opened for writing.
* Removed `format_call` from `salt.state.State` since it was almost a one to one copy of `salt.utils.format_call`.
* The `format_call` in `salt.utils` was modified to accept initial return data(to provide the functionality from the removed `State.format_call`.
* While the function arguments are being queried/matched, those used are removed from a copy of the passed data. Once finished, any remaining keyword arguments which do not match those allowed on the `expected_extra_kws` keyword argument to `format_call` will raise a `SaltInvocationError`.
This will prevent any future bogus bug searching like what happened on #6912 because the wrong state function argument was being passed.
If the OS was not properly identified, salt/modules/service.py is used
as a fallback provider for the service module/state. However, the way it
looks up the location of the initscripts directory results in a
traceback if the OS grain isn't in the lookup dict.
This commit simplifies the lookup dict and has the module use
/etc/init.d as the location for initscripts if the 'os' grain is not in
the lookup dict, fixing this traceback.