Skip to content

Commit 53524c4

Browse files
committed
Add a generic method to destroy a realm
This commit adds a method to the driver class to destroy a created realm, and transitions the main file over to use this instead of console.realm.stop().
1 parent 622f4fd commit 53524c4

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

gssapi-console.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@
4343
'GSSAPI console' % PARSED_ARGS.mech)
4444

4545
mech_cls = mech_cls_loader.load()
46-
console = GSSAPIConsole(mech_cls, realm_args=realm_args)
47-
4846
SAVED_ENV = None
4947

5048
try:
5149
# import the env
5250
SAVED_ENV = copy.deepcopy(os.environ)
51+
console = GSSAPIConsole(mech_cls, realm_args=realm_args)
5352
for k, v in console.realm.env.items():
5453
os.environ[k] = v
5554

@@ -76,4 +75,4 @@
7675
else:
7776
del os.environ[k]
7877

79-
console.realm.stop()
78+
console.stop()

gssapi_console/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def __init__(self, driver_cls, use_readline=True, realm_args={}, *args, **kwargs
5151
if os.environ.get('LD_LIBRARY_PATH'):
5252
self.realm.env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
5353

54+
def stop(self):
55+
self._driver.destroy_realm(self.realm)
56+
5457
def _add_readline(self):
5558
self.runsource(READLINE_SRC, '<readline setup>', 'exec')
5659

gssapi_console/drivers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class GSSAPIConsoleDriver(object):
88
def create_realm(self, realm_args):
99
return None
1010

11+
def destroy_realm(self, realm):
12+
return None
13+
1114

1215
class Krb5Console(GSSAPIConsoleDriver):
1316
MECH_NAME = 'krb5'
@@ -19,3 +22,6 @@ def __init__(self):
1922

2023
def create_realm(self, realm_args):
2124
return self._k5test.K5Realm(**realm_args)
25+
26+
def destroy_realm(self, realm):
27+
realm.stop()

0 commit comments

Comments
 (0)