- flush openconnect_certs file in between and finally close before giving to openconnect call

This commit is contained in:
Tino Lange
2019-06-12 11:06:44 +02:00
parent 412560eff7
commit 15c5734878
+4 -2
View File
@@ -148,6 +148,7 @@ def load_conf(cf):
if len(conf[k].strip()) == 0: if len(conf[k].strip()) == 0:
err('empty configuration key: {0}'.format(k)) err('empty configuration key: {0}'.format(k))
conf['debug'] = conf.get('debug', '').lower() in ['1', 'true'] conf['debug'] = conf.get('debug', '').lower() in ['1', 'true']
conf['openconnect_certs'].flush()
return conf return conf
def mfa_priority(conf, ftype, fprovider): def mfa_priority(conf, ftype, fprovider):
@@ -471,10 +472,10 @@ def paloalto_getconfig(conf, s, saml_username, prelogin_cookie):
if len(portal_userauthcookie) == 0: if len(portal_userauthcookie) == 0:
err('empty portal_userauthcookie') err('empty portal_userauthcookie')
gateway = x.find('.//gateways//entry').get('name') gateway = x.find('.//gateways//entry').get('name')
with open(conf['openconnect_certs'].name, 'ab') as cafile:
for entry in x.find('.//root-ca'): for entry in x.find('.//root-ca'):
cert = entry.find('.//cert').text cert = entry.find('.//cert').text
cafile.write(to_b(cert)) conf['openconnect_certs'].write(to_b(cert))
conf['openconnect_certs'].flush()
return portal_userauthcookie, gateway return portal_userauthcookie, gateway
# Combined first half of okta_saml with second half of okta_redirect # Combined first half of okta_saml with second half of okta_redirect
@@ -562,6 +563,7 @@ def main():
else: else:
pcmd = 'printf \'' + bugs + '{0}\''.format(cookie) pcmd = 'printf \'' + bugs + '{0}\''.format(cookie)
print() print()
conf['openconnect_certs'].close()
if conf.get('execute', '').lower() in ['1', 'true']: if conf.get('execute', '').lower() in ['1', 'true']:
cmd = shlex.split(cmd) cmd = shlex.split(cmd)
cmd = [os.path.expandvars(os.path.expanduser(x)) for x in cmd] cmd = [os.path.expandvars(os.path.expanduser(x)) for x in cmd]