New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution module - file.read binary=True fails with decoding errors #55602
Comments
Hey @rares-pop thanks for the report! This will fail on any file that contains non-text (unicode) data. An easy way to test this:
This will break with the above issue. It happens because in the Either we need to update the docs to be explicit that we only support reading text files (despite being able to read them with the The latter might be a much more involved fix, as Salt currently treats all internal data as unicode text. |
@rares-pop what was your desired outcome here? Were you just trying to get the contents of a binary file available on the master? Or...? For a workaround, you could feed the file to |
@waynew - yeah, I mentioned 'reading binary files', so yeah, having non-ascii characters. My particular use-case was to get a .so file from the minion to the master, to allow remote-debug on it. And that .so is binary. I'm aware of cp.push stuff but I haven't tried it out, so I don't know if it works (it's marked as a security concern, and has to be explicitly enabled in master conf, so I wouldn't recommend it). Hmm.. I haven't thought to base64, but I don't think it's feasible if we (or the clients) have to do it manually each time before we want to transfer the file. Maybe if salt would do that inline? I was looking into fixing this issue myself in salt, but as you say, it's core is using unicodes, so it's not a trivial fix to enable this. We are work arounding this by using other non-salt mechanisms, but this behavior is still broken in salt. I start to believe it might be a viable option to modify salt to do that base64 encoding inline, and document this behavior, so the function is not broken. |
I don't hate that idea. It doesn't solve all of our underlying bytes vs. text issues, but it would be an improvement. If it's written with a flag to guard it on the server side of the file client, and then the client side looks for some I don't think that based on priority we'll be able to get this done on the core team, but if someone wants to tackle it, I think this would be a great addition to the Phosphorus release 👍 |
Description of Issue
Tried reading a binary file in Salt, in multiple versions:
2018.3, 2019.2.0, 2019.2.2, but fails with decoding exceptions.
Tried 2018.3 in both Windows and NILinuxRT.
Tried 2019.2.2 in arch linux.
All fails.
For example, using LANG=POSIX, I get this:
However, it fails using UTF-8 too.
Setup
N/A
Steps to Reproduce Issue
try running:
salt-call --local file.read /usr/bin/bash True
Versions Report
The text was updated successfully, but these errors were encountered: