jborean93 / pykrb5

Python krb5 API interface
MIT License
17 stars 8 forks source link

Have `krb5.init_context()` raise an exception on error. #22

Closed pseudometric closed 2 years ago

pseudometric commented 2 years ago

krb5.init_context() currently just returns a null pointer if the C routine fails, which is unlike the norm in this module and I assume is an oversight. Typically this will fail if there's a syntax error in the libkrb5 configuration (/etc/krb5.conf, or whatever is read). A program using pykrb5 that I wrote segfaulted in this situation, because I then passed the null context to other routines. With this change, we get instead:

In [2]: ctx = krb5.init_context()
---------------------------------------------------------------------------
Krb5Error                                 Traceback (most recent call last)
...
Krb5Error: Included profile file could not be read -1429577697
jborean93 commented 2 years ago

I assume is an oversight

Yea I have no idea why I didn't do this but thank you for picking this up and fixing this.