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:
commit
e8f72eeab4
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user