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

Merge pull request #93 from altlinux/kinit_check_retcode

Check kinit and kdestroy for errors
This commit is contained in:
Evgeny Sinelnikov 2020-07-01 01:17:16 +04:00 committed by GitHub
commit e8f72eeab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -91,7 +91,6 @@ class gpoa_controller:
'''
GPOA controller entry point
'''
os.environ['KRB5CCNAME'] = 'FILE:{}'.format(self.cache_path)
self.__kinit_successful = machine_kinit(self.cache_path)
self.start_plugins()
self.start_backend()

View File

@ -43,7 +43,6 @@ def set_loglevel(loglevel_num=None):
log_level = 10 * log_num
print('Setting log level to {}'.format(loglevels[log_num]))
logging.basicConfig(format=format_message)
logger = logging.getLogger()
logger.setLevel(log_level)

View File

@ -29,11 +29,22 @@ def machine_kinit(cache_name=None):
Perform kinit with machine credentials
'''
host = get_machine_name()
os.environ['KRB5CCNAME'] = 'FILE:{}'.format(cache_name)
kinit_cmd = ['kinit', '-k', host]
if cache_name:
kinit_cmd.extend(['-c', cache_name])
subprocess.call(kinit_cmd)
return check_krb_ticket()
proc = subprocess.Popen(kinit_cmd)
proc.wait()
result = False
if 0 == proc.returncode:
result = True
if result:
result = check_krb_ticket()
return result
def machine_kdestroy(cache_name=None):
@ -44,7 +55,9 @@ def machine_kdestroy(cache_name=None):
kdestroy_cmd = ['kdestroy']
if cache_name:
kdestroy_cmd.extend(['-c', cache_name])
subprocess.call(kdestroy_cmd)
proc = subprocess.Popen(kdestroy_cmd, stderr=subprocess.DEVNULL)
proc.wait()
if cache_name and os.path.exists(cache_name):
os.unlink(cache_name)