Skip to content
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

vault: Read stdin data as binary on python3 #52229

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
4 participants
@swegener
Copy link
Contributor

swegener commented Feb 14, 2019

SUMMARY

On python3 sys.stdin is an encoded file and does not support reading raw data. Use the buffer object of the file object to read raw binary data.

Signed-off-by: Sven Wegener sven.wegener@inovex.de

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

vault

vault: Read stdin data as binary on python3
On python3 sys.stdin is an encoded file object that does not support
reading raw binary data. Use the supplied buffer object to do so.

Signed-off-by: Sven Wegener <sven.wegener@inovex.de>
@sivel

This comment has been minimized.

Copy link
Member

sivel commented Feb 14, 2019

Can you show what problem you are solving? I cannot replicate any incorrect behavior with python3 as of now.

@swegener

This comment has been minimized.

Copy link
Contributor Author

swegener commented Feb 15, 2019

Try encrypting binary data from stdin:

dd bs=512 count=4 if=/dev/urandom status=none | ansible-vault encrypt --vault-password=/tmp/pass --output /tmp/test.file

Python3's sys.stdin assumes the data is encoded according to the current locale/ioencoding and fails with:

ERROR! Unable to read source file (-): 'utf-8' codec can't decode byte 0x94 in position 4: invalid start byte

@bcoca bcoca removed the needs_triage label Feb 19, 2019

@bcoca
Copy link
Member

bcoca left a comment

change looks good, but i would also add changelog entry and tests

@ansibot ansibot added needs_revision and removed core_review labels Feb 19, 2019

@ansibot ansibot added stale_ci and removed new_contributor labels Feb 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.