Skip to content

Commit

Permalink
Add PrincipalRef to deal with aliases
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tlyu committed Jan 28, 2015
1 parent 522fd72 commit 96934d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/krb5.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ def __str__(self):
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self.unparse_name())

# A reference to a principal, to avoid freeing
class PrincipalRef(Principal):
def __init__(self, ctx, princ):
self._ctx = ctx
self._handle = princ

def __del__(self):
pass

class Credentials(object):
def __init__(self, ctx):
self._ctx = ctx
Expand Down

0 comments on commit 96934d3

Please sign in to comment.