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

Add PrincipalRef to deal with aliases #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tlyu
Copy link
Contributor

@tlyu tlyu commented Jan 27, 2015

Subclass Principal into PrincipalRef to deal with principals that must
not be directly freed by garbage collection, e.g., because they're
aliases into structures such as krb5_enc_tkt_part.

Pull 3 of a series of 3. Check out my wip branch for all of them on one branch.

Subclass Principal into PrincipalRef to deal with principals that must
not be directly freed by garbage collection, e.g., because they're
aliases into structures such as krb5_enc_tkt_part.
@davidben
Copy link
Contributor

Hrm. I'm slightly uneasy that this makes the public API no longer memory-safe. I guess one option is if PrincipalRef took a reference to the owning object and were only vended by wrapper functions.

But that has unfortunate memory usage properties (end up keeping objects alive for longer than they should) and begs the question of what to do about all the fields I never bothered to expose, since self._handle and ctypes is hardly reasonable public API.

One option is to go the krb5-go route and have the value-type objects be idiomatic-Python and convert to/from C on-demand. I do like that option, but it means redoing a lot of the existing types. It might be less work than writing equivalent accessors for everything though.

Thoughts?

(I'm not going to be a stickler about it and can just merge this as-is if it makes your life easier. We can figure this out later, if ever. This was mostly a lazy one-off for Roost, and to_data hardly meets the standards of a legitimate Python binding... :-) Though I didn't find an existing one before, so maybe there's room in the world for a good one.)

@tlyu
Copy link
Contributor Author

tlyu commented Jan 28, 2015

I sympathize with your concerns. I think I'll take a closer look at krb5-go and see what alternatives I can come up with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants