-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support strings and bytes for credential store keys and values (#242) #243
Conversation
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 personally still think that utf-8
should be used by default and if the caller requires a different encoding scheme they pass in a byte string that is already encoded as needed. I'll leave that up to @frozencemetery to decide though.
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 personally still think that utf-8 should be used by default and if the caller requires a different encoding scheme they pass in a byte string that is already encoded as needed. I'll leave that up to @frozencemetery to decide though.
I agree with this. Our default encoding is utf-8; callers can switch that with gssapi.set_encoding()
.
But you do understand the implications of the file system encoding with not being not UTF-8? |
@frozencemetery Done as requested. |
On Linux the filesystem isn't even enforced with an encoding. I can easily create a file with invalid UTF-8 sequences as paths are just a sequence of bytes import os
os.mkdir(b'/tmp/test-folder')
path = b'/tmp/test-folder/test-\xef.txt'
with open(path, mode='wb') as fd:
fd.write(b'test')
print(os.listdir('/tmp/test-folder')
# ['test-\udcef.txt']
print(os.listdir(b'/tmp/test-folder')
# [b'test-\xef.txt'] When showing the path with bash you get |
@jborean93 I didn't say anything about enforcement, I said that invalid file names, as you have seen in the Bash are possible. |
@michael-o we consider this to be user error. It would be nice if the FS would enforce UTF-8, but it doesn't. |
So would I. |
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.
As others have pointed out, it's possible to use pretty much arbitrary bytestrings for filenames. If users need to do that, they're welcome to pass bytes
objects in instead. So I'm fine with this as it currently stands.
Closes: #242 Signed-off-by: Michael Osipov <michael.osipov@siemens.com> [rharwood@redhat.com: commit message]
This closes #242
Disclaimer: I am not a daily Python hacker, I hope I correctly understood how Cython and type conversion/assignment from Python to C works here.
I wasn't also able to run tests because of:
Design decision for
sys.getdefaultencoding()
: I do understand that the entire API uses UTF-8 to convert Python strings tochar *
because Kerberos requires names to be encoded UTF-8 by RFC. Here, we use filesystem paths where Kerberos operates onchar *
which will be passed to the FS and most Unix FS will store paths as raw bytes of the locale instead of canonicalized form in UTF-8 or UTF-16. I hope that most have abandoned non-UTF-8 locales, but who knows.My tries:
Please comment.