1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

gpoa: Use KRB5CCNAME implicitly

This commit is contained in:
Игорь Чудов 2020-06-25 14:57:42 +04:00
parent 2803d2be72
commit 49f900b2a9
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC
3 changed files with 12 additions and 6 deletions

View File

@ -98,7 +98,7 @@ class gpoa_controller:
self.start_backend()
self.start_frontend()
if self.__kinit_successful:
machine_kdestroy(self.cache_path)
machine_kdestroy()
def start_backend(self):
'''

View File

@ -25,21 +25,27 @@ from .util import get_machine_name
from .logging import slogm
def machine_kinit(cache_name):
def machine_kinit(cache_name=None):
'''
Perform kinit with machine credentials
'''
host = get_machine_name()
subprocess.call(['kinit', '-k', host, '-c', cache_name])
kinit_cmd = ['kinit', '-k', host]
if cache_name:
kinit_cmd.extend(['-c', cache_name])
subprocess.call(kinit_cmd)
return check_krb_ticket()
def machine_kdestroy(cache_name):
def machine_kdestroy(cache_name=None):
'''
Perform kdestroy for machine credentials
'''
host = get_machine_name()
subprocess.call(['kdestroy', '-c', cache_name])
kdestroy_cmd = ['kdestroy']
if cache_name:
kdestroy_cmd.extend(['-c', cache_name])
subprocess.call(kdestroy_cmd)
cache_file = Path(cache_name)
if os.path.exists(cache_name):

View File

@ -31,7 +31,7 @@ def signal_handler(sig_number, frame):
signal.signal(sig_number, signal.SIG_IGN)
# Kerberos cache cleanup on interrupt
machine_kdestroy(os.environ['KRB5CCNAME'])
machine_kdestroy()
print('Received signal, exiting gracefully')
exit(ExitCodeUpdater.EXIT_SIGINT)