-
Notifications
You must be signed in to change notification settings - Fork 91
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
CA-403952: Fix TapCtl._errmsg() bytes/str type issue #724
CA-403952: Fix TapCtl._errmsg() bytes/str type issue #724
Conversation
TapCtl runs in binary mode when handling encryption key, so the stderr is of 'bytes' type, while 'str.rstrip' in _errmsg expects a 'str' object. This results in a bytes/str type mismatch issue. Signed-off-by: Stephen Cheng <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I so hate the breaking changes between Python 2 & 3 :(
eww, the whole point of subprocess's universal_newlines is to get consistently back to having text. Does |
It's not
|
That's my question. What is so special about |
What's so special is that it is supplied an encryption key, in binary form, as stdin |
Well, that's the root of all of this mess then. There doesn't appear to be a way to get Popen() to have differing text/binary mode on stdin vs others. It's all or nothing. What's the likelihood of getting a version of |
@andyhhp How would you make it handlle getting a binary feed on the stdin? This was an intentional design choice when support for encryption was added to avoid the key being written to disk or recorded on the commandline for the process. We have control of the |
Taking the key on stdin is fine, but the far more normal way of doing this would be to use base64 encoded text, not binary. |
@andyhhp has valid points here, I'm going to raise a follow on ticket to update the
|
As discussed above, need to use base64 for the encryption key. |
TapCtl runs in binary mode when handling encryption key, so the stderr is of 'bytes' type,
while 'str.rstrip' in _errmsg expects a 'str' object. This results in a bytes/str type mismatch issue.
Locally tested:
Wrote a simple test where
line1
is abytes
andline2
is astr
The output is correct: